Skip to content

cftime date2num not working after 15/10/1582.  #258

Closed

Description

I am using cftime 1.5.1.1 in python 3.8.10 on ubuntu 20.04.

I am trying to change the unit in cftime.date2num from "days since 0001-12-31" to "seconds since 1970-01-01"

The error I am encountering is;

Traceback (most recent call last):
File "/home/egoss/Documents/data_processing/mita-teknik/main.py", line 136, in
daily_dataframe = Txt.input_txt(day[0][1], zipObj)
File "/home/egoss/Documents/data_processing/mita-teknik/Txt_folder.py", line 229, in input_txt
df[set_header[0]] = cftime.date2num(df[set_header[0]], "seconds since 1970-01-01 00:00:00.000", calendar="standard")
File "src/cftime/_cftime.pyx", line 270, in cftime._cftime.date2num
File "/home/egoss/.local/lib/python3.8/site-packages/pendulum/period.py", line 340, in mod
return self.as_interval().mod(other)
File "/home/egoss/.local/lib/python3.8/site-packages/pendulum/duration.py", line 403, in mod
r = self._to_microseconds() % other._to_microseconds()
AttributeError: 'datetime.timedelta' object has no attribute '_to_microseconds'

I have noticed that line 229 does not have any issues if I use a date up to and including 1582-10-15 (the date of the gregorian calendar change.) Any date after this does not work.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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