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

Skip to content

Commit 9f66ae2

Browse files
committed
Didn't realize that _to_ordinalf needs to support datetime.date objects.
Signed-off-by: Paul G <[email protected]>
1 parent ba623a7 commit 9f66ae2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/matplotlib/dates.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,14 @@ def _get_rc_timezone():
205205

206206
def _to_ordinalf(dt):
207207
"""
208-
Convert :mod:`datetime` to the Gregorian date as UTC float days,
209-
preserving hours, minutes, seconds and microseconds. Return value
208+
Convert :mod:`datetime` or :mod:`date` to the Gregorian date as UTC float
209+
days, preserving hours, minutes, seconds and microseconds. Return value
210210
is a :func:`float`.
211211
"""
212212

213+
if isinstance(dt, datetime.date):
214+
return float(datetime.datetime.toordinal(dt))
215+
213216
if hasattr(dt, 'tzinfo') and dt.tzinfo is not None:
214217
delta = dt.tzinfo.utcoffset(dt)
215218
if delta is not None:

0 commit comments

Comments
 (0)