Skip to content

Commit

Permalink
DBC22-2259: start and end time now parsed as utc
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-oxd authored and fatbird committed Jul 31, 2024
1 parent aeedaba commit 10976d5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/backend/apps/feed/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import zoneinfo
from datetime import datetime

import pytz
from apps.feed.fields import (
DriveBCDateField,
DriveBCField,
Expand All @@ -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


Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -264,6 +268,7 @@ class Meta:
'issuedUtc',
)


# Rest Stop serializer
class RestStopSerializer(serializers.Serializer):
class Meta:
Expand Down

0 comments on commit 10976d5

Please sign in to comment.