mirror of
https://github.com/unraid/api.git
synced 2025-12-31 13:39:52 -06:00
feat(api): omit tz from sys time date format by default
This commit is contained in:
@@ -11,7 +11,9 @@ interface Display {
|
|||||||
critical: string;
|
critical: string;
|
||||||
custom: string;
|
custom: string;
|
||||||
dashapps: string;
|
dashapps: string;
|
||||||
|
/** a strftime format string */
|
||||||
date: string;
|
date: string;
|
||||||
|
/** a strftime format string */
|
||||||
time?: string;
|
time?: string;
|
||||||
hot: string;
|
hot: string;
|
||||||
max: string;
|
max: string;
|
||||||
@@ -42,10 +44,10 @@ interface Notify {
|
|||||||
plugin: string;
|
plugin: string;
|
||||||
docker_notify: string;
|
docker_notify: string;
|
||||||
report: string;
|
report: string;
|
||||||
/** Date format: DD-MM-YYYY, MM-DD-YYY, or YYYY-MM-DD */
|
/** @deprecated (will remove in future release). Date format: DD-MM-YYYY, MM-DD-YYY, or YYYY-MM-DD */
|
||||||
date: 'd-m-Y' | 'm-d-Y' | 'Y-m-d';
|
date: 'd-m-Y' | 'm-d-Y' | 'Y-m-d';
|
||||||
/**
|
/**
|
||||||
* Time format:
|
* @deprecated (will remove in future release). Time format:
|
||||||
* - `hi: A` => 12 hr
|
* - `hi: A` => 12 hr
|
||||||
* - `H:i` => 24 hr (default)
|
* - `H:i` => 24 hr (default)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -700,9 +700,11 @@ export class NotificationsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private parseNotificationDateToIsoDate(unixStringSeconds: string | undefined): Date | null {
|
private parseNotificationDateToIsoDate(unixStringSeconds: string | undefined): Date | null {
|
||||||
if (unixStringSeconds && !isNaN(Number(unixStringSeconds))) {
|
const timeStamp = Number(unixStringSeconds)
|
||||||
return new Date(Number(unixStringSeconds) * 1_000);
|
if (unixStringSeconds && !Number.isNaN(timeStamp)) {
|
||||||
|
return new Date(timeStamp * 1_000);
|
||||||
}
|
}
|
||||||
|
// i.e. if unixStringSeconds is an empty string or represents a non-numberS
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -138,18 +138,16 @@ export function formatDatetime(
|
|||||||
if (dateFormat === '%c') {
|
if (dateFormat === '%c') {
|
||||||
/**----------------------------------------------
|
/**----------------------------------------------
|
||||||
* Omit Timezone
|
* Omit Timezone
|
||||||
*
|
|
||||||
* we omit trailing tz by only keeping the first 6 parts
|
* We omit the trailing tz `%Z` from systime's format
|
||||||
* of sys time (can't omit last x parts bc tz isn't always 3 words).
|
* which expands to '%a %d %b %Y %X %Z' in strftime's
|
||||||
*
|
* implementation. For reference, sys time looks like
|
||||||
* the magic number 6 comes from the sys time string, which
|
* 'Wed 20 Nov 2024 06:39:39 AM Pacific Standard Time'
|
||||||
* looks like 'Wed 20 Nov 2024 06:39:39 AM Pacific Standard Time'
|
*
|
||||||
*
|
|
||||||
* note: this may not work with right-to-left locales
|
|
||||||
* (where tz may be in first 6 parts)
|
|
||||||
*---------------------------------------------**/
|
*---------------------------------------------**/
|
||||||
if (omitTimezone) {
|
if (omitTimezone) {
|
||||||
formatted = formatted.split(' ').slice(0, 6).join(' ');
|
const timezoneFreeFormat = '%a %d %b %Y %I:%M:%S %p';
|
||||||
|
formatted = strftime(timezoneFreeFormat, date);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/**----------------------------------------------
|
/**----------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user