-
Notifications
You must be signed in to change notification settings - Fork 212
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
O3-2476 - isOmrsDateStrict should accept dates with negative timezone… #785
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -50,7 +50,7 @@ export function isOmrsDateStrict(omrsPayloadString: string): boolean { | |||||
} | ||||||
|
||||||
// checking UTC offset format | ||||||
if (!(omrsPayloadString[23] === "+" && omrsPayloadString[26] !== ":")) { | ||||||
if (!(omrsPayloadString[23] === "+" || omrsPayloadString[23] === "-")) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, I don't know what that original There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Zone formats are specified like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should work and be consistent with the code here that verifies all the non-numeric components:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so @ibacher ? Look at all of the test cases for this class, and look at the date string I was originally having an issue with on the ticket. It's in the format: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specifically @ibacher, the isoFormat specified in omrs-dates.js is:
And, per the day.js documentation, "ZZ" is "compact offset from UTC", whereas just "Z" is the offset with the ":". See https://day.js.org/docs/en/parse/string-format. So with our date format, we will get "-0500", not "-05:00". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like ISO considers both including and not including a : as valid (https://en.wikipedia.org/wiki/ISO_8601) I can't remember where, but I do remember some case where we were having an issue with this... ie like an old version of Java only excepted one of the two? Do note @ibacher that it looks like the initial code was testing that a colon was not present, so it was enforcing the "0400" format. I'm fine with removing it.... though see my comment above. Also will flag @brandones @FlorianRappl in case they have any insight. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I misread that! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In any event, removing the check on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I assume there only is such a thing as "omrs ISO format" because, again I assume, the OpenMRS server must use an ISO parser that is not quite correct; perhaps it is more particular about format than the ISO spec. If the OpenMRS server understands any ISO-spec date strings than I don't know why any of those functions exist. I did not implement them, so I don't really know what the motivation was. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @brandones ... this rang a bell and I was actually able to track this down, see bug here: However, this assumedly was resolved years ago? Note that even though @mseaton removed the test for the colon in the timezone, such a string is still considered invaid, I believe/assume because it's 29 characters in length instead of 28, and that is one of the first checks in the validator... fyi @ibacher @mseaton |
||||||
return false; | ||||||
} | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't this fail test case fail without a colon check, or is there something else wrong with this that I'm missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mogoodrich , not sure I follow? This is basically already testing that having the colon is invalid. So according to the tests at least, having
+03:00
is not valid, only+0300
is validThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right... so I guess I'm confused, but I was assuming that if you removed the omrsPayloadString[26] !== ":" the isOmrsDateStrict would return "true" for this (and therefore the test woud fail).