Skip to content

isoparse docstring says an ISO week without a day "defaults to 0", but the day is 1 (Monday) and 0 is rejected #1629

Description

@Upua

Versions tested: python-dateutil 3.0.0 from PyPI (the newest release on 2026-10-22; wheel sha256 3c79630202e4152c6add678446984236efe4f57e84d8e892aab0637bab82e9fd) and the master branch at
10f317fde11ce5bc6540e83f896af10e67d52937 (its head on 2026-10-22; the text of src/dateutil/parser/isoparser.py is identical in the 3.0.0 wheel); CPython 3.11.10 on Linux x86_64.

Reproduce (one command):

python3 -c 'from dateutil.parser import isoparse as p; print(p("2024-W01")); print(p("2024-W01-1")); print(p("2024-W01-0"))'

Expected: the docstring of isoparse (rendered on the "parser" page of the documentation) lists, under "Uncommon" date formats:

YYYY-Www or YYYYWww - ISO week (day defaults to 0)

and says a few lines later that "The ISO week and day numbering follows the same logic as datetime.date.isocalendar". In that numbering the weekday runs from 1 (Monday) to 7 (Sunday), and the next bullet (YYYY-Www-D) takes D in that range. So a reader expects either that the default day is a valid ISO day, or that the text says which day it is.

Observed (the same on 3.0.0 and on master):

2024-01-01 00:00:00
2024-01-01 00:00:00
ValueError: Invalid weekday: 0

The default is ISO day 1 (Monday): YYYY-Www equals YYYY-Www-1, and src/dateutil/parser/isoparser.py has dayno = 1 in _parse_isodate_uncommon (line 269). Day 0 is rejected, by the code (_calculate_weekdate documents "range is [1 (MON), 7 (SUN)]") and by the test suite (('2012-W01-0', ValueError) in tests/test_isoparser.py); test_isoweek expects 2020-W01 to be 2019-12-30, a Monday. The behaviour looks right; the sentence "day defaults to 0" is the part that is wrong, or at best ambiguous (0 would be Monday only in date.weekday() numbering, which this docstring does not use).

Suggested wording, if useful: "ISO week (day defaults to 1, Monday)".

We have not looked for anything beyond the docstring; the code and tests agree with each other.

Found by running isoparse on generated valid ISO 8601 strings against an independent model and reading its documentation claims one by one.

Activity

  1. FullStraing commented on Nov 20, 2026

    @FullStraing

    Opened PR #1681 fixing the docstring — an ISO week without a day defaults to day 1 (Monday).

  2. FullStraing commented on Nov 20, 2026

    @FullStraing

    Opened a PR for this: #1681 — it fixes the isoparse docstring (an ISO week without a day defaults to day 1, Monday, not 0). Changelog fragment added to the PR branch.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions