Skip to content

Commit

Permalink
fix default for list and calendar command
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
geier committed Nov 3, 2023
1 parent 25a877f commit 5d2e569
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions khal/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand Down

0 comments on commit 5d2e569

Please sign in to comment.