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

Regex for timezone erroneous #43

Open
mightyCelu opened this issue Oct 10, 2022 · 2 comments
Open

Regex for timezone erroneous #43

mightyCelu opened this issue Oct 10, 2022 · 2 comments

Comments

@mightyCelu
Copy link

Both the regex for XsdTimezoneComponent as well as for the optional variant are erroneous:

((\+\|-)(0[1-9]\|1[0-9]\|2[0-4]):(0[0-9]\|[1-5][0-9])\|Z)

This does not allow for timezones with two leading zeros, e.g. +00:30.

On a similar note, the minute-part of the regex could be simplified from 0[0-9]\|[1-5][0-9] to [0-5][0-9].

@DavidUnderdown
Copy link
Contributor

While half hour timezones do exist, so far as I'm aware neither +00:30 or -00:30 is used (or anything else between +01:00 and -01:00 exclusive) so I'm not sure it is actually erroneous to define in that way. There's possibly a good reason for why the second is written that way too, @adamretter do you have any idea?

@mightyCelu
Copy link
Author

That is true. However, I still think the inconsistency is worth addressing. Which timezones currently exist can change, and it is also conceivable to have data at a time offset that does not correspond to a commonly accepted timezone. This is something the currently specified regex reflects (e.g. +01:42), just not for offsets beginning with 00. Moreover, the offsets +00:00 & -00:00, are also not valid with the current regex. While they are equivalent to Z, I feel it would be arbitrary to forbid these values. In particular, since the referenced data type specification (3.7.2.3) permits these values as well.

All in all I would suggest the following regex:

((\+\|-)((0[0-9]\|1[0-3]):([0-5][0-9])\|14:00)\|Z)

which includes the following changes:

  • allows for offsets 00:00 - 00:59
  • simplifies the subgroup for the minutes
  • reduces the maximum magnitude of the allowed offset to at most fourteen hours (in acordance with the XSD specification)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@DavidUnderdown @mightyCelu and others