Skip to content

date2num error when converting a DatetimeProlepticGregorian object in cftime 1.0.4 #126

@spencerkclark

Description

@spencerkclark

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions