-
Notifications
You must be signed in to change notification settings - Fork 263
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
Fixed error in validating date-time #84
base: master
Are you sure you want to change the base?
Conversation
Wherein valid date-time objects with milliseconds (and without trailing literal 'Z') attached were getting bounced. Now RegEx handles previous and other cases.
Updated to incorporate edge cases
This doesn't break any tests that it affects |
Ah date-time the bane of my existence :) |
The ABNF in the RFC doesn't technically allow for any whitespace, but the following paragraph says applications "may" (i.e. not MAY which is formally defined) use a space instead. I have half a mind to write an ABNF-to-Regexp converter right now. (Don't forget about leap seconds, 23:59:60 is a perfectly reasonable, if uncommon, time of day) Is there a valid RFC3339 timestamp that is invalid with the current regex? |
Sure, not a problem.
|
@tdegrunt added tests, formatted for easier reading. |
@ACubed No, I've handled the loosest (including case-insensitive t,z, & allowing for whitespace, & up to 7 digit microseconds). The two additional test cases along with those already present tighten this up quite a great deal. |
…ired':false will allow null values to be consistent with other standards.
I've added support for null values iff it is not required. |
Best to separate the code-style changes from the actual code change .. |
The proposed regex:
fails the following example listed in RFC3339 itself:
Additionally, instances of My hand-crafted regex examining the ABNF looks like:
Which looks rather similar to the current regex. The current one handles arbitrary length fractions of seconds, @mikeangstadt can you provide a specific example date that isn't supported? |
I've added a few tests, if those pass with yours & you like it better lets
|
I've got two tests that fail with your above handcrafted, one mine - one The current version passes all tests, please let me know if you can think Failed tests with above suggested.
milliseconds
On Wed, Aug 6, 2014 at 7:20 AM, Michael Angstadt [email protected]
Mike Angstadt "The noblest pleasure is the joy of understanding" - Leonardo Di Vinci |
Wherein valid date-time objects with milliseconds (and without trailing literal 'Z') attached were getting bounced. Now RegEx handles previous and other cases.