target / theta-idl

Define communication protocols between applications using algebraic data types.
Other
45 stars 9 forks source link

Consistent leap second handling for Time type #61

Closed TikhonJelvis closed 2 years ago

TikhonJelvis commented 2 years ago

The initial implementation of Time did not handle leap seconds consistently across languages. 23:59:60 would work in Haskell but get read as 00:00:00 in Rust and Python.

Since Python's datetime package does not handle leap seconds at all and leap seconds are, in general, a massive headache, I am going to explicitly not support leap seconds in Theta. Theta will never write a leap second to a Time value and it will read Time values with a leap second as 23:59:59.999999.

This PR adds leap-second-handling logic to Haskell, Python and Rust along with tests.

I originally caught the bug when one the cross-language QuickCheck tests failed with a massive input. To help debug this, I moved Test.Assertions from a hidden module in Theta's test suite to Theta.Test.Assertions and wrote a version of assertDiff that only prints the first difference between two values (rather than the whole thing). This made finding the part of the test case that caused the failure a lot easier than needing to deal with the entire input!