Skip to content
Snippets Groups Projects
Verified Commit 9c5e3f0f authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

fix: expose start & end of a timeslot using astimezone

parent 2977b143
No related branches found
No related tags found
No related merge requests found
Pipeline #8529 passed
...@@ -19,7 +19,9 @@ ...@@ -19,7 +19,9 @@
# #
import re import re
from datetime import datetime
from functools import cached_property from functools import cached_property
from zoneinfo import ZoneInfo
from drf_jsonschema_serializer import JSONSchemaField from drf_jsonschema_serializer import JSONSchemaField
from rest_framework import serializers from rest_framework import serializers
...@@ -985,6 +987,14 @@ class TimeSlotSerializer(serializers.ModelSerializer): ...@@ -985,6 +987,14 @@ class TimeSlotSerializer(serializers.ModelSerializer):
def get_note_id(obj) -> int: def get_note_id(obj) -> int:
return obj.note.id if hasattr(obj, "note") else None return obj.note.id if hasattr(obj, "note") else None
@staticmethod
def get_start(obj) -> datetime:
return obj.start.astimezone(tz=ZoneInfo(settings.TIME_ZONE))
@staticmethod
def get_end(obj) -> datetime:
return obj.end.astimezone(tz=ZoneInfo(settings.TIME_ZONE))
def update(self, instance, validated_data): def update(self, instance, validated_data):
"""Update and return an existing Show instance, given the validated data.""" """Update and return an existing Show instance, given the validated data."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment