Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
timedelta formatter#8930
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -457,3 +457,27 @@ def test_DayLocator(): | ||
def test_tz_utc(): | ||
dt = datetime.datetime(1970, 1, 1, tzinfo=mdates.UTC) | ||
dt.tzname() | ||
@pytest.mark.parametrize("x, tdelta", | ||
[(1, datetime.timedelta(days=1)), | ||
([1, 1.5], [datetime.timedelta(days=1), | ||
datetime.timedelta(days=1.5)])]) | ||
def test_num2timedelta(x, tdelta): | ||
dt = mdates.num2timedelta(x) | ||
assert dt == tdelta | ||
@pytest.mark.parametrize('dt, fmt, out', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 How about | ||
[(datetime.timedelta(days=8, hours=1, minutes=2, | ||
seconds=3, microseconds=4), | ||
'{D}d {H:02}:{M:02}:{S:02}.{f:06}', | ||
'8d 01:02:03.000004'), | ||
(datetime.timedelta(seconds=1), '{f}', '1000000'), | ||
(datetime.timedelta(microseconds=1e5), '{S}', '0.1'), | ||
]) | ||
def test_TimedeltaFormatter(dt, fmt, out): | ||
formatter = mdates.TimedeltaFormatter(fmt) | ||
x = mdates.date2num(dt) | ||
formatted = formatter(x) | ||
assert formatted == out |