some ui refactorings,

use_user_db option for storing api user inside db file
This commit is contained in:
euzu
2025-02-26 13:46:23 +01:00
parent 4a5f1b488d
commit cbef4e3d4b
16 changed files with 493 additions and 123 deletions
+35 -4
View File
@@ -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;
}
}