Issue with date2num
I use timezones intensively, and I had an issue with
date2numon line 209 of
The code refers to an undefined variable
def date2num(dt, tz=None): """ Convert :mod:`datetime` to the Gregorian date as UTC float days, preserving hours, minutes, seconds and microseconds. Return value is a :func:`float`. """ if tz is not None: dt = tz.localize(dwhen) if hasattr(dt, 'tzinfo') and dt.tzinfo is not None: delta = dt.tzinfo.utcoffset(dt) if delta is not None: dt -= delta base = float(dt.toordinal()) if hasattr(dt, 'hour'): # base += (dt.hour / HOURS_PER_DAY + # dt.minute / MINUTES_PER_DAY + # dt.second / SECONDS_PER_DAY + # dt.microsecond / MUSECONDS_PER_DAY # ) base = math.fsum( (base, dt.hour / HOURS_PER_DAY, dt.minute / MINUTES_PER_DAY, dt.second / SECONDS_PER_DAY, dt.microsecond / MUSECONDS_PER_DAY)) return base
My guess is that
dwhenmust be substituted with
Can you show how you use the timezones? Thanks
On timers with
tzdataparameters to trigger timers on market place's timezone.
Our historicals datas are stored into a MongoDB through Arctic library, since ticks and bars are stored UTC, when building a feed I add
tzparameter to point to the proper timezone.
I guess that those uses of timezones pinpointed me to this issue.