-
-
Notifications
You must be signed in to change notification settings - Fork 397
Add Duration.to_iso8601_string() #314
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
base: master
Are you sure you want to change the base?
Conversation
Still some work in progress:
I have yet to find any info on whether the standard allows for durations like Haven't purchased the standard, so not sure if present in the full standard. |
Not too sure what's happening with the failing tests. I'll have a look at it in a bit, but am not too familiar with pypy or python 2.7, so would appreciate any thoughts. |
Turns out the bug was caused by round returning a float instead of an int in python2, so |
Add relevant tests. Skip test that can't succed with current duration implementation. Fixed bug caused by microseconds being stored as floats on python2. Update CHANGELOG.
e69aeb5
to
b399d0f
Compare
@sdispater I'm still not sure how/if negative durations should be handled, but this should otherwise be good to go. I.e. Would "P1M-1D" or "-P5D" be valid ISO8601 duration strings? I don't have the full standard, but what I've seen doesn't mention whether negative durations or duration components are possible. Looks like Moment.js has encountered similar: How should I proceed? Happy to add support for negative durations if you'd like. |
Hi @sdispater, I would appreciate your thoughts if you have a chance. |
Have been looking for this. Would be very useful. |
I've also stumbled upon this as a nice-to-have feature |
I just bumped into this, would really appreciate it getting merged soon! If there's any help I can add, testing/debugging etc. please shout. |
Thanks from the bumps, just waiting on some input from @sdispater or another authority on how negative durations should be handled. |
Nice work! Would love to have this feature available! |
is this going to be released? |
I'm still waiting on a response and some input from @sdispater |
Any update on this? |
Not from my end 🙂 |
Would also love to see this. It sounds like there isn't work needed other than decision on negative timestamps? @sdispater is this under consideration? |
this fails assert pendulum.parse(pendulum.parse("P1Y").to_iso8601_string()) == pendulum.parse("1Y") it gives
|
Add a
Duration.to_iso8601_string()
method to output a standalone duration as an ISO8601 string.Fixes #306