-
Notifications
You must be signed in to change notification settings - Fork 730
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
Duration from ISO leading minus #683
Merged
icambron
merged 2 commits into
moment:master
from
jmadelaine:duration-from-iso-leading-minus
Apr 2, 2020
Merged
Duration from ISO leading minus #683
icambron
merged 2 commits into
moment:master
from
jmadelaine:duration-from-iso-leading-minus
Apr 2, 2020
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
icambron
requested changes
Apr 2, 2020
… on negative prefix We check that num is not undefined before negation, as returning NaN from extractISODuration throws an error inside asNumber util function.
jmadelaine
force-pushed
the
duration-from-iso-leading-minus
branch
from
April 2, 2020 20:02
5b12f33
to
66ed38d
Compare
Looks good, thanks! I'll get this released very soon. |
icambron
approved these changes
Apr 2, 2020
Released as 1.23.0 |
vipulnsward
added a commit
to vipulnsward/rails
that referenced
this pull request
Jun 4, 2020
…TS(ex: moment/luxon#683, moment/moment#2408), many do not. For example PG refers to https://www.ietf.org/rfc/rfc3339.txt when converting(Ref: https://www.postgresql.org/docs/current/datatype-datetime.html) According to the ref there is no explicit mention of allowing sign before the parts, which reads as below: Durations: dur-second = 1*DIGIT "S" dur-minute = 1*DIGIT "M" [dur-second] dur-hour = 1*DIGIT "H" [dur-minute] dur-time = "T" (dur-hour / dur-minute / dur-second) dur-day = 1*DIGIT "D" dur-week = 1*DIGIT "W" dur-month = 1*DIGIT "M" [dur-day] dur-year = 1*DIGIT "Y" [dur-month] dur-date = (dur-day / dur-month / dur-year) [dur-time] duration = "P" (dur-date / dur-time / dur-week) We should not attempt to move sign forward in this case.
rafaelfranca
pushed a commit
to rails/rails
that referenced
this pull request
Nov 2, 2020
…TS(ex: moment/luxon#683, moment/moment#2408), many do not. For example PG refers to https://www.ietf.org/rfc/rfc3339.txt when converting(Ref: https://www.postgresql.org/docs/current/datatype-datetime.html) According to the ref there is no explicit mention of allowing sign before the parts, which reads as below: Durations: dur-second = 1*DIGIT "S" dur-minute = 1*DIGIT "M" [dur-second] dur-hour = 1*DIGIT "H" [dur-minute] dur-time = "T" (dur-hour / dur-minute / dur-second) dur-day = 1*DIGIT "D" dur-week = 1*DIGIT "W" dur-month = 1*DIGIT "M" [dur-day] dur-year = 1*DIGIT "Y" [dur-month] dur-date = (dur-day / dur-month / dur-year) [dur-time] duration = "P" (dur-date / dur-time / dur-week) We should not attempt to move sign forward in this case.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes moment/luxon#681.
The issue above links to a similar issue with moment (moment/moment#2408) which was resolved.
Although the ISO 8601 duration format does not mention support for a leading minus, there are many other libraries that support ISO duration parsing in this way.
The assumed rule is that a leading minus sign inverts the sign of all values.
Examples of leading-minus ISO strings and their equivalent non-leading-minus ISO strings:
-P1D == P-1D
-P5Y3M == P-5Y-3M
-P-5Y-3M == P5Y3M
-P-1W1DT13H-23M34S == P1W-1DT-13H23M-34S