Skip to content
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
13 changes: 5 additions & 8 deletions py3status/modules/google_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@
Requires:
1. Python library google-api-python-client.
2. Python library google-auth-oauthlib.
3. Python library python-dateutil.
4. OAuth 2.0 credentials for the Google Calendar api.
3. OAuth 2.0 credentials for the Google Calendar api.

Follow Step 1 of the guide here to obtain your OAuth 2.0 credentials:
https://developers.google.com/google-apps/calendar/quickstart/python
Expand Down Expand Up @@ -166,8 +165,6 @@
except ImportError:
from apiclient import discovery

from dateutil import parser
from dateutil.tz import tzlocal
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
Expand Down Expand Up @@ -338,11 +335,11 @@ def _check_warn_threshold(self, time_to, event_dict):

def _gstr_to_date(self, date_str):
"""Returns a dateime object from calendar date string."""
return parser.parse(date_str).replace(tzinfo=tzlocal())
return datetime.datetime.fromisoformat(date_str).astimezone()

def _gstr_to_datetime(self, date_time_str):
"""Returns a datetime object from calendar date/time string."""
return parser.parse(date_time_str)
return datetime.datetime.fromisoformat(date_time_str.replace("Z", "+00:00"))

def _datetime_to_str(self, date_time, dt_format):
"""Returns a strftime formatted string from a datetime object."""
Expand All @@ -353,7 +350,7 @@ def _delta_time(self, date_time):
Returns in a dict the number of days/hours/minutes and total minutes
until date_time.
"""
now = datetime.datetime.now(tzlocal())
now = datetime.datetime.now().astimezone()
diff = date_time - now

days = int(diff.days)
Expand Down Expand Up @@ -419,7 +416,7 @@ def _build_response(self):
start_dt = self._gstr_to_datetime(event["start"].get("dateTime"))
end_dt = self._gstr_to_datetime(event["end"].get("dateTime"))

if end_dt < datetime.datetime.now(tzlocal()):
if end_dt < datetime.datetime.now().astimezone():
continue

event_dict["start_time"] = self._datetime_to_str(start_dt, self.format_time)
Expand Down
Loading