From 2b16712496b1ef338737e5313dc717e51ce067c3 Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Sat, 17 Aug 2024 08:30:24 -0400 Subject: [PATCH] chore: Update time zone handling in code --- backend/server/main/settings.py | 2 +- frontend/src/lib/components/AdventureCard.svelte | 2 +- frontend/src/lib/components/ChecklistCard.svelte | 2 +- frontend/src/lib/components/CollectionCard.svelte | 5 ++--- frontend/src/lib/components/NoteCard.svelte | 2 +- frontend/src/lib/components/TransportationCard.svelte | 2 +- frontend/src/routes/adventures/[id]/+page.svelte | 6 ++++-- frontend/src/routes/collections/[id]/+page.svelte | 8 ++++---- frontend/src/routes/profile/+page.svelte | 4 +++- 9 files changed, 18 insertions(+), 15 deletions(-) diff --git a/backend/server/main/settings.py b/backend/server/main/settings.py index 35020b8c..71c1525b 100644 --- a/backend/server/main/settings.py +++ b/backend/server/main/settings.py @@ -112,7 +112,7 @@ LANGUAGE_CODE = 'en-us' -TIME_ZONE = 'America/New_York' +TIME_ZONE = 'UTC' USE_I18N = True diff --git a/frontend/src/lib/components/AdventureCard.svelte b/frontend/src/lib/components/AdventureCard.svelte index fe7d41de..191656c9 100644 --- a/frontend/src/lib/components/AdventureCard.svelte +++ b/frontend/src/lib/components/AdventureCard.svelte @@ -198,7 +198,7 @@ {#if adventure.date && adventure.date !== ''}
-

{new Date(adventure.date).toLocaleDateString('en-US', { timeZone: 'UTC' })}

+

{new Date(adventure.date).toLocaleDateString(undefined, { timeZone: 'UTC' })}

{/if} {#if adventure.activity_types && adventure.activity_types.length > 0} diff --git a/frontend/src/lib/components/ChecklistCard.svelte b/frontend/src/lib/components/ChecklistCard.svelte index 6df1d8bb..b0f05d42 100644 --- a/frontend/src/lib/components/ChecklistCard.svelte +++ b/frontend/src/lib/components/ChecklistCard.svelte @@ -44,7 +44,7 @@ {#if checklist.date && checklist.date !== ''}
-

{new Date(checklist.date).toLocaleDateString('en-US', { timeZone: 'UTC' })}

+

{new Date(checklist.date).toLocaleDateString(undefined, { timeZone: 'UTC' })}

{/if}
diff --git a/frontend/src/lib/components/CollectionCard.svelte b/frontend/src/lib/components/CollectionCard.svelte index df07f461..535337ab 100644 --- a/frontend/src/lib/components/CollectionCard.svelte +++ b/frontend/src/lib/components/CollectionCard.svelte @@ -98,9 +98,8 @@

{collection.adventures.length} Adventures

{#if collection.start_date && collection.end_date}

- Dates: {new Date(collection.start_date).toLocaleDateString('en-US', { timeZone: 'UTC' })} - {new Date( - collection.end_date - ).toLocaleDateString('en-US', { timeZone: 'UTC' })} + Dates: {new Date(collection.start_date).toLocaleDateString(undefined, { timeZone: 'UTC' })} - + {new Date(collection.end_date).toLocaleDateString(undefined, { timeZone: 'UTC' })}

diff --git a/frontend/src/lib/components/NoteCard.svelte b/frontend/src/lib/components/NoteCard.svelte index 71a8ea40..863ea4d1 100644 --- a/frontend/src/lib/components/NoteCard.svelte +++ b/frontend/src/lib/components/NoteCard.svelte @@ -45,7 +45,7 @@ {#if note.date && note.date !== ''}

-

{new Date(note.date).toLocaleDateString('en-US', { timeZone: 'UTC' })}

+

{new Date(note.date).toLocaleDateString(undefined, { timeZone: 'UTC' })}

{/if}
diff --git a/frontend/src/lib/components/TransportationCard.svelte b/frontend/src/lib/components/TransportationCard.svelte index a27ea9ad..dd2a53af 100644 --- a/frontend/src/lib/components/TransportationCard.svelte +++ b/frontend/src/lib/components/TransportationCard.svelte @@ -50,7 +50,7 @@

{/if} {#if transportation.date} - {new Date(transportation.date).toLocaleString()} + {new Date(transportation.date).toLocaleString(undefined, { timeZone: 'UTC' })} {/if} {#if user?.pk === transportation.user_id}
diff --git a/frontend/src/routes/adventures/[id]/+page.svelte b/frontend/src/routes/adventures/[id]/+page.svelte index 1e6b0f50..e7bc4952 100644 --- a/frontend/src/routes/adventures/[id]/+page.svelte +++ b/frontend/src/routes/adventures/[id]/+page.svelte @@ -169,7 +169,9 @@ {new Date(adventure.date).toLocaleDateString()}{new Date(adventure.date).toLocaleDateString(undefined, { + timeZone: 'UTC' + })}
{/if} @@ -309,7 +311,7 @@

{adventure.date - ? new Date(adventure.date).toLocaleDateString('en-US', { + ? new Date(adventure.date).toLocaleDateString(undefined, { timeZone: 'UTC' }) : ''} diff --git a/frontend/src/routes/collections/[id]/+page.svelte b/frontend/src/routes/collections/[id]/+page.svelte index 3f8cb864..ce2b3cae 100644 --- a/frontend/src/routes/collections/[id]/+page.svelte +++ b/frontend/src/routes/collections/[id]/+page.svelte @@ -510,9 +510,9 @@

Duration: {numberOfDays} days

{/if}

- Dates: {new Date(collection.start_date).toLocaleDateString('en-US', { timeZone: 'UTC' })} - {new Date( + Dates: {new Date(collection.start_date).toLocaleDateString(undefined, { timeZone: 'UTC' })} - {new Date( collection.end_date - ).toLocaleDateString('en-US', { timeZone: 'UTC' })} + ).toLocaleDateString(undefined, { timeZone: 'UTC' })}

{#each Array(numberOfDays) as _, i} @@ -539,7 +539,7 @@ )[dateString]}

- Day {i + 1} - {currentDate.toLocaleDateString('en-US', { timeZone: 'UTC' })} + Day {i + 1} - {currentDate.toLocaleDateString(undefined, { timeZone: 'UTC' })}

{#if dayAdventures.length > 0} @@ -626,7 +626,7 @@

{adventure.date - ? new Date(adventure.date).toLocaleDateString('en-US', { timeZone: 'UTC' }) + ? new Date(adventure.date).toLocaleDateString(undefined, { timeZone: 'UTC' }) : ''}

diff --git a/frontend/src/routes/profile/+page.svelte b/frontend/src/routes/profile/+page.svelte index 44472b13..4265d7fc 100644 --- a/frontend/src/routes/profile/+page.svelte +++ b/frontend/src/routes/profile/+page.svelte @@ -50,7 +50,9 @@

Member Since

-

{new Date(data.user.date_joined).toLocaleDateString()}

+

+ {new Date(data.user.date_joined).toLocaleDateString(undefined, { timeZone: 'UTC' })} +

{/if}