fmtlib / fmt

A modern formatting library
https://fmt.dev
Other
19.9k stars 2.43k forks source link

std::chrono::current_zone() is not meant to return the local time zone #3927

Closed hvenev closed 3 months ago

hvenev commented 3 months ago

fmt::localtime uses std::chrono::current_zone() to determine the local time zone. However, per https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114645, the intended behavior of std::chrono::current_zone() is to read /etc/localtime, which does not match how libc determines the local time zone. The TZ environment variable should also be considered.

vitaut commented 3 months ago

Thanks for reporting but {fmt} is a C++ library and doesn't have to replicate legacy C behaviors. If you believe there is something wrong with std::chrono::current_zone please open an LWG issue.

hvenev commented 3 months ago

The problem is that the other fmt::localtime uses the "legacy" C behavior specified by POSIX.

vitaut commented 3 months ago

It's just a fallback. We could make it more consistent with std::chrono::current_zone but it's not critical.

hvenev commented 3 months ago

I had misunderstood the code. Sorry for wasting your time.