Skip to content

sdk: Allow 4+ digit year in xs:dateTime - #617

Open
hpoeche wants to merge 4 commits into
eclipse-basyx:developfrom
rwth-iat:fix/long-year
Open

sdk: Allow 4+ digit year in xs:dateTime#617
hpoeche wants to merge 4 commits into
eclipse-basyx:developfrom
rwth-iat:fix/long-year

Conversation

@hpoeche

@hpoeche hpoeche commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Previously, the deserialization required values in formats xs:dateTime and xs:date to consists of exactly four digits for the year. However, the XML Schema 1.0, which is defined as reference, allow for more digits if the leading digit is non-zero.

These changes adapt the regex used for deserialization of both datatypes to also allow more than four digits for year numbers if no leading zeros are used. If only four digits are used, leading zeros are still allowed.

Fixes #616

Previously, the deserialization required values in formates
`xs:dateTime` and `xs:date` to consists of exactly four digits for
the year. However, the XML Schema 1.0, which is defined as reference,
allow for more digits if the leading digit is non-zero.

These changes adapt the regex used for deserialization of both datatypes
to also allow more than four digits for year numbers if no leading
zeros are used. If only four digits are uesd, leading zeros are still
allowed.

Fixes eclipse-basyx#616
@s-heppner

Copy link
Copy Markdown
Member

What happens, if you try to cast such a year this into Python's datetime?
Can you add test cases for the 4+ digit years?

Similar to handling of negative dates in eclipse-basyx#586
The `GYear` and `GYearMonth` lexical representation follows the
one of the year part of `xs:dateTime`. Therefore the regex needs
to be changed to prohibit leading zeros for 4+ digit year.

The error handling in the `into_date()` method of both classes
for years that exceed Python's `datetime.MAXYEAR` is similar to
the one for negative dates (introduced in eclipse-basyx#586).
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.

2 participants