https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114279

            Bug ID: 114279
           Summary: utc_clock does not support leap seconds
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gnaggnoyil at gmail dot com
  Target Milestone: ---

When using current GCC trunk, the program

#include <chrono>
#include <sstream>
#include <iostream>

int main(){
        std::stringstream stream;
        stream << "20161231-23:59:60.035";
        std::chrono::utc_time<std::chrono::milliseconds> utc_tp;
        (void)std::chrono::from_stream(stream, "%4Y%2m%2d-%2H:%2M:%S", utc_tp);
        std::cout << utc_tp << std::endl;
        return 0;
}

gives the following output:

2017-01-01 00:00:00.035

which does not seems to give leap seconds into consideration.

The current standard working draft [time.clock.utc.overview]#1 states

In contrast to sys_time, which does not take leap seconds into account,
utc_clock and its associated time_point, utc_time, count time, including leap
seconds, since 1970-01-01 00:00:00 UTC.

So I think the current libstdc++ implementation here is not conforming the
standard.

Reply via email to