From 5d2e56919fbde500931ffd715c5dd4fcd4c32bc1 Mon Sep 17 00:00:00 2001 From: Christian Geier Date: Fri, 3 Nov 2023 23:54:29 +0100 Subject: [PATCH] fix default for `list` and `calendar` command The default (today) was until now not localized, but today in UTC was assumed. This could lead to commands such as `khal calendar` starting to show events from with either the previous or the next day instead of today. --- khal/controllers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/khal/controllers.py b/khal/controllers.py index 6af65592d..7d755fe99 100644 --- a/khal/controllers.py +++ b/khal/controllers.py @@ -27,7 +27,7 @@ import textwrap from collections import OrderedDict, defaultdict from shutil import get_terminal_size -from typing import Callable, List, Optional +from typing import Callable, List, Optional, Tuple import pytz from click import confirm, echo, prompt, style @@ -147,7 +147,7 @@ def start_end_from_daterange( locale: LocaleConfiguration, default_timedelta_date: dt.timedelta=dt.timedelta(days=1), default_timedelta_datetime: dt.timedelta=dt.timedelta(hours=1), -): +) -> Tuple[dt.datetime, dt.datetime]: """ convert a string description of a daterange into start and end datetime @@ -157,7 +157,8 @@ def start_end_from_daterange( :param locale: locale settings """ if not daterange: - start = dt.datetime(*dt.date.today().timetuple()[:3]) + today = dt.datetime.now(locale['local_timezone']).date() + start = dt.datetime.combine(today, dt.time.min) end = start + default_timedelta_date else: start, end, allday = parse_datetime.guessrangefstr(