Skip to content

Cannot parse 2026-W36-1 specifically #916

@AetherUnbound

Description

@AetherUnbound
  • I am on the latest Pendulum version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • OS version and name: OSX 15.6.1 (also seeing this on a Debian docker image)
  • Pendulum version: 3.0.0

Issue

Pendulum appears unable to parse 2026W36, or specifically 2026-W36-1 of the ISO 8601 spec. Here's some examples:

>>> import pendulum
>>> from pendulum import DateTime, Timezone
>>> pendulum.parse("2026W36", strict=False)
Traceback (most recent call last):
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parsing/__init__.py", line 128, in _parse
    dt = parser.parse(
         ^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/dateutil/parser/_parser.py", line 1368, in parse
    return DEFAULTPARSER.parse(timestr, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/dateutil/parser/_parser.py", line 643, in parse
    raise ParserError("Unknown string format: %s", timestr)
dateutil.parser._parser.ParserError: Unknown string format: 2026W36

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parser.py", line 30, in parse
    return _parse(text, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parser.py", line 43, in _parse
    parsed = base_parse(text, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parsing/__init__.py", line 78, in parse
    return _normalize(_parse(text, **_options), **_options)
                      ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parsing/__init__.py", line 132, in _parse
    raise ParserError(f"Invalid date string: {text}")
pendulum.parsing.exceptions.ParserError: Invalid date string: 2026W36
# Previous year works just fine
>>> pendulum.parse("2025W36", strict=False)
DateTime(2025, 9, 1, 0, 0, 0, tzinfo=Timezone('UTC'))
# Other dates in same year work
>>> pendulum.parse("2026W01", strict=False)
DateTime(2025, 12, 29, 0, 0, 0, tzinfo=Timezone('UTC'))
>>> pendulum.parse("2026W02", strict=False)
DateTime(2026, 1, 5, 0, 0, 0, tzinfo=Timezone('UTC'))
# Week prior and week after work
>>> pendulum.parse("2026W35", strict=False)
DateTime(2026, 8, 24, 0, 0, 0, tzinfo=Timezone('UTC'))
>>> pendulum.parse("2026W37", strict=False)
DateTime(2026, 9, 7, 0, 0, 0, tzinfo=Timezone('UTC'))
# Using the day declaration fails multiple ways
>>> pendulum.parse("2025W36-1", strict=False)
Traceback (most recent call last):
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parsing/__init__.py", line 128, in _parse
    dt = parser.parse(
         ^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/dateutil/parser/_parser.py", line 1368, in parse
    return DEFAULTPARSER.parse(timestr, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/dateutil/parser/_parser.py", line 643, in parse
    raise ParserError("Unknown string format: %s", timestr)
dateutil.parser._parser.ParserError: Unknown string format: 2025W36-1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parser.py", line 30, in parse
    return _parse(text, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parser.py", line 43, in _parse
    parsed = base_parse(text, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parsing/__init__.py", line 78, in parse
    return _normalize(_parse(text, **_options), **_options)
                      ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parsing/__init__.py", line 132, in _parse
    raise ParserError(f"Invalid date string: {text}")
pendulum.parsing.exceptions.ParserError: Invalid date string: 2025W36-1
>>> pendulum.parse("2026-W36-1", strict=False)
Traceback (most recent call last):
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parsing/__init__.py", line 128, in _parse
    dt = parser.parse(
         ^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/dateutil/parser/_parser.py", line 1368, in parse
    return DEFAULTPARSER.parse(timestr, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/dateutil/parser/_parser.py", line 643, in parse
    raise ParserError("Unknown string format: %s", timestr)
dateutil.parser._parser.ParserError: Unknown string format: 2026-W36-1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parser.py", line 30, in parse
    return _parse(text, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parser.py", line 43, in _parse
    parsed = base_parse(text, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parsing/__init__.py", line 78, in parse
    return _normalize(_parse(text, **_options), **_options)
                      ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parsing/__init__.py", line 132, in _parse
    raise ParserError(f"Invalid date string: {text}")
pendulum.parsing.exceptions.ParserError: Invalid date string: 2026-W36-1
>>> pendulum.parse("2026-W36", strict=False)
Traceback (most recent call last):
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parsing/__init__.py", line 128, in _parse
    dt = parser.parse(
         ^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/dateutil/parser/_parser.py", line 1368, in parse
    return DEFAULTPARSER.parse(timestr, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/dateutil/parser/_parser.py", line 643, in parse
    raise ParserError("Unknown string format: %s", timestr)
dateutil.parser._parser.ParserError: Unknown string format: 2026-W36

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parser.py", line 30, in parse
    return _parse(text, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parser.py", line 43, in _parse
    parsed = base_parse(text, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parsing/__init__.py", line 78, in parse
    return _normalize(_parse(text, **_options), **_options)
                      ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aether/git/airflow/etl/.venv/lib/python3.12/site-packages/pendulum/parsing/__init__.py", line 132, in _parse
    raise ParserError(f"Invalid date string: {text}")
pendulum.parsing.exceptions.ParserError: Invalid date string: 2026-W36
# Confirmation that day declaration works in general
>>> pendulum.parse("2025-W36-1", strict=False)
DateTime(2025, 9, 1, 0, 0, 0, tzinfo=Timezone('UTC'))
>>> pendulum.parse("2026-W01-1", strict=False)
DateTime(2025, 12, 29, 0, 0, 0, tzinfo=Timezone('UTC'))
# Week prior works
>>> pendulum.parse("2026-W37-1", strict=False)
DateTime(2026, 9, 7, 0, 0, 0, tzinfo=Timezone('UTC'))
# Day after and day before work
>>> pendulum.parse("2026-W36-2", strict=False)
DateTime(2026, 9, 1, 0, 0, 0, tzinfo=Timezone('UTC'))
>>> pendulum.parse("2026-W35-7", strict=False)
DateTime(2026, 8, 30, 0, 0, 0, tzinfo=Timezone('UTC'))
# Date can be constructed on its own just fine
>>> DateTime(2026, 8, 31, 0, 0, 0, tzinfo=Timezone('UTC'))
DateTime(2026, 8, 31, 0, 0, 0, tzinfo=Timezone('UTC'))

I'm really not sure what's going on here! This should ostensibly be working and 2026-08-31 should be a valid date 😅 Any pointers here would be wonderful!

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions