microsoft / vscode-json-languageservice

JSON language service extracted from VSCode to be reused, e.g in the Monaco editor.
Other
261 stars 110 forks source link

"time" format seems to be incorrectly excluding "00:00:00" #218

Closed zynga-jpetersen closed 6 months ago

zynga-jpetersen commented 8 months ago

According https://datatracker.ietf.org/doc/html/rfc3339#section-5.6, the time fraction shouldn't be required:

partial-time    = time-hour ":" time-minute ":" time-second
                     [time-secfrac]

The current time regex can be found at https://github.com/microsoft/vscode-json-languageservice/blob/5692bed6db771d0f8985f89a9ecd9e3bc96cbc00/src/parser/jsonParser.ts#L23

Examples that it will accept is: "00:00:00+00:00" or "00:00:00Z"

But If I'm correct about 00:00:00 being a valid rfc3339 time, then my suggestion is that the regex should instead be:

/^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?((Z|(\+|-)([01][0-9]|2[0-3]):([0-5][0-9])))+$/i

Additional Documentation: Json Schema documentation about the time format

aeschli commented 6 months ago

Looking at https://datatracker.ietf.org/doc/html/rfc3339#section-5.6

 full-time       = partial-time time-offset
 partial-time    = time-hour ":" time-minute ":" time-second [time-secfrac]
 time-offset     = "Z" / time-numoffset

time ends with time-offset which contains a Z.

Let me know why you think 00:00:00 is a valid rfc3339 time,