Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dayofyr and dayofwk after cftime.datetime.replace #106

Closed
spencerkclark opened this issue Dec 15, 2018 · 1 comment
Closed

dayofyr and dayofwk after cftime.datetime.replace #106

spencerkclark opened this issue Dec 15, 2018 · 1 comment

Comments

@spencerkclark
Copy link
Collaborator

#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.

jswhit added a commit that referenced this issue Dec 15, 2018
@jswhit
Copy link
Collaborator

jswhit commented Dec 15, 2018

I incorporated your workaround into the replace method. If you can come up with something more elegant, feel free to create an alternative pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants