Skip to content

Commit 50a9309

Browse files
authored
exchange: Fix weird timezone error on latest Python (#514)
1 parent 8f60102 commit 50a9309

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

newdle/providers/free_busy/exchange.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ def fetch_free_busy(date, tz, uid, email):
117117
for event in busy_info.calendar_events or []:
118118
overlap = find_overlap(
119119
date,
120-
event.start.replace(tzinfo=account_tz),
121-
event.end.replace(tzinfo=account_tz),
120+
_ews_to_dt(event.start).replace(tzinfo=account_tz),
121+
_ews_to_dt(event.end).replace(tzinfo=account_tz),
122122
tzinfo,
123123
)
124124
if event.busy_type in {'Busy', 'Tentative', 'OOF'} and overlap:
@@ -135,3 +135,14 @@ def fetch_free_busy(date, tz, uid, email):
135135
return [
136136
((start.hour, start.minute), (end.hour, end.minute)) for start, end in results
137137
]
138+
139+
140+
def _ews_to_dt(ews_dt):
141+
return datetime(
142+
ews_dt.year,
143+
ews_dt.month,
144+
ews_dt.day,
145+
ews_dt.hour,
146+
ews_dt.minute,
147+
ews_dt.second,
148+
)

0 commit comments

Comments
 (0)