-
Notifications
You must be signed in to change notification settings - Fork 543
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
Json round-tripping changes leap seconds #944
Comments
Changing the We can discuss TAI in the linked issue. I think we'll have to accept that JSON serialization of non-TAI time is lossy. |
Hmm… maybe |
If you are going to try to encode leap seconds at all, and print it in this (without-date) ISO8601-like format, you should print the leap second as De facto the peer probably won't cope unless the protocol spec (that imported JSON) explicitly says that leap seconds must be supported. I think the call |
Certainly, leap seconds always appear at the end of a minute, in any timezone. So when passing |
@ijackson if this API is ill-advised, what would you propose instead? I agree that it might make sense to reject Maybe we should reject serializing a leap second unless through a particular opt-in API? |
I think it's probably too late to rework this particular bit of the API now. My suggestion would be to document the semantics more explicitly, and in particular to document explicitly the restriction that leap seconds are only allowed at the end of a whole minute.
I don't see a compelling reason not to serialise it to An alternative would be to rip out leap seconds support altogether but that doesn't seem like a very good option at this stage. |
I think changing the API is related to #21. The API would ideally need to change whatever is decided for 0.5, but will be dependent on the choice there (whether chrono should focus on having second-exact durations or second-exact naive-times without support from the os, basically). TBH I can't see better behavior than current for json round-tripping with the current API: it's afaict already encoding as :60 and decoding properly. The problem is really just for ill-formed leap seconds (in the middle of a minute). I think it makes sense for json round-tripping to not keep that information right, as the leap second was ill-formed in the first place. So this just leaves the debug representation. Maybe having |
I mean, we could instead make |
It doesn't need to panic. It can just return
|
Ahh yeah, sorry. |
We have a couple of issues about leap seconds. I would like to make this one about the ability of types to represent leap seconds, and leave the clock source and the ability to do calculations involving leap seconds to other issues. I am just writing down some of my thoughts on the issue here. Chrono defines a point in time with components: types such as Offset from UTC In order to work with historical values Leap seconds Because by 1972 the offset from UTC is everywhere specified to be a round number of minutes, everyone can use ":60" to designate the extra second. It does not have to happen within the 59th minute however. In Nepal the offset in 1972 was +05:30, so the first leap second was at 1972-07-01 5:29:60. And when the offset was changed to +05:45 in 1986 the next leap second occured on 1988-01-01 5:44:60 (let's hope I got the numbers right). So there are ca. 26 years between the first leap second, and when the last offset from UTC was in use that did not have a round number of minutes, and could mess up the ":60" designation. Components What should happen if you have a Make it harder to create invalid leap seconds We can change We should also adjust the Change |
Closing this issue. #1283 changed almost all methods to no longer allow creating a leap second that is not on a minute boundary. In can still be created from an existing value by using a I don't think we should change the
#954 is for further discussion of the leap-second support in chrono. |
The following code triggers the second
assert_eq!
with a confusing error message:(playground)
This issue was again found by my fuzzer… and TBH I would have rather not had to care 😅
My thoughts are:
00:00:00+1.500
? Or00:00:00(leap).500
?What do you think?
The text was updated successfully, but these errors were encountered: