-
Notifications
You must be signed in to change notification settings - Fork 20
Fix truncated timepoint addition bug #234
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
Conversation
Note this does not fix cylc/cylc-flow#2382, presumably that is still a bug in cylc-flow |
Actually which should the behaviour be?
|
681b125
to
2833ad2
Compare
This comment was marked as outdated.
This comment was marked as outdated.
I think we have to maintain the current behaviour to avoid breaking (Technically we could change the behaviour here and add a workaround in Cylc, but that's more effort) |
Decision on The behaviour is to be:
This is because a truncated datetime should assume 0 for any unspecified time units, and 1 for any unspecified date units lower than what has been specified. |
fb0a2f0
to
2f75c13
Compare
02d8e73
to
6d6b7ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable, code looks good and looks like it fixes the bug. Is it worth filling the gaps in the coverage whilst you're at it. I think it is.
7e4b9b7
to
96e7f06
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I failed to approve sooner. Please get a second reviewer or merge as you think appropriate.
No worries, this has not been a top priority at the moment |
@oliver-sanders Poke (I just spent half a day investigating a bug with Cylc |
Sorry, this hasn't made the priority list. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm happy with the new method, makes sense, very thorough.
There's a disparity in how input types are handled in a lot of these methods when if not isinstance(self, X): raise NotImplementedError
is used. Some specify the one valid type, others pick the looser object
(the latter is technically correct and more compatible with inheritance, although we probably wouldn't have written it that way if starting anew).
def seconds_since_unix_epoch(self) -> int: | ||
reference_timepoint = TimePoint( | ||
**CALENDAR.UNIX_EPOCH_DATE_TIME_REFERENCE_PROPERTIES) | ||
days, seconds = (self - reference_timepoint).get_days_and_seconds() | ||
# N.B. This needs altering if we implement leap seconds. | ||
return str(int(CALENDAR.SECONDS_IN_DAY * days + seconds)) | ||
return int(CALENDAR.SECONDS_IN_DAY * days + seconds) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which is why it is listed as such in the changelog
Testing this out with cylc-flow. Have found one Cylc unit test that fails with this branch:
Should check whether this change is correct. Otherwise, all good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz squash merge.
68b9a4f
to
dfe5495
Compare
(Latest force push only affects changelog as per review request) (Edit: argh, accidentally pressed normal merge instead of squash, oh well) |
Closes #80
Closes #212
Built on #203