-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
string representation of a timedelta objects cannot be read by time class #135176
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
Comments
Seems sensible. Do you wish to a PR? Comparing the 2 |
I've no experience doing a PR, so I would prefer someone else does it. |
Changing |
This will require changing the C implementation too I'm afraid. @vstinner That issue has also had quite a lot of extensive discussion before: |
>>> str(timedelta(seconds=1000000))
'11 days, 13:46:40' As for adding methods to convert the string representation back to |
Uh oh!
There was an error while loading. Please reload this page.
Feature or enhancement
Proposal:
The
__str__
method of thedatetime.timediff
class returns a string representation of a time difference in days, hours, minutes, seconds, microseconds. The representation of minutes and seconds is with a leading zero, which is fine. But the hours is not with a leading zero.Example:
The problem is now that the method
fromisoformat
of thedatetime.time
class does not recognize this string as a valid iso-format string because of the missing leading zero:adding a leading zero works:
interestingly the
__str__
method of time has a leading zero for the hours.So the
__str__
method oftimedelta
shall add a leading zero as well to be conform to the ISO format.Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
The text was updated successfully, but these errors were encountered: