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 method is not correctly parsing string passed with a positive sign #4002
Comments
This seems like a bug, yeah. If we accept -, then we should accept +. Pull request wanted. |
@kshitijb from the docs, it seems
is referring to the ISO 8601 format (you're using the ASP.NET time spans). As for the solution of this bug, it seems like patching the aspNetRegex from var aspNetRegex = /^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/; to var aspNetRegex = /^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/; solves it, but I don't know enough about this to be sure. |
@mathcavalieri Actually it doesn't. @icambron I have created a PR - #4007 PS - I have tested it locally and it is giving the expected results. |
PR #4007 has been merged and fixed this; this issue can be closed. |
Description
I am trying to add or subtract a duration from UTC 0000 hours. I am using
duration
method to create a duration and then passing that into theadd
method. The documentation mentions that support of mixed negative and positive sign was added in V 2.13.0. But using a positive sign is returning0
. The code is available in this fiddle - https://jsfiddle.net/kshitij/9jqvfk3g/Code Snippet
I have tested this on my machine as well as jsfiddle. I had created an issue on StackOverflow for this but didn't get a satisfactory answer, so posting it here https://stackoverflow.com/questions/44430239/momentjs-duration-is-not-parsing-positive-sign-correctly?noredirect=1#comment75871221_44430239
The text was updated successfully, but these errors were encountered: