diff --git a/api/src/core/types/ini.ts b/api/src/core/types/ini.ts index 5cf62e28b..c2cb6f27d 100644 --- a/api/src/core/types/ini.ts +++ b/api/src/core/types/ini.ts @@ -11,7 +11,9 @@ interface Display { critical: string; custom: string; dashapps: string; + /** a strftime format string */ date: string; + /** a strftime format string */ time?: string; hot: string; max: string; @@ -42,10 +44,10 @@ interface Notify { plugin: string; docker_notify: 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'; /** - * Time format: + * @deprecated (will remove in future release). Time format: * - `hi: A` => 12 hr * - `H:i` => 24 hr (default) */ diff --git a/api/src/unraid-api/graph/resolvers/notifications/notifications.service.ts b/api/src/unraid-api/graph/resolvers/notifications/notifications.service.ts index 839bab730..46d99d8f4 100644 --- a/api/src/unraid-api/graph/resolvers/notifications/notifications.service.ts +++ b/api/src/unraid-api/graph/resolvers/notifications/notifications.service.ts @@ -700,9 +700,11 @@ export class NotificationsService { } private parseNotificationDateToIsoDate(unixStringSeconds: string | undefined): Date | null { - if (unixStringSeconds && !isNaN(Number(unixStringSeconds))) { - return new Date(Number(unixStringSeconds) * 1_000); + const timeStamp = Number(unixStringSeconds) + 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; } diff --git a/api/src/utils.ts b/api/src/utils.ts index 7dd10afeb..c203c4ef1 100644 --- a/api/src/utils.ts +++ b/api/src/utils.ts @@ -138,18 +138,16 @@ export function formatDatetime( if (dateFormat === '%c') { /**---------------------------------------------- * Omit Timezone - * - * we omit trailing tz by only keeping the first 6 parts - * of sys time (can't omit last x parts bc tz isn't always 3 words). - * - * the magic number 6 comes from the sys time string, which - * 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) + + * We omit the trailing tz `%Z` from systime's format + * which expands to '%a %d %b %Y %X %Z' in strftime's + * implementation. For reference, sys time looks like + * 'Wed 20 Nov 2024 06:39:39 AM Pacific Standard Time' + * *---------------------------------------------**/ if (omitTimezone) { - formatted = formatted.split(' ').slice(0, 6).join(' '); + const timezoneFreeFormat = '%a %d %b %Y %I:%M:%S %p'; + formatted = strftime(timezoneFreeFormat, date); } } else { /**----------------------------------------------