Closed carbolymer closed 9 months ago
That's an invalid SystemTime
, systemNanoseconds
should be in the range 0 to 2E9-1.
@AshleyYakeley You're right. Thanks for pointing that out. I've stumbled upon this issue in our test generator:
genUTCTime =
systemToUTCTime <$>
(MkSystemTime <$> Gen.int64 Range.constantBounded
<*> Gen.word32 Range.constantBounded)
which obviously isn't correct, because it generates nanoseconds all the way up to 2^32-1.
I'm wondering if it wouldn't be beneficial here to introduce a smart constructor or a pattern synonym, which would prevent a user from creating invalid SystemTime
values. For example it could clip the value up to 2E9-1. Would it make sense?
Not really. It's rare people want leap seconds in any case, so most of the time they'd want to clip to 1E9-1 instead. Far better to keep it simple.
Take a look at the seconds value: 62.556790486 Reproduced on time 1.9.3.
As a workaround I can use
truncateSystemTimeLeapSecond
which produces a "better" value.