shexSpec / shex

ShEx language issues, including new features for e.g. ShEx2.1
24 stars 8 forks source link

Add support for min/max-inclusive exclusive for dates #119

Open labra opened 2 years ago

ericprud commented 2 years ago

It would be nice to include a surface syntax for dates/times as as well.

[13t] literal ::= rdfLiteral | numericLiteral | booleanLiteral | DATETIME | DATE | TIME

XSD Appendicx D covers the rules:

[[ C -- represents a digit used in the thousands and hundreds components, the "century" component, of the time element "year". Legal values are from 0 to 9. Y -- represents a digit used in the tens and units components of the time element "year". Legal values are from 0 to 9. M -- represents a digit used in the time element "month". The two digits in a MM format can have values from 1 to 12. D -- represents a digit used in the time element "day". The two digits in a DD format can have values from 1 to 28 if the month value equals 2, 1 to 29 if the month value equals 2 and the year is a leap year, 1 to 30 if the month value equals 4, 6, 9 or 11, and 1 to 31 if the month value equals 1, 3, 5, 7, 8, 10 or 12. h -- represents a digit used in the time element "hour". The two digits in a hh format can have values from 0 to 24. If the value of the hour element is 24 then the values of the minutes element and the seconds element must be 00 and 00. m -- represents a digit used in the time element "minute". The two digits in a mm format can have values from 0 to 59. s -- represents a digit used in the time element "second". The two digits in a ss format can have values from 0 to 60. In the formats described in this specification the whole number of seconds ·may· be followed by decimal seconds to an arbitrary level of precision. This is represented in the picture by "ss.sss". A value of 60 or more is allowed only in the case of leap seconds. ]]

but I haven't found the pattern for dateTime. I found a related SO with no apparent authoritative refs.

I think I punted on this in my own code before and used [+-]?\d{4}-[01]\d-[0-3]\dT[0-5]\d:[0-5]\d:[0-5]\d(\.\d+)?([+-][0-2]\d:[0-5]\d|Z)? (see shex.js validator).