Skip to content

_parse_xsd_datetime and _parse_xsd_time crash on XSD end-of-day midnight (24:00:00) #564

@s-heppner

Description

@s-heppner

Currently, _parse_xsd_datetime() and _parse_xsd_time() in basyx/aas/model/datatypes.py crash with ValueError: hour must be in 0..23 whenever they encounter the XSD end-of-day midnight notation 24:00:00.

Both functions pass the parsed hour integer directly to Python's datetime.datetime / datetime.time constructors, which do not accept values above 23. There is no special-casing for the 24:00:00 form.

However, W3C XSD 1.0 explicitly permits 24:00:00 for both xs:dateTime and xs:time as end-of-day midnight:

  • For xs:dateTime, YYYY-MM-DDT24:00:00 is canonically equivalent to YYYY-MM-(DD+1)T00:00:00
  • For xs:time, 24:00:00 normalizes to 00:00:00. XSD 1.0 requires that when the hour is 24, minutes and seconds must both be 00.

In any case, the AAS schemas allow for hour 24, so we need to allow for it.
I think we should automatically convert this edge case into valid datetime.datetime (which btw follows ISO 8601).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdiscussionIt's not clear yetsdkSomething to do with the `sdk` package

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions