mirror of
https://github.com/euzu/tuliprox.git
synced 2026-10-05 15:32:31 +02:00
some ui refactorings,
use_user_db option for storing api user inside db file
This commit is contained in:
@@ -2,11 +2,18 @@ function formatDate(date: any): string {
|
||||
if (typeof date === 'string') {
|
||||
return date;
|
||||
}
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const year = date.getFullYear();
|
||||
if (typeof date === 'number') {
|
||||
date = new Date(date);
|
||||
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
if (typeof date?.getTime === 'function') {
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const year = date.getFullYear();
|
||||
|
||||
return `${year}-${month}-${day}`;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
const DateUtils = {
|
||||
@@ -15,6 +22,30 @@ const DateUtils = {
|
||||
return formatDate(date);
|
||||
}
|
||||
return '';
|
||||
},
|
||||
toUnixSeconds: (date: any) => {
|
||||
if (date && typeof date.getTime == 'function') {
|
||||
if (date.getTime() > 0) {
|
||||
return Math.floor(date.getTime() / 1000);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (date && typeof date == 'number') {
|
||||
if ( date > 0) {
|
||||
return Math.floor(date / 1000);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return date;
|
||||
},
|
||||
unixSecondsToDate: (date: any) => {
|
||||
if (date && typeof date == 'number') {
|
||||
return new Date(date * 1000);
|
||||
}
|
||||
if (date && typeof date.getTime == 'function') {
|
||||
return date;
|
||||
}
|
||||
return date;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user