X Tutup
Skip to content

timedelta formatter#8930

Closed
dstansby wants to merge 3 commits intomatplotlib:masterfrom
dstansby:timedelta-formatter
Closed

timedelta formatter#8930
dstansby wants to merge 3 commits intomatplotlib:masterfrom
dstansby:timedelta-formatter

Conversation

@dstansby
Copy link
Copy Markdown
Member

PR Summary

A new TimedeltaFormatter class for formatting timedelta objects. Unlike datetime objects there's no strftime 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.

@dstansby dstansby force-pushed the timedelta-formatter branch from 70ebfcd to 16d1240 Compare July 24, 2017 17:20
@dstansby dstansby added this to the 2.2 (next next feature release) milestone Aug 1, 2017
@pganssle
Copy link
Copy Markdown
Member

@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',
Copy link
Copy Markdown
Member

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))?

@pganssle
Copy link
Copy Markdown
Member

Is it a bit inconsistent with strftime to use D for days rather than d?

@dstansby dstansby modified the milestones: v2.2, v3.0 Jan 10, 2018
@tacaswell tacaswell modified the milestones: v3.0, v3.1 Jul 7, 2018
@jklymak jklymak modified the milestones: v3.1.0, v3.2.0 Feb 7, 2019
@dstansby
Copy link
Copy Markdown
Member Author

I'm going to close this in favour of dateutil/dateutil#444 - I think doing this upstream in dateutil is the better way to go.

@dstansby dstansby closed this Jul 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

X Tutup