cylc-flow icon indicating copy to clipboard operation
cylc-flow copied to clipboard

`next()` can return a datetime that is in the past

Open MetRonnie opened this issue 2 years ago • 4 comments

>>> now = 2020-10-19T13:53Z
>>> next(--10-19)
2020-10-19T00:00Z

is a https://github.com/cylc/cylc-flow/labels/bug because it returns a datetime that is in the past!

It should be

2021-10-19T00:00Z  # next year

Similarly (but less severe), previous() goes back too far

>>> previous(--10-19)
2019-10-19T00:00Z

when it should be

2020-10-19T00:00Z

because just as T00 is short for T0000 and 01 is short for 01T0000, --10-19 is short for --10-19T0000.

I.E. matching date-time components should not be a special case.

Note this is somewhat of a breaking change, so tagged against next minor version rather than maintenance version.

Originally posted by @MetRonnie in https://github.com/cylc/cylc-flow/issues/5777#issuecomment-1772521629

MetRonnie avatar Oct 27 '23 14:10 MetRonnie

We may fix this in https://github.com/metomi/isodatetime/pull/234

MetRonnie avatar Oct 27 '23 15:10 MetRonnie

To close this issue, these tests should be fixed:

https://github.com/cylc/cylc-flow/blob/238ce2890c4ccb2ecc576a5c79902fb2e8a22cba/tests/unit/cycling/test_iso8601.py#L688

https://github.com/cylc/cylc-flow/blob/238ce2890c4ccb2ecc576a5c79902fb2e8a22cba/tests/unit/cycling/test_iso8601.py#L712

oliver-sanders avatar Nov 02 '23 11:11 oliver-sanders

@MetRonnie - bumping this back to 8.4 for now as it seems to have stagnated for a bit.

hjoliver avatar Mar 14 '24 03:03 hjoliver

:+1: The fix is ready but has not been a priority for review

MetRonnie avatar Mar 14 '24 10:03 MetRonnie