vc-data-model icon indicating copy to clipboard operation
vc-data-model copied to clipboard

Include a regex for XML Date Time in the next version of the standard.

Open OR13 opened this issue 3 years ago • 10 comments

If we can't agree to relax XML Data Time to the broader category or ISO 8601 date times, we should include a regex that defines the allows string representations, and we should document all known issues with string representations of date times in the spec, so that implementers don't have to guess about "leap seconds" or other time related issues.

OR13 avatar Nov 29 '21 22:11 OR13

The issue was discussed in a meeting on 2021-12-01

  • no resolutions were taken
View the transcript

3.3. Include a regex for XML Date Time in the next version of the standard. (issue vc-data-model#846)

See github issue vc-data-model#846.

Brent Zundel: This seems like it's v2.0, anyone disagree?.

iherman avatar Dec 02 '21 09:12 iherman

Related:

Examples should include leap seconds if they are legal, and the regex MUST recognize valid ISO8601 date time strings that include leap seconds.

For example:

{ 
  "issuanceDate": "2016-12-31T23:59:60Z",  // looses leap second
  "expirationDate": "2038-01-19T03:14:08Z" // integer overflow
}

time

OR13 avatar Dec 03 '21 20:12 OR13

https://github.com/json-schema-org/json-schema-spec/issues/483

OR13 avatar Aug 17 '22 19:08 OR13

something like (\d{4}-\d{2}-\d{2})[A-Z]+(\d{2}:\d{2}:\d{2}).([0-9+-:]+) ?

mprorock avatar Aug 17 '22 19:08 mprorock

possibly useful:

https://github.com/transmute-industries/verifiable-data/blob/43b2dd1f91dc200927bd8c859ece31eae465e4f1/packages/vc.js/src/datetime/datetime.test.ts

https://github.com/transmute-industries/verifiable-data/blob/43b2dd1f91dc200927bd8c859ece31eae465e4f1/packages/vc.js/src/datetime/index.ts

export const RFC_3339 = new RegExp(
  "^([0-9]{4})-([0-9]{2})-([0-9]{2})" +
    "([Tt]([0-9]{2}):([0-9]{2}):([0-9]{2})(.[0-9]+)?)?" +
    "(([Zz]|([+-])([0-9]{2}):([0-9]{2})))?"
);

// Tweaked to allow for leap seconds
export const ISO_8601_FULL = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-6]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;

export const TIME_ZONE_OFFSET_MATCH = /[+-]\d\d:\d\d$/;

OR13 avatar Aug 17 '22 19:08 OR13

possible regex from @mprorock:

mprorock spits (\d{4}-\d{2}-\d{2})[A-Z]+(\d{2}:\d{2}:\d{2}).([0-9+-:]+) out of the magic "i hate regex" scratchpad

brentzundel avatar Aug 17 '22 19:08 brentzundel

and a more brutal, but probably more correct one: ^([0-9]{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$

mprorock avatar Aug 17 '22 19:08 mprorock

Of course, we all know that there are multiple flavors of regex in the world, so we have to declare which one is in play here...

TallTed avatar Aug 17 '22 20:08 TallTed

The issue was discussed in a meeting on 2022-08-17

  • no resolutions were taken
View the transcript

2.3. Include a regex for XML Date Time in the next version of the standard. (issue vc-data-model#846)

See github issue vc-data-model#846.

Orie Steele: found flaws in the v1.0 description of date/times.
… this was fixed in v1.1 DM.
… but need to be clear about which string format is being used.
… so prefer a regex value.

Manu Sporny: we can add this to v2 DM.

Dmitri Zagidulin: +1 to including the RegEx in the spec :) (having had to come up with that same regex for a library...).

Manu Sporny: alternatively we could define an XML schema for date/time and a regex to check if it is correct.

Dmitri Zagidulin: having already implemented this, we will save a lot of time if we add Regex expression to the DMv2.

Gabe Cohen: +1. implementing xsd:dateTime was incredibly painful.

Michael Jones: I added regex to OAuth2 and implementors have found it useful.

Manu Sporny: +1 selfissued, I think that would be fine..

Michael Jones: so I support adding it.

Brent Zundel: we need a volunteer to produce a PR for this? Orie? Dmitry?.

Dmitri Zagidulin: said he would produce the first draft.

iherman avatar Aug 18 '22 05:08 iherman

A slightly different, but related question: do we really want the timezone offset to be optional? Strictly speaking, a dateTime without an explicit timezone is ambiguous.

If it is expected that timezone offset are always provided, then the specified datatype should be xsd:dateTimeStamp rather than xsd:dateTime.

pchampin avatar Sep 09 '22 08:09 pchampin

https://www.w3.org/TR/xmlschema11-2/#dateTime

  • does not support leap seconds.
  • 100% compatible with unix timestamps.

OR13 avatar Oct 13 '22 17:10 OR13

The issue was discussed in a meeting on 2023-01-11

  • no resolutions were taken
View the transcript

3.2. Include a regex for XML Date Time in the next version of the standard. (issue vc-data-model#846)

See github issue vc-data-model#846.

Brent Zundel: Include date and time for the standard..
… No opposition to this proposal..
… Any volunteers to write this?.

Manu Sporny: Terrified to get this wrong. A bug in the scheme. It's possible that the regx could be incorrect..
… There should be timezone in the date and time. We need regx experts to get it right..

Brent Zundel: Any volunteers?.

Ivan Herman: Do we have a decision to use the XSD date and time?.

Manu Sporny: We have gone through three variants. XML schema 1, regx, ....

Ivan Herman: Not asking about regex. Asking for definition about daytime..

Manu Sporny: We have looked into this. We are looking at XML schema for daytime, but it was wrong..
… You have to specify the timezone..
… Times are hard. :-).
… XML schema must specify timezone..

iherman avatar Jan 11 '23 17:01 iherman

The issue was discussed in a meeting on 2023-04-04

  • no resolutions were taken
View the transcript

1.5. Include a regex for XML Date Time in the next version of the standard. (issue vc-data-model#846)

See github issue vc-data-model#846.

Kristina Yasuda: About regex for XML Date Time..

Manu Sporny: I'll take this one.
… We will provide a regex for XML Date Time that exists in the spec, but we will mandate time zone..
… This has come up in implementations..

Ivan Herman: Manu, didn't we have that in the DID spec?.

Manu Sporny: Not sure if we had a regex for this in DID Core. If we did, it needs to be updated to include the time zone..

iherman avatar Apr 04 '23 16:04 iherman

If only this came with a regex

https://ijmacd.github.io/rfc3339-iso8601/

OR13 avatar Apr 27 '23 22:04 OR13

Very supportive of this issue. I've had a hard time finding libraries for xsd:dateTime in go. I end up using RFC3339 everywhere which isn't great. A regex would go a long way towards facilitating interoperability.

decentralgabe avatar Jul 05 '23 18:07 decentralgabe

PR #1183 has been merged to address this issue. Closing.

msporny avatar Jul 15 '23 13:07 msporny