Skip to content

Commit 7b2c186

Browse files
committed
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.
1 parent 3c4327f commit 7b2c186

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

khal/controllers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import textwrap
2828
from collections import OrderedDict, defaultdict
2929
from shutil import get_terminal_size
30-
from typing import Callable, List, Optional
30+
from typing import Callable, List, Optional, Tuple
3131

3232
import pytz
3333
from click import confirm, echo, prompt, style
@@ -148,7 +148,7 @@ def start_end_from_daterange(
148148
locale: LocaleConfiguration,
149149
default_timedelta_date: dt.timedelta=dt.timedelta(days=1),
150150
default_timedelta_datetime: dt.timedelta=dt.timedelta(hours=1),
151-
):
151+
) -> Tuple[dt.datetime, dt.datetime]:
152152
"""
153153
convert a string description of a daterange into start and end datetime
154154
@@ -158,7 +158,8 @@ def start_end_from_daterange(
158158
:param locale: locale settings
159159
"""
160160
if not daterange:
161-
start = dt.datetime(*dt.date.today().timetuple()[:3])
161+
today = dt.datetime.now(locale['local_timezone']).date()
162+
start = dt.datetime.combine(today, dt.time.min)
162163
end = start + default_timedelta_date
163164
else:
164165
start, end, allday = parse_datetime.guessrangefstr(

0 commit comments

Comments
 (0)