Trouble finding Time Zones by parsing the name

26 views
Skip to first unread message

Chris Kingsley

unread,
Apr 24, 2025, 8:44:38 AMApr 24
to icu-support
Using ICU 74.2, if I construct
        auto tz = icu::TimeZone::createTimeZone("Africa/Harare");
I can then iterate over various styles to get other names for this Time Zone. In particular, 
        Tz->GetDisplayName(0, TimeZone::GENERIC_LOCATION, result);
I get the name "Zimbabwe Time". I have not found any way to get from the name "Zimbabwe Time" to get the correct time zone object later. I have been using  a TimeZoneFormat object:
        auto tzf = TimeZoneFormat::createInstance(loc, ec); // loc is English
And call
        auto foundTZ = tzf->parse(UTZFMT_STYLE_GENERIC_LOCATION, uniName, pos, UTZFMT_PARSE_OPTION_NONE, &ttype);
And I get no foundTZ. I have tried a variety of format styles and parse options, but I haven't found a way to find a TZ object from that name.

If GetDisplayName can give a name, shouldn't Parse be able to find the TZ for that name?

How can I parse this? Is there a better way to find this?

Reply all
Reply to author
Forward
0 new messages