Skip to content

Commit

Permalink
fix(events/api/views.py): Fix timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
setmao committed Feb 19, 2022
1 parent eb29d14 commit 3f23750
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/events/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.conf import settings
from django.db.models import Count
from django.http import Http404
from django.utils.timezone import make_naive

from core.authentication import TokenAuthentication
from events.models import (
Expand Down Expand Up @@ -158,11 +159,11 @@ def speakers(self) -> Union[List[str], List[dict]]:

@property
def begin_time(self) -> str:
return self.obj.begin_time.value.strftime('%Y-%m-%d %H:%M:%S')
return make_naive(self.obj.begin_time.value).strftime('%Y-%m-%d %H:%M:%S')

@property
def end_time(self) -> str:
return self.obj.end_time.value.strftime('%Y-%m-%d %H:%M:%S')
return make_naive(self.obj.end_time.value).strftime('%Y-%m-%d %H:%M:%S')

@property
def is_remote(self) -> bool:
Expand Down Expand Up @@ -295,8 +296,12 @@ def get(self, request):

result = []
for day_info in day_info_dict.values():
day_info['timeline']['begin'] = day_info['timeline']['begin'].value.strftime('%Y-%m-%d %H:%M:%S')
day_info['timeline']['end'] = day_info['timeline']['end'].value.strftime('%Y-%m-%d %H:%M:%S')
day_info['timeline']['begin'] = make_naive(
day_info['timeline']['begin'].value
).strftime('%Y-%m-%d %H:%M:%S')
day_info['timeline']['end'] = make_naive(
day_info['timeline']['end'].value
).strftime('%Y-%m-%d %H:%M:%S')
result.append(day_info)

return Response({'data': result})
Expand Down

0 comments on commit 3f23750

Please sign in to comment.