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

--- Comment #2 from Howard Hinnant <howard.hinnant at gmail dot com> ---
This:

2024-03-05 00:00:00
2024-03-04 23:59:33

looks like correct output to me.

sys_time and utc_time map to the same civil calendar date/time (except during a
leap second).  That is 2024-03-05 00:00:00 sys_time, converted to utc_time,
also should print out as 2024-03-05 00:00:00.

The only difference between sys_time and utc_time is that utc_time counts the
leap seconds since 1970 (27 at this point).  This means if you look at the
difference in .time_since_epoch(), utc_time will be 27 seconds longer, even
though it prints out as the same date and time.

Consequently, 2024-03-05 00:00:00 in utc_time is *not* a multiple of 86400s,
but rather 27s greater than a multiple of 86400s.  And all round<days>(udays)
does is round the .time_since_epoch() to the nearest multiple of 86400s.  Which
in utc_time is 27s earlier, or 2024-03-04 23:59:33.

So in summary, if you make a change, and *don't* get this output, then you've
introduced a bug.
  • [Bug libstdc++/114260] std::f... howard.hinnant at gmail dot com via Gcc-bugs

Reply via email to