HowardHinnant / date

A date and time library based on the C++11/14/17 <chrono> header
Other
3.07k stars 669 forks source link

Chrono localication #793

Closed LukashonakV closed 10 months ago

LukashonakV commented 10 months ago

Hi @HowardHinnant Thank you for your incredible contribution into the library. I'm trying to move clock implementation to C++20 std::chrono. Before it we used date::format to print tp. For example:

      res << date::format(*locale_, "%B %Y", ym);

or

        Glib::ustring wd_ustring{date::format(*locale_, "%a", wd)};

This code took into account system locale and printed calendar headers in system locale

image


With the new code in C++20 and GCC13.2.0

      os << std::format(*locale_, "{:%B %Y}", ym);

or

        wdStr = std::format(*locale_, "{:%a}", wd);

image

So the library doesn't print calendar headers in the same manner using system locale. Can you please suggest how to force library apply locale ?

Thank you in advance.

HowardHinnant commented 10 months ago

Hi, thanks for your kind words.

I don't have gcc 13.2.0 to experiment with, but I can think of one possible cause.

  1. gcc 13.2.0 has not yet implemented the complete C++20 spec. The last bits of C++20 were just implemented 3 days ago and are on the gcc trunk. I do not know what has yet to be implemented in gcc 13.2.0, but it might impact this area.

You may be able to confirm or deny this theory with some experiments on godbolt.

Your ported format statements look correct to me.

LukashonakV commented 10 months ago

Thank you. Will check gcc then :)