Skip to content

Commit

Permalink
Merge pull request pycontw#1149 from pycontw/update/ccip/session-time…
Browse files Browse the repository at this point in the history
…zone

feat(ccip): let session start/end time follow local timezone
  • Loading branch information
josix committed Aug 30, 2023
2 parents bf7899e + 5fb88a9 commit 5d3c25f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/ccip/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import operator
from datetime import timezone, timedelta

from django.http import JsonResponse
from django.templatetags.static import static
Expand Down Expand Up @@ -166,11 +167,15 @@ def _transform_session(request, event, type_key, info_getter):
for speaker in event_info.speakers
]

LOCAL_TIMEZONE = timezone(offset=timedelta(hours=8))
# Explicitly show the local timezone used by OPass(CCIP)
# to avoid iOS device showing UTC+0 time without changing it to local time
# https://github.com/CCIP-App/CCIP-iOS/issues/54
session = {
'id': f'{type_key}-{event_info.pk}',
'type': type_key,
'start': event.begin_time.value.isoformat() if event.begin_time else None,
'end': event.end_time.value.isoformat() if event.end_time else None,
'start': event.begin_time.value.astimezone(LOCAL_TIMEZONE).isoformat() if event.begin_time else None,
'end': event.end_time.value.astimezone(LOCAL_TIMEZONE).isoformat() if event.end_time else None,
'slide': event_info.slide_link,
'speakers': [speaker['id'] for speaker in speakers],
'tags': [tag['id'] for tag in tags],
Expand Down

0 comments on commit 5d3c25f

Please sign in to comment.