date2num error when converting a DatetimeProlepticGregorian object in cftime 1.0.4
spencerkclark opened this issue · comments
Spencer Clark commented
In version 1.0.3.4 of cftime the following succeeds without an error:
In [1]: import cftime
In [2]: d = cftime.DatetimeProlepticGregorian(1, 1, 1)
In [3]: cftime.date2num(d, 'days since 0001-01-01', 'proleptic_gregorian')
Out[3]: 0.0
However, with 1.0.4, the following occurs:
In [3]: cftime.date2num(d, 'days since 0001-01-01', 'proleptic_gregorian')
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-5b0bfcafe058> in <module>
----> 1 cftime.date2num(d, 'days since 0001-01-01', 'proleptic_gregorian')
cftime/_cftime.pyx in cftime._cftime.date2num()
AttributeError: 'cftime._cftime.DatetimeProlepticGregorian' object has no attribute 'tzinfo'
We came across this in the xarray test suite, xref: pydata/xarray#3427. Was this an intentional change?
Jeff Whitaker commented
Jeff Whitaker commented
Barron H. Henderson commented
I’m at a conference thru tomorrow, so I haven’t been able to look at it. I trust that you’re right. I could look on Thursday.
Jeff Whitaker commented
Will go ahead and merge since the fix is trivial.
Jeff Whitaker commented
F