diff --git a/src/lib/components/dualTimeView.svelte b/src/lib/components/dualTimeView.svelte new file mode 100644 index 000000000..14e32ccb5 --- /dev/null +++ b/src/lib/components/dualTimeView.svelte @@ -0,0 +1,69 @@ + + + + + + + {timeToString} + + + + + + + + + + + + + + + + + + + diff --git a/src/lib/components/filePicker.svelte b/src/lib/components/filePicker.svelte index ec2007f29..d26d03744 100644 --- a/src/lib/components/filePicker.svelte +++ b/src/lib/components/filePicker.svelte @@ -1,17 +1,16 @@ @@ -19,11 +20,6 @@ by {deployment.providerCommitAuthor} {:else} - - - {capitalize(timeFromNow(deployment.$updatedAt))} - - {toLocaleDateTime(deployment.$updatedAt)} - + {/if}

diff --git a/src/lib/helpers/date.ts b/src/lib/helpers/date.ts index f7d7f3a4b..012d49cb3 100644 --- a/src/lib/helpers/date.ts +++ b/src/lib/helpers/date.ts @@ -31,7 +31,10 @@ export const toLocaleDate = (datetime: string) => { return date.toLocaleDateString('en', options); }; -export const toLocaleDateTime = (datetime: string | number) => { +export const toLocaleDateTime = ( + datetime: string | number, + timeZone: string | undefined = undefined +) => { const date = new Date(datetime); if (isNaN(date.getTime())) { @@ -39,6 +42,7 @@ export const toLocaleDateTime = (datetime: string | number) => { } const options: Intl.DateTimeFormatOptions = { + timeZone, year: 'numeric', month: 'short', day: 'numeric', @@ -181,3 +185,11 @@ export function getTomorrow(date: Date) { return tomorrow; } + +export function getUTCOffset(): string { + const offsetMinutes = -new Date().getTimezoneOffset(); + const hours = Math.floor(offsetMinutes / 60); + const minutes = Math.abs(offsetMinutes % 60); + + return `${hours >= 0 ? '+' : ''}${hours}${minutes ? `:${minutes.toString().padStart(2, '0')}` : ''}`; +} diff --git a/src/routes/(console)/account/identities.svelte b/src/routes/(console)/account/identities.svelte index ec537e0e3..b58f95332 100644 --- a/src/routes/(console)/account/identities.svelte +++ b/src/routes/(console)/account/identities.svelte @@ -11,6 +11,7 @@ import { oAuthProviders } from '$lib/stores/oauth-providers'; import { Card, Empty, Icon, Layout, Table } from '@appwrite.io/pink-svelte'; import { IconTrash } from '@appwrite.io/pink-icons-svelte'; + import DualTimeView from '$lib/components/dualTimeView.svelte'; async function deleteIdentity(id: string) { try { @@ -70,7 +71,7 @@ {identity.providerEmail} - {toLocaleDateTime(identity.$createdAt)} + {toLocaleDateTime(identity.providerAccessTokenExpiry)} diff --git a/src/routes/(console)/organization-[organization]/billing/budgetCap.svelte b/src/routes/(console)/organization-[organization]/billing/budgetCap.svelte index 47bc47465..2982bc43d 100644 --- a/src/routes/(console)/organization-[organization]/billing/budgetCap.svelte +++ b/src/routes/(console)/organization-[organization]/billing/budgetCap.svelte @@ -3,7 +3,7 @@ import { Click, Submit, trackError, trackEvent } from '$lib/actions/analytics'; import { CardGrid } from '$lib/components'; import { BillingPlan, Dependencies } from '$lib/constants'; - import { Button, Form, FormList, InputNumber, InputSwitch } from '$lib/elements/forms'; + import { Button, Form, InputNumber, InputSwitch } from '$lib/elements/forms'; import { showUsageRatesModal, upgradeURL } from '$lib/stores/billing'; import { addNotification } from '$lib/stores/notifications'; import { organization, currentPlan } from '$lib/stores/organization'; diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/table.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/table.svelte index c56b228a7..d4e8b69b6 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/table.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/table.svelte @@ -12,11 +12,10 @@ } from '@appwrite.io/pink-svelte'; import { IconDotsHorizontal, IconPencil, IconTrash } from '@appwrite.io/pink-icons-svelte'; import { columns } from './store'; - import { timeFromNow } from '$lib/helpers/date'; import DeleteRecordModal from './deleteRecordModal.svelte'; - import { capitalize } from '$lib/helpers/string'; import EditRecordModal from './updateRecordModal.svelte'; import type { DnsRecord } from '$lib/sdk/domains'; + import DualTimeView from '$lib/components/dualTimeView.svelte'; export let data; @@ -78,9 +77,7 @@ {:else if column.id === '$createdAt'} - - {capitalize(timeFromNow(record.$createdAt))} - + {/if} {/if} diff --git a/src/routes/(console)/organization-[organization]/usage/[[invoice]]/totalMembers.svelte b/src/routes/(console)/organization-[organization]/usage/[[invoice]]/totalMembers.svelte index e97db98e4..c87f9efd1 100644 --- a/src/routes/(console)/organization-[organization]/usage/[[invoice]]/totalMembers.svelte +++ b/src/routes/(console)/organization-[organization]/usage/[[invoice]]/totalMembers.svelte @@ -3,13 +3,13 @@ import { EmptyCardCloud } from '$lib/components/billing'; import { BillingPlan } from '$lib/constants'; import { Button } from '$lib/elements/forms'; - import { toLocaleDate } from '$lib/helpers/date'; import { formatCurrency } from '$lib/helpers/numbers'; import { plansInfo, tierToPlan } from '$lib/stores/billing'; import { newMemberModal, organization } from '$lib/stores/organization'; import type { Models } from '@appwrite.io/console'; import { IconInfo, IconPlus } from '@appwrite.io/pink-icons-svelte'; import { Icon, Layout, Table, Tooltip, Typography } from '@appwrite.io/pink-svelte'; + import DualTimeView from '$lib/components/dualTimeView.svelte'; export let members: Models.MembershipList; @@ -78,9 +78,7 @@ - {member.joined - ? toLocaleDate(member.joined) - : toLocaleDate(member.$createdAt)} + {/each} diff --git a/src/routes/(console)/project-[project]/auth/teams/+page.svelte b/src/routes/(console)/project-[project]/auth/teams/+page.svelte index 22d69bd1b..e139bc81e 100644 --- a/src/routes/(console)/project-[project]/auth/teams/+page.svelte +++ b/src/routes/(console)/project-[project]/auth/teams/+page.svelte @@ -14,7 +14,6 @@ } from '$lib/components'; import Create from '../createTeam.svelte'; import { goto } from '$app/navigation'; - import { toLocaleDateTime } from '$lib/helpers/date'; import { Container } from '$lib/layout'; import { base } from '$app/paths'; import type { Models } from '@appwrite.io/console'; @@ -23,6 +22,7 @@ import { canWriteTeams } from '$lib/stores/roles'; import { Icon, Layout, Table } from '@appwrite.io/pink-svelte'; import { IconPlus } from '@appwrite.io/pink-icons-svelte'; + import DualTimeView from '$lib/components/dualTimeView.svelte'; export let data: PageData; @@ -64,7 +64,7 @@ {team.total} members - {toLocaleDateTime(team.$createdAt)} + {/each} diff --git a/src/routes/(console)/project-[project]/databases/database-[database]/backups/table.svelte b/src/routes/(console)/project-[project]/databases/database-[database]/backups/table.svelte index 7f6ef65bb..25bbea229 100644 --- a/src/routes/(console)/project-[project]/databases/database-[database]/backups/table.svelte +++ b/src/routes/(console)/project-[project]/databases/database-[database]/backups/table.svelte @@ -27,6 +27,7 @@ import { LabelCard } from '$lib/components/index.js'; import { Dependencies } from '$lib/constants'; import { Tooltip } from '@appwrite.io/pink-svelte'; + import DualTimeView from '$lib/components/dualTimeView.svelte'; export let data: PageData; @@ -155,12 +156,9 @@ - - - {cleanBackupName(backup)} - - {timeFromNow(backup.$createdAt)} - + + {cleanBackupName(backup)} + {#if backup.status === 'completed'} diff --git a/src/routes/(console)/project-[project]/databases/database-[database]/collection-[collection]/table.svelte b/src/routes/(console)/project-[project]/databases/database-[database]/collection-[collection]/table.svelte index e7ee17b19..ee81a1d00 100644 --- a/src/routes/(console)/project-[project]/databases/database-[database]/collection-[collection]/table.svelte +++ b/src/routes/(console)/project-[project]/databases/database-[database]/collection-[collection]/table.svelte @@ -16,8 +16,8 @@ import RelationshipsModal from './relationshipsModal.svelte'; import { attributes, collection, columns } from './store'; import type { ColumnType } from '$lib/helpers/types'; - import { toLocaleDateTime } from '$lib/helpers/date'; import { Tooltip, Table, Selector, Button, Link } from '@appwrite.io/pink-svelte'; + import DualTimeView from '$lib/components/dualTimeView.svelte'; export let data: PageData; @@ -237,10 +237,10 @@ {/if} {/each} - {toLocaleDateTime(document.$createdAt)} + - {toLocaleDateTime(document.$updatedAt)} + {/each} @@ -269,7 +269,11 @@ - +

Are you sure you want to delete {selectedDb.length} diff --git a/src/routes/(console)/project-[project]/functions/function-[function]/executions/table.svelte b/src/routes/(console)/project-[project]/functions/function-[function]/executions/table.svelte index fa1bf102c..cd270f8e3 100644 --- a/src/routes/(console)/project-[project]/functions/function-[function]/executions/table.svelte +++ b/src/routes/(console)/project-[project]/functions/function-[function]/executions/table.svelte @@ -1,6 +1,6 @@ -