Skip to content

dayofyr and dayofwk after cftime.datetime.replace #106

@spencerkclark

Description

@spencerkclark

#66 enabled working dayofyr and dayofwk attributes for all cftime dates constructed manually, which is great!

I've noticed that if one constructs datetime objects using replace, that the dayofyr and dayofwk attributes are not automatically updated:

In [21]: date = cftime.DatetimeNoLeap(1, 2, 1)

In [22]: date.dayofyr
Out[22]: 32

In [23]: date.replace(year=2, month=5).dayofyr
Out[23]: 32

A workaround is to specify dayofwk=-1 within replace:

In [24]: date.replace(year=2, month=5, dayofwk=-1).dayofyr
Out[24]: 121

Is this intentional? Should we not pass down the old dayofyr and dayofwk attributes to the new date object in replace? I'm happy to provide a PR to change this behavior, if desired.

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