On Fri, Sep 2, 2016 at 11:47 AM, Howard Hinnant <howard.hinnant@gmail.com> wrote:
On Sep 2, 2016, at 11:42 AM, Bradley White <bww@acm.org> wrote:
Just to clarify, the leap-second table in the tzdata is only for running
in "right" mode, where clocks tick through leaps and so don't need any indication that leaps happen.
This may be your only use of the leap-second table, but it is not my use.
Here is working code for me:
#include "chrono_io.h" #include "tz.h" #include <iostream>
int main() { using namespace date; using namespace std::chrono_literals; auto t0 = to_gps_time(sys_days{2017_y/jan/1} - 500ms); auto t1 = to_gps_time(sys_days{2017_y/jan/1} + 500ms); std::cout << t1 - t0 << '\n'; }
This should output:
2000ms
which indicates the insertion of a leap second into my gps_clock a few months from now. Unfortunately it currently (and incorrectly) outputs:
1000ms
Sure, you may use *a* leap-second table. But tzdata only includes one to generate "right" zoneinfo files. Aside: It would be unfortunate, for any expression X, if ((X + 500ms) - (X - 500ms)) was not 1000ms.