Skip to content

Commit 5d2e569

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 25a877f commit 5d2e569

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
@@ -147,7 +147,7 @@ def start_end_from_daterange(
147147
locale: LocaleConfiguration,
148148
default_timedelta_date: dt.timedelta=dt.timedelta(days=1),
149149
default_timedelta_datetime: dt.timedelta=dt.timedelta(hours=1),
150-
):
150+
) -> Tuple[dt.datetime, dt.datetime]:
151151
"""
152152
convert a string description of a daterange into start and end datetime
153153
@@ -157,7 +157,8 @@ def start_end_from_daterange(
157157
:param locale: locale settings
158158
"""
159159
if not daterange:
160-
start = dt.datetime(*dt.date.today().timetuple()[:3])
160+
today = dt.datetime.now(locale['local_timezone']).date()
161+
start = dt.datetime.combine(today, dt.time.min)
161162
end = start + default_timedelta_date
162163
else:
163164
start, end, allday = parse_datetime.guessrangefstr(

0 commit comments

Comments
 (0)