Skip to content

num2date only_use_cftime_datetimes argument not working as expected #165

@mommebutenschoen

Description

@mommebutenschoen

According to the docstring of the num2date function, with the option only_use_cftime_datetimes=False the function should return python datetime instances where possible:

**`only_use_cftime_datetimes`**: if False, python datetime.datetime
objects are returned from num2date where possible; if True dates which
subclass cftime.datetime are returned for all calendars. Default `True`.

However, this doesn't seem to be the case:

In [1]: from cftime import num2date,num2pydate

In [2]: num2date(0,units="seconds since 2000-01-01 00:00:00",only_use_cftime_datetimes=False)
Out[2]: cftime.DatetimeGregorian(2000-01-01 00:00:00)

In [3]: num2pydate(0,units="seconds since 2000-01-01 00:00:00")
Out[3]: datetime.datetime(2000, 1, 1, 0, 0)

cftime version 1.1.1.2
python 3.7.6
Linux 3.10.0-957.el7.x86_64

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