Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3a5683b

Browse files
committed
FIX: translate timedeltas in _to_ordinalf
1 parent 63fe909 commit 3a5683b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/matplotlib/dates.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ def _to_ordinalf(dt):
222222
dt = dt.astimezone(UTC)
223223
tzi = UTC
224224

225+
if isinstance(dt, datetime.timedelta):
226+
base = dt / datetime.timedelta(days=1)
227+
return base
228+
225229
base = float(dt.toordinal())
226230

227231
# If it's sufficiently datetime-like, it will have a `date()` method
@@ -405,6 +409,7 @@ def date2num(d):
405409
Gregorian calendar is assumed; this is not universal practice.
406410
For details see the module docstring.
407411
"""
412+
408413
if hasattr(d, "values"):
409414
# this unpacks pandas series or dataframes...
410415
d = d.values

0 commit comments

Comments
 (0)