mirror of
https://github.com/fmtlib/fmt.git
synced 2025-06-25 01:11:40 +02:00
Fix handling of %Z
This commit is contained in:
2
.github/workflows/windows.yml
vendored
2
.github/workflows/windows.yml
vendored
@ -39,7 +39,7 @@ jobs:
|
||||
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
|
||||
|
||||
- name: Set timezone
|
||||
run: tzutil /s "Ekaterinburg Standard Time"
|
||||
run: tzutil /s "Pacific Standard Time"
|
||||
|
||||
- name: Create Build Environment
|
||||
run: cmake -E make_directory ${{runner.workspace}}/build
|
||||
|
@ -1393,7 +1393,7 @@ class tm_writer {
|
||||
}
|
||||
|
||||
void on_utc_offset(numeric_system ns) { format_utc_offset_impl(tm_, ns); }
|
||||
void on_tz_name() { format_tz_name_impl(tm_); }
|
||||
void on_tz_name() { out_ = std::copy_n("UTC", 3, out_); }
|
||||
|
||||
void on_year(numeric_system ns, pad_type pad) {
|
||||
if (is_classic_ || ns == numeric_system::standard)
|
||||
|
@ -263,8 +263,7 @@ auto strftime_full_utc(TimePoint tp) -> std::string {
|
||||
return system_strftime("%Y-%m-%d %H:%M:%S", &tm);
|
||||
}
|
||||
|
||||
template <typename Time>
|
||||
void test_time(Time time) {
|
||||
template <typename Time> void test_time(Time time) {
|
||||
EXPECT_EQ(fmt::format("{}", time), "1979-03-12 12:00:00");
|
||||
EXPECT_EQ(fmt::format("{:}", time), "1979-03-12 12:00:00");
|
||||
|
||||
@ -333,20 +332,7 @@ TEST(chrono_test, sys_time) {
|
||||
EXPECT_EQ(fmt::format("{:%z}", time), "+0000");
|
||||
EXPECT_EQ(fmt::format("{:%Ez}", time), "+00:00");
|
||||
EXPECT_EQ(fmt::format("{:%Oz}", time), "+00:00");
|
||||
|
||||
auto t1 = std::chrono::time_point_cast<std::chrono::seconds>(
|
||||
std::chrono::system_clock::now());
|
||||
|
||||
// Separate tests for UTC, since std::time_put can use local time and ignoring
|
||||
// the timezone in std::tm (if it presents on platform).
|
||||
if (fmt::detail::has_member_data_tm_zone<std::tm>::value) {
|
||||
auto t = std::chrono::system_clock::to_time_t(t1);
|
||||
auto tm = *std::gmtime(&t);
|
||||
|
||||
std::vector<std::string> tz_names = {"GMT", "UTC"};
|
||||
EXPECT_THAT(tz_names, Contains(fmt::format("{:%Z}", t1)));
|
||||
EXPECT_THAT(tz_names, Contains(fmt::format("{:%Z}", tm)));
|
||||
}
|
||||
EXPECT_EQ(fmt::format("{:%Z}", time), "UTC");
|
||||
}
|
||||
|
||||
TEST(chrono_test, local_time) {
|
||||
|
Reference in New Issue
Block a user