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

Addition of "conjugate" Duration to TimePoint - order of operations #214

Open
MetRonnie opened this issue Jun 10, 2022 · 0 comments
Open
Labels
Milestone

Comments

@MetRonnie
Copy link
Contributor

MetRonnie commented Jun 10, 2022

From cylc/cylc-flow#4908

When you add a conjugate Duration such as P1M1D to a TimePoint, it seems isodatetime does + P1D + P1M internally, which I think is confusing.

This can be argued either way (I don't think ISO 8601 specifies what order is supposed to happen), but I think the order should be as is written from left to right, i.e. + P1M + P1D.

Why does the order matter, you ask? For nominal (inexact) units, addition is not associative:

>>> 2021-02-28 + P1M + P1D
2021-03-29
>>> 2021-02-28 + P1D + P1M
2021-04-01
>>> 2021-02-28 + P1M1D
2021-04-01

(I've used shorthand to represent the metomi.isodatetime.data objects)

The other side of the argument is that we should stick with the existing behaviour to avoid a breaking, possibly-painful change.

Note: If users want the addition to take place in a specific order, they should use separate Duration objects and add them to the TimePoint object in the desired order, not add Duration objects together.

@MetRonnie MetRonnie added this to the 4.0.0 milestone Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant