-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Closed
Milestone
Description
The behavior of matplotlib.dates.num2date changed between stable versions 1.4.3 and 1.5.
In version 1.5 the implementation of helper function, _from_ordinalf ignores the tz argument and always returns datetimes in UTC.
def _from_ordinalf(x, tz=None):
"""
Convert Gregorian float of the date, preserving hours, minutes,
seconds and microseconds. Return value is a :class:`datetime`.
The input date `x` is a float in ordinal days at UTC, and the output will
be the specified :class:`datetime` object corresponding to that time in
timezone `tz`, or if `tz` is `None`, in the timezone specified in
`rcParams['timezone']`.
"""
if tz is None:
tz = _get_rc_timezone()
ix = int(x)
dt = datetime.datetime.fromordinal(ix).replace(tzinfo=UTC)
remainder = float(x) - ix
# Round down to the nearest microsecond.
dt += datetime.timedelta(microseconds=int(remainder * MUSECONDS_PER_DAY))
# Compensate for rounding errors
if dt.microsecond < 10:
dt = dt.replace(microsecond=0)
elif dt.microsecond > 999990:
dt += datetime.timedelta(microseconds=1e6 - dt.microsecond)
return dtIn version 1.4.3 this is handled correctly.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels