-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
timedelta formatter #8930
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
timedelta formatter #8930
Conversation
Fix whitespace
70ebfcd
to
16d1240
Compare
@dstansby Did you base this formatting mini-language on anything? I'd like to implement something similar in dateutil/dateutil#444, but I'm not aware of any standard way to do it. |
assert dt == tdelta | ||
|
||
|
||
@pytest.mark.parametrize('dt, fmt, out', |
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.
I think you'd probably want a lot more tests. What happens for a negative timedelta
?
How about ('{H:02}:{M:02}', timedelta(days=4, hours=0, minutes=0, seconds=4))
?
Is it a bit inconsistent with |
I'm going to close this in favour of dateutil/dateutil#444 - I think doing this upstream in |
PR Summary
A new
TimedeltaFormatter
class for formattingtimedelta
objects. Unlikedatetime
objects there's nostrftime
method, so I've had to roll my own version. The docstring examples and tests I've added should make it clear how it works.This depends on PR #8730. See #8869 for tracker issue for plotting
timedelta
objects.