Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(events): provide time in UTC and ISO format in API response #1099

Merged
merged 1 commit into from
Aug 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(events): provide time in UTC and ISO format in API response
  • Loading branch information
mattwang44 committed Aug 24, 2022
commit aa3d5b27367f2f184f3db35251af0fa0dead8baa
20 changes: 12 additions & 8 deletions src/events/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ def begin_time(self) -> str:
def end_time(self) -> str:
return make_naive(self.obj.end_time.value).strftime('%Y-%m-%d %H:%M:%S')

@property
def begin_time_utc(self) -> str:
return self.obj.begin_time.value

@property
def end_time_utc(self) -> str:
return self.obj.end_time.value

@property
def is_remote(self) -> bool:
if isinstance(self.obj, (KeynoteEvent, ProposedTalkEvent, ProposedTutorialEvent)):
Expand Down Expand Up @@ -244,8 +252,8 @@ def display(self):
'event_type': self.event_type,
'title': self.title,
'speakers': self.speakers,
'begin_time': self.begin_time,
'end_time': self.end_time,
'begin_time': self.begin_time_utc,
'end_time': self.end_time_utc,
'is_remote': self.is_remote,
'recording_policy': self.recording_policy,
'language': self.language,
Expand Down Expand Up @@ -328,12 +336,8 @@ def get(self, request):

result = []
for day_info in day_info_dict.values():
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')
day_info['timeline']['begin'] = day_info['timeline']['begin'].value
day_info['timeline']['end'] = day_info['timeline']['end'].value
result.append(day_info)

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