From 10976d5742e97ba16c65dfb8a392599a3a8a6a78 Mon Sep 17 00:00:00 2001 From: ray Date: Tue, 28 May 2024 15:24:09 -0700 Subject: [PATCH] DBC22-2259: start and end time now parsed as utc --- src/backend/apps/feed/serializers.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/backend/apps/feed/serializers.py b/src/backend/apps/feed/serializers.py index faea9e15..5003b7e7 100644 --- a/src/backend/apps/feed/serializers.py +++ b/src/backend/apps/feed/serializers.py @@ -1,6 +1,7 @@ import zoneinfo from datetime import datetime +import pytz from apps.feed.fields import ( DriveBCDateField, DriveBCField, @@ -16,8 +17,8 @@ WebcamRegionField, WebcamRegionGroupField, ) -from apps.weather.models import CurrentWeather, RegionalWeather from apps.rest.models import RestStop +from apps.weather.models import CurrentWeather, RegionalWeather from rest_framework import serializers @@ -197,9 +198,12 @@ def to_internal_value(self, data): # Parse start and end into datetime objects if start != '': - internal_data['start'] = datetime.strptime(start, "%Y-%m-%dT%H:%M") + start_time = datetime.strptime(start, "%Y-%m-%dT%H:%M").replace(tzinfo=pytz.utc) + internal_data['start'] = start_time + if end != '': - internal_data['end'] = datetime.strptime(end, "%Y-%m-%dT%H:%M") + end_time = datetime.strptime(end, "%Y-%m-%dT%H:%M").replace(tzinfo=pytz.utc) + internal_data['end'] = end_time return internal_data @@ -264,6 +268,7 @@ class Meta: 'issuedUtc', ) + # Rest Stop serializer class RestStopSerializer(serializers.Serializer): class Meta: