Skip to content

<chrono>: zoned_time::get_info() and vformat() generate ERROR_NO_UNICODE_TRANSLATION exceptions when the system region is set to Slovak #5482

Open
@StephanTLavavej

Description

@StephanTLavavej

See the original report DevCom-10896610. (Internal: VSO-2467874 / AB#2467874 ).

#include <chrono>
#include <exception>
#include <format>
#include <iostream>
#include <locale>
#include <string>
using namespace std;
using namespace std::chrono;

// Set C++ Language standard to be used to ISO C++20 Standard
// Install the Slovak language first: Settings -> Time & Language -> Language -> Preferred Languages -> Add a language
// Set System Region: Settings -> Time & Language -> Region -> Region Format -> Slovak (Slovakia)

int main() {
    zoned_time<system_clock::duration> zonedTime{current_zone(), system_clock::now()};

    try { // Problem #1
        auto info = zonedTime.get_info();
        cout << "Zone abbrev: " << info.abbrev << endl;
    } catch (const exception& e) {
        cout << "Exception: " << e.what() << endl;
    }

    try { // Problem #2
        string zonedTimeString = vformat(locale::classic(), "{:%Y-%m-%dT%H:%M:%S}", make_format_args(zonedTime));
        cout << "Time string: " << zonedTimeString << endl;
    } catch (const exception& e) {
        cout << "Exception: " << e.what() << endl;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingchronoC++20 chrono

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions