On 10/21/2015 03:27 PM, Alexander Belopolsky wrote:
I just wanted to share a slide https://docs.google.com/presentation/d/1H1tkvg_vm39jXPZbOvQLoWb32POSpTYiZx8qMtBvdSQ/pub?start=false&loop=false&delayms=3000&slide=id.gdfc9fbb2b_0_74 [1] I came across that is very similar to the sketches in PEP 495. Does anyone understand how CCTZ handles the discontinuities?
It provides two APIs, MakeTime and MakeTimeInfo, which both accept a "naive datetime" and a timezone. MakeTime returns an absolute time, and discontinuities are handled by always assuming the pre-transition offset: https://github.com/google/cctz/blob/master/src/cctz.h#L131 MakeTimeInfo returns a more complex TimeInfo struct which has a `kind` enum member that can be `UNIQUE` (the normal case), `SKIPPED`, or `REPEATED`, and has `pre`, `post`, and `trans` timestamp members (containing the time calculated using the pre-transition offset, the time calculated using the post-transition offset, and the time at which the transition occurs), which in the normal case of `UNIQUE` are all set to the same value. Documentation starts here: https://github.com/google/cctz/blob/master/src/cctz.h#L142 Carl