Skip to content

Invalid (local) %Z and %z with std::chrono::time_point<system_clock> but correct UTC Timestamp (%T) on MSVC #3815

@wbitesi

Description

@wbitesi

Printing with MSVC does not work properly using the Timezone.

When running this example with MSVC

  fmt::print("Got now as {:%FT%T%z}\n",
             std::chrono::time_point<std::chrono::system_clock>::clock::now());

I get the output:
Got now as 2024-01-18T07:09:51.3559309+0100

The timestamp is UTC (local time was 08:09) and UTC time is indeed 07:09, but my time zone (+0100) is printed instead of the correct +0000. On GCC (12.2 on debian) I get the correct time and timezone.

Tested with fmt 10.2.1 and current master. Minimum sample is here:
minimum sample.zip

Changing CXX_STANDARD from 20 to 11 does not lead to different results.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions