Skip to content

Commit

Permalink
Fix calendar sync failing on months having 1st day as Monday
Browse files Browse the repository at this point in the history
  • Loading branch information
ReekenX authored and mandarons committed Apr 12, 2024
1 parent 4abbb6a commit b815d68
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions icloudpy/services/calendar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Calendar service."""

from calendar import monthrange
from datetime import datetime

Expand Down Expand Up @@ -46,9 +47,9 @@ def refresh_client(self, from_dt=None, to_dt=None):
have been given, the range becomes this month.
"""
today = datetime.today()
first_day, last_day = monthrange(today.year, today.month)
_, last_day = monthrange(today.year, today.month)
if not from_dt:
from_dt = datetime(today.year, today.month, first_day)
from_dt = datetime(today.year, today.month, 1)
if not to_dt:
to_dt = datetime(today.year, today.month, last_day)
params = dict(self.params)
Expand Down Expand Up @@ -76,8 +77,8 @@ def calendars(self):
Retrieves calendars of this month.
"""
today = datetime.today()
first_day, last_day = monthrange(today.year, today.month)
from_dt = datetime(today.year, today.month, first_day)
_, last_day = monthrange(today.year, today.month)
from_dt = datetime(today.year, today.month, 1)
to_dt = datetime(today.year, today.month, last_day)
params = dict(self.params)
params.update(
Expand Down

0 comments on commit b815d68

Please sign in to comment.