From a60d077cb24ac65ba468cbb0504e2bc50733e95b Mon Sep 17 00:00:00 2001 From: Debin Li Date: Thu, 12 May 2022 10:24:57 -0400 Subject: [PATCH] Issue #145: Make calendar link timezone aware --- api/yelp_beans/send_email.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/yelp_beans/send_email.py b/api/yelp_beans/send_email.py index 7cd31549..48721d3a 100644 --- a/api/yelp_beans/send_email.py +++ b/api/yelp_beans/send_email.py @@ -183,6 +183,14 @@ def create_google_calendar_invitation_link(user_list, title, office, location, m 'location': office + " " + location, 'add': ','.join([user.email for user in user_list]) } + try: + if meeting_datetime.strftime("%Z") and "ctz" not in url_params: + # If the meeting time have a timezone specified + # and Calendar URL link doesn't contain timezone + # Add the "ctz" parameter to Google's Calendar template link + url_params["ctz"] = meeting_datetime.tzinfo.zone + except Exception: + logging.exception("Failed to add timezone information to Google Calendar link") invite_url += urllib.parse.urlencode(url_params) return invite_url