mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix: add toISOString helper for date formatting
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
<script lang="ts">
|
||||
import { type ComponentProps } from 'svelte';
|
||||
import { capitalize } from '$lib/helpers/string';
|
||||
import { timeFromNow, toLocaleDateTime, toLocalDateTimeISO } from '$lib/helpers/date';
|
||||
import {
|
||||
timeFromNow,
|
||||
toLocaleDateTime,
|
||||
toLocalDateTimeISO,
|
||||
toISOString
|
||||
} from '$lib/helpers/date';
|
||||
import { Badge, InteractiveText, Layout, Popover, Typography } from '@appwrite.io/pink-svelte';
|
||||
|
||||
export let time: string = '';
|
||||
@@ -99,7 +104,7 @@
|
||||
isVisible
|
||||
variant="copy"
|
||||
text={toLocaleDateTime(time, 'UTC')}
|
||||
value={new Date(time).toISOString()} />
|
||||
value={toISOString(time)} />
|
||||
|
||||
<Badge variant="secondary" content="UTC" size="xs" />
|
||||
</Layout.Stack>
|
||||
|
||||
@@ -223,3 +223,12 @@ export function getUTCOffset(): string {
|
||||
|
||||
return `${hours >= 0 ? '+' : ''}${hours}${minutes ? `:${minutes.toString().padStart(2, '0')}` : ''}`;
|
||||
}
|
||||
|
||||
export function toISOString(date: string): string {
|
||||
const d = new Date(date);
|
||||
|
||||
if (isNaN(d.getTime())) {
|
||||
return 'n/a';
|
||||
}
|
||||
return d.toISOString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user