Skip to content

Commit 460c5d2

Browse files
committed
update
1 parent c45bcf6 commit 460c5d2

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

khal/controllers.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def format_day(day: dt.date, format_string: str, locale, attributes=None):
6262
attributes["date"] = day.strftime(locale['dateformat'])
6363
attributes["date-long"] = day.strftime(locale['longdateformat'])
6464

65-
attributes["name"] = parse_datetime.construct_daynames(day, local_timezone=locale['local_timezone'])
65+
attributes["name"] = parse_datetime.construct_daynames(day, timezone=locale['local_timezone'])
6666

6767
colors = {"reset": style("", reset=True), "bold": style("", bold=True, reset=False)}
6868
for c in ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"]:
@@ -204,8 +204,11 @@ def get_events_between(
204204
env = {}
205205
assert start
206206
assert end
207-
start_local = locale['local_timezone'].localize(start)
208-
end_local = locale['local_timezone'].localize(end)
207+
assert start.tzinfo is not None
208+
assert end.tzinfo is not None
209+
210+
start_local = start
211+
end_local = end
209212

210213
start = start_local.replace(tzinfo=None)
211214
end = end_local.replace(tzinfo=None)
@@ -273,6 +276,8 @@ def khal_list(
273276
default_timedelta_datetime=conf['default']['timedelta'],
274277
)
275278
logger.debug(f'Getting all events between {start} and {end}')
279+
assert start.tzinfo is not None
280+
assert end.tzinfo is not None
276281

277282
elif datepoint is not None:
278283
if not datepoint:
@@ -295,18 +300,23 @@ def khal_list(
295300
bold=True,
296301
)
297302
logger.debug(f'Getting all events between {start} and {end}')
303+
assert start.tzinfo is not None
304+
assert end.tzinfo is not None
305+
else:
306+
raise ValueError('Something has gone wrong')
298307

299308
event_column: List[str] = []
300309
once = set() if once else None
301310
if env is None:
302311
env = {}
303312

304-
original_start = conf['locale']['local_timezone'].localize(start)
313+
original_start = start
305314
while start < end:
306315
if start.date() == end.date():
307316
day_end = end
308317
else:
309318
day_end = dt.datetime.combine(start.date(), dt.time.max)
319+
day_end = day_end.replace(tzinfo=start.tzinfo)
310320
current_events = get_events_between(
311321
collection, locale=conf['locale'], formatter=formatter, start=start,
312322
end=day_end, notstarted=notstarted, original_start=original_start,
@@ -320,6 +330,7 @@ def khal_list(
320330
event_column.append(format_day(start.date(), day_format, conf['locale']))
321331
event_column.extend(current_events)
322332
start = dt.datetime(*start.date().timetuple()[:3]) + dt.timedelta(days=1)
333+
start = start.replace(tzinfo=original_start.tzinfo)
323334

324335
return event_column
325336

0 commit comments

Comments
 (0)