google / cctz

CCTZ is a C++ library for translating between absolute and civil times using the rules of a time zone.
Apache License 2.0
597 stars 166 forks source link

Breakdown the "seconds + femtoseconds => time_point" overflow issue. #200

Closed devbww closed 3 years ago

devbww commented 3 years ago

When cctz::parse() produces seconds+femtoseconds values that cannot be represented in the output time_point<D> it should return false. Here we add overloads of join_seconds() that break the overflow issue down into four cases, three of which are implemented and have test cases.

The fourth overload (for 1/N duration ratios) is yet to be implemented, so its test cases are currently commented out, but they provide a guide to what remains to be done. See #199.

Also, clarify that the ToUnixSeconds() implementation requires that the std::chrono::system_clock uses the Unix epoch in order to avoid arithmetic overflow.


This change is Reviewable