Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Regex for xs:dateTime does not properly support timezones #498

Open
mjacoby opened this issue Dec 11, 2024 · 5 comments
Open

[BUG] Regex for xs:dateTime does not properly support timezones #498

mjacoby opened this issue Dec 11, 2024 · 5 comments
Assignees
Labels
accepted accepted as proposed documentation Improvements or additions to documentation requires workstream approval strategic decision proposal needs to be prepared in TF spec team
Milestone

Comments

@mjacoby
Copy link

mjacoby commented Dec 11, 2024

Describe the bug
The regex for values of type xs:dateType

^-?(([1-9][0-9][0-9][0-9]+)|(0[0-9][0-9][0-9]))-((0[1-9])|(1[0-2]))-((0[1-9])|([12][0-9])|(3[01]))T(((([01][0-9])|(2[0-3])):[0-5][0-9]:([0-5][0-9])(\\.[0-9]+)?)|24:00:00(\\.0+)?)(Z|\\+00:00|-00:00)

does only allow Z, +00:00, or -00:00 as timezones.
Correct behavior would be to allow Z or any other timezone of format (+|-)[0-9]{2}:[0-9]{2}.

Where

  • "pattern": "^-?(([1-9][0-9][0-9][0-9]+)|(0[0-9][0-9][0-9]))-((0[1-9])|(1[0-2]))-((0[1-9])|([12][0-9])|(3[01]))T(((([01][0-9])|(2[0-3])):[0-5][0-9]:([0-5][0-9])(\\.[0-9]+)?)|24:00:00(\\.0+)?)(Z|\\+00:00|-00:00)$"
  • "pattern": "^-?(([1-9][0-9][0-9][0-9]+)|(0[0-9][0-9][0-9]))-((0[1-9])|(1[0-2]))-((0[1-9])|([12][0-9])|(3[01]))T(((([01][0-9])|(2[0-3])):[0-5][0-9]:([0-5][0-9])(\\.[0-9]+)?)|24:00:00(\\.0+)?)(Z|\\+00:00|-00:00)$"

Additional context
https://www.w3.org/TR/xmlschema-2/#dateTime Section 3.2.7.3

@mjacoby
Copy link
Author

mjacoby commented Dec 13, 2024

This is actually more complex as I described in aas-core-works/aas-core-meta#355 (comment)

Copying my response from there

The specification says the following for basicEventElement.lastUpdate

image

The issue here is that the Type is dateTime which is defined as xs:dateTime, meaning it can have any timezone. However, the explanation column states that the timestamp should/must(?) be in UTC. Based on that you introduced a new "type" Date_time_UTC. I would argue that the specification is wrong or at least inconsistent as the type information is constrained by the explanation to an undefined type "dateTimeUTC". The correct way to handle this would be to change the specification to either defined the type dateTimeUTC or to remove the UTC restriction in the explanation.

@s-heppner
Copy link
Collaborator

I imagine to remember that there was once a decision that the timestamps must all be defined in UTC, but maybe @BirgitBoss could clarify this?

@BirgitBoss
Copy link
Collaborator

BirgitBoss commented Feb 19, 2025

So far the type "timestamp" is only used in the experimental Event. For me the specification is clear: UTC is required. The specification is not wrong.

Of course it can be improved by introducing a new data type dateTimeUtc. The naming would hinder to include other time zones later. A more generic name would be eventTime but this is probably too specific.

if the schemas are already supporting UTC only, then I consider this to be a backward compatible change and an improvement of the documentation only.

@s-heppner what about xml and rdf?

@BirgitBoss BirgitBoss added documentation Improvements or additions to documentation accepted accepted as proposed and removed bug Something isn't working Schemas generated schemata for xml, JSON and rdf or XMI JSON impact on JSON only labels Feb 19, 2025
@BirgitBoss BirgitBoss added this to the V3.1 milestone Feb 19, 2025
@mjacoby
Copy link
Author

mjacoby commented Feb 20, 2025

@BirgitBoss Although you are right that in the meta model classes dateTime is only used for events but it can also be used as a type for values of e.g. Property or Range which is far more important and relevant.
For me, this is not a minor issue but an important issue or even flaw/bug in the AAS type system.

Right now, the definition of dateTime as an AAS type references xs:dateTime which clearly allows time zones. However, the regex defined by AAS for that type does not allow time zones. This is inconsistent.

Additionally, the description of BasicEventElement.lastUpdate says "UTC only" while to type used does allow time zones.

So my proposal is to strictly follow xs:dateTime and allow time zones as removing time zones can lead to a loss of information (there is a reason why basically all standards are still using time zones and not simply UTC).

@BirgitBoss
Copy link
Collaborator

BirgitBoss commented Feb 24, 2025

As far as I see the schemas do not provide regEx for the enumeration values in DataTypeDefXsd only for the elements within the Metamodel lastUpdate and timeStamp.

In aas-core we have https://aas-core-works.github.io/aas-core-meta/v3_1/MatchesXsDateTimeUtc.html and https://aas-core-works.github.io/aas-core-meta/v3_1/MatchesXsDateTime.html: so everything should be fine, no?

For changing the UTC restriction for these two Event attributes please add a separate issue. Thank you!

@BirgitBoss BirgitBoss added the requires workstream approval strategic decision proposal needs to be prepared in TF spec team label Feb 24, 2025
BirgitBoss added a commit that referenced this issue Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted accepted as proposed documentation Improvements or additions to documentation requires workstream approval strategic decision proposal needs to be prepared in TF spec team
Projects
None yet
Development

No branches or pull requests

3 participants