Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8906f29

Browse files
committed
Allow timedelta to be converted to a ordinalf
1 parent6da2b8c commit8906f29

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

‎lib/matplotlib/dates.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,19 @@ def _get_rc_timezone():
207207

208208
def_to_ordinalf(dt):
209209
"""
210-
Convert :mod:`datetime`or :mod:`date` to the Gregorian date as UTC float
211-
days, preserving hours, minutes, seconds and microseconds. Return value
212-
is a :func:`float`.
210+
Convert :mod:`datetime`, :mod:`date`or :mod:`timedelta` to the Gregorian
211+
date as UTC floatdays, preserving hours, minutes, seconds and
212+
microseconds. Return valueis a :func:`float`.
213213
"""
214214
# Convert to UTC
215215
tzi=getattr(dt,'tzinfo',None)
216216
iftziisnotNone:
217217
dt=dt.astimezone(UTC)
218218
tzi=UTC
219219

220+
ifisinstance(dt,datetime.timedelta):
221+
returndt.total_seconds()/SEC_PER_DAY
222+
220223
base=float(dt.toordinal())
221224

222225
# If it's sufficiently datetime-like, it will have a `date()` method

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp