Skip to content

Commit

Permalink
fix time zone for external eateries (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
mateow99 authored Nov 27, 2023
1 parent 2e4f046 commit e808987
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/event/controllers/populate_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from event.serializers import EventSerializer
from eatery.util.constants import dining_id_to_internal_id
import json
import pytz

class PopulateEventController():
def __init__(self):
Expand Down Expand Up @@ -48,12 +49,14 @@ def generate_external_events(self, json_eatery):
while date.strftime("%A").lower() != json_date["weekday"].lower():
date += timedelta(days=1)
start_string = json_event['start']
start_timestamp = datetime(date.year, date.month, date.day, int(start_string[:2]), int(start_string[3:])).timestamp()
timezone = pytz.timezone('US/Eastern')
start_time = datetime(date.year, date.month, date.day, int(start_string[:2]), int(start_string[3:]))
start_timestamp = timezone.localize(start_time).timestamp()
end_string = json_event['end']
if int(end_string[:2]) < int(start_string[:2]):
date += timedelta(days=1)
end_timestamp = datetime(date.year, date.month, date.day, int(end_string[:2]), int(end_string[3:])).timestamp()

end_time = datetime(date.year, date.month, date.day, int(end_string[:2]), int(end_string[3:]))
end_timestamp = timezone.localize(end_time).timestamp()
eatery_id = json_eatery["id"]
data = {
'eatery': eatery_id,
Expand Down

0 comments on commit e808987

Please sign in to comment.