Skip to content

Fix locale ISO datetime parsing#1471

Open
nkgotcode wants to merge 2 commits into
pimutils:masterfrom
nkgotcode:fix/khal-iso8601-locale-datetime
Open

Fix locale ISO datetime parsing#1471
nkgotcode wants to merge 2 commits into
pimutils:masterfrom
nkgotcode:fix/khal-iso8601-locale-datetime

Conversation

@nkgotcode

Copy link
Copy Markdown

Fixes #1469.

This updates locale datetime parsing so composite locale directives are expanded through locale.nl_langinfo() before parsing. It also accepts the ISO-like %c form produced by locales such as en_DK.utf8 when the formatted value has an empty %Z timezone field.

The regression test covers a locale-provided datetime format of %Y-%m-%dT%T %Z with an input value that omits the timezone name.

Validation:

. .venv-oss1856/bin/activate && py.test tests/parse_datetime_test.py -q
# 54 passed, 14 warnings
. .venv-oss1856/bin/activate
TMPDIR=$(mktemp -d)
mkdir -p "$TMPDIR/calendar" "$TMPDIR/cache"
CONFIG="$TMPDIR/config"
printf '%s\n' '[calendars]' '  [[default]]' "    path = $TMPDIR/calendar" '    color = dark magenta' '' '[locale]' 'local_timezone = Europe/Paris' 'default_timezone = Europe/Paris' '' '[sqlite]' "path = $TMPDIR/cache/khal.db" > "$CONFIG"
env -u LC_ALL LANG=en_US.utf8 LC_TIME=en_DK.utf8 khal -c "$CONFIG" printformats
env -u LC_ALL LANG=en_US.utf8 LC_TIME=en_DK.utf8 khal -c "$CONFIG" at '2026-05-14T12:00:00'
# exit 0; no critical parse error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Khal cannot parse ISO8601 from system default

1 participant