Skip to content

Commit

Permalink
DBC22-3081: fixed timezone conversion offset
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-oxd committed Dec 10, 2024
1 parent 583c59e commit 672157c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/backend/apps/event/tasks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
import logging
from zoneinfo import ZoneInfo

import pytz
from apps.event.enums import EVENT_DIFF_FIELDS, EVENT_STATUS, EVENT_UPDATE_FIELDS
Expand Down Expand Up @@ -120,7 +121,7 @@ def populate_all_event_data():

# DBC22-3081 replace timezone with DIT API data, to be removed if source is corrected
if cars_data['timezone']:
new_tz = pytz.timezone(cars_data['timezone'])
new_tz = ZoneInfo(cars_data['timezone'])

first_created_time = event_data["first_created"].replace(tzinfo=new_tz)
event_data["first_created"] = cap_time_to_now(first_created_time)
Expand All @@ -129,11 +130,11 @@ def populate_all_event_data():
event_data["last_updated"] = cap_time_to_now(last_updated_time)

if "start" in event_data:
pacific_start_time = event_data["start"].astimezone(pytz.timezone('America/Vancouver'))
pacific_start_time = event_data["start"].astimezone(ZoneInfo('America/Vancouver'))
event_data["start"] = pacific_start_time.replace(tzinfo=new_tz)

if "end" in event_data:
pacific_end_time = event_data["end"].astimezone(pytz.timezone('America/Vancouver'))
pacific_end_time = event_data["end"].astimezone(ZoneInfo('America/Vancouver'))
event_data["end"] = pacific_end_time.replace(tzinfo=new_tz)

# Populate db obj
Expand Down

0 comments on commit 672157c

Please sign in to comment.