tzdb: cannot locate zone

Trying to run my an old app...
where:
 
std::string time = std::format("{:%H:%M:%OS %z}", std::chrono::zoned_time{"America/New_York", now});



terminate called after throwing an instance of 'std::runtime_error'
  what():  tzdb: cannot locate zone: America/New_York
Aborted


It returns a such error with any zone. I have this issue on Debian 12. On Deb 11 it worked fine.

1. All files of TZDB are there and readable - /usr/share/zoneinfo/.
2. I have a last version: "tzdata_2024b-0+deb12u1_all"(bookworm); downgrading to "2024b-0+deb11u1"(bullseye) doesn't help.
3. Neither g++ 13.3.0 nor g++ 14.2.0 can obtain the location.

I have searched around... Suggestions like to change "America/New_York" to "some code"(Ubuntu) or downgrading the tzdata(ArchLinux) didn't work for me.

Maybe someone knows how to locate zone? It looks like Debian, as usually, has its own painful way:))
The problem of "America/New_York" is that there are 2 timezones: "EST" and "EDT". The error probably means that the system is not able to figure out which one to use.

Maybe you can use "EST"/"EDT" instead. That'd mean it is up to you to figure out the right one.
Maybe you can use "EST"/"EDT" instead.

Unfortunately..
tzdb: cannot locate zone: EST
tzdb: cannot locate zone: EDT
tzdb: cannot locate zone: /usr/share/zoneinfo/America/New_York
as well((
btw, the "some code"(Ubuntu)" mentioned above is a "EST5EDT"... from the file "New_York".
tzdb: cannot locate zone: EST5EDT
That looks like the timezone is not correctly configured. Did you considered this:

https://wiki.debian.org/TimeZoneChanges
I really don't want to change the local time. I have no reason to change time settings, it works fine and may be reconfigured any time if I need.
I want to let my program to represent the local time(or any time point) in time of a certain location - for ex. NY. As I see there: https://wiki.debian.org/TimeZoneChanges - Time Zone changes doesn't affect time representation by std::chrono::zoned_time. Time point representation is the reason why I'm using "zoned_time".
Last edited on
Just found another way... but not what I really want.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <chrono>
#include <iostream>
#include <iomanip>
#include <ctime>
#include <cstdlib>

int main() {
    // Set the TZ environment variable
    setenv("TZ", "America/New_York", 1);
    tzset(); // Update the timezone information

    auto now = std::chrono::system_clock::now();
    auto local_time = std::chrono::system_clock::to_time_t(now);
    std::tm* tm_ptr = std::localtime(&local_time);

    // Format the time manually
    std::cout << "Current time in New York: "
              << std::put_time(tm_ptr, "%H:%M:%S %z") << std::endl;

    return 0;
}



Current time in New York: 11:31:07 -0500
This sounds like a breaking change that Debian devs introduced, no? Is there something in the Debian 12 changelogs that mention zoned_time or time zone changes? Maybe a actual Debian forum might know more.
cppreference has a sample program in https://en.cppreference.com/w/cpp/chrono/zoned_time
I did run it there and got:
             Africa/Casablanca - Zoned Time: 2025-02-28 15:35:31.670317006 +00

America/Argentina/Buenos_Aires - Zoned Time: 2025-02-28 12:35:31.675967324 -03
              America/Barbados - Zoned Time: 2025-02-28 11:35:31.675975923 AST
    America/Indiana/Petersburg - Zoned Time: 2025-02-28 10:35:31.675983665 EST
Error: std::chrono::tzdb: cannot locate zone: America/Tarasco_Bar
              Antarctica/Casey - Zoned Time: 2025-02-28 23:35:31.676126172 +08
             Antarctica/Vostok - Zoned Time: 2025-02-28 20:35:31.676133331 +05
                  Asia/Magadan - Zoned Time: 2025-03-01 02:35:31.676136602 +11
                   Asia/Manila - Zoned Time: 2025-02-28 23:35:31.676140361 PST
                 Asia/Shanghai - Zoned Time: 2025-02-28 23:35:31.676147347 CST
                    Asia/Tokyo - Zoned Time: 2025-03-01 00:35:31.676154280 JST
              Atlantic/Bermuda - Zoned Time: 2025-02-28 11:35:31.676160805 AST
              Australia/Darwin - Zoned Time: 2025-03-01 01:05:31.676186592 ACST
            Europe/Isle_of_Man - Zoned Time: 2025-02-28 15:35:31.676193613 GMT
Error: std::chrono::tzdb: cannot locate zone: Europe/Laputa
              Indian/Christmas - Zoned Time: 2025-02-28 22:35:31.676222711 +07
                  Indian/Cocos - Zoned Time: 2025-02-28 22:05:31.676227586 +0630
             Pacific/Galapagos - Zoned Time: 2025-02-28 09:35:31.676231553 -06

Note two unknown zones. An AlmaLinux 9 the output is same (and "America/New_York" exists).
Yeah, I know this example. But how can this change the situation? It seems this is specific Debian bug now - libstdc++ cannot parse tzdata correctly.


Error: tzdb: cannot locate zone: Africa/Casablanca
Error: tzdb: cannot locate zone: America/Argentina/Buenos_Aires
Error: tzdb: cannot locate zone: America/Barbados
Error: tzdb: cannot locate zone: America/Indiana/Petersburg
Error: tzdb: cannot locate zone: America/Tarasco_Bar
Error: tzdb: cannot locate zone: Antarctica/Casey
Error: tzdb: cannot locate zone: Antarctica/Vostok
Error: tzdb: cannot locate zone: Asia/Magadan
Error: tzdb: cannot locate zone: Asia/Manila
Error: tzdb: cannot locate zone: Asia/Shanghai
Error: tzdb: cannot locate zone: Asia/Tokyo
Error: tzdb: cannot locate zone: Atlantic/Bermuda
Error: tzdb: cannot locate zone: Australia/Darwin
Error: tzdb: cannot locate zone: Europe/Isle_of_Man
Error: tzdb: cannot locate zone: Europe/Laputa
Error: tzdb: cannot locate zone: Indian/Christmas
Error: tzdb: cannot locate zone: Indian/Cocos
Error: tzdb: cannot locate zone: Pacific/Galapagos


This is interesting https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109857 - but I'm not sure I can figure out how to deal with it.
As I understand this, the problem is that in the file tzdata.zi max is Max and hence can't be parsed. If so, why not just edit this file and replace Max with max?
I just can't find neither "Max" nor "max" there. The mentioned string from the bugzilla looks otherwise - there is only "ma". So, I'm not sure should I touch this because there are many strings containing "ma".

from bugzilla:

R K 2023 Max - O lastTh 24 0 -


..../gcc-13.3.0/libstdc++-v3/src/c++20/tzdata.zi:

R K 2023 ma - O lastTh 24 0 -



Okay, I have edited the tzdata.zi :) "ma" -> "max"
Still not working. Maybe it's needed to reboot the machine or restart something? I'm not sure.))
Registered users can post here. Sign in or register to post.