@@ -1021,3 +1021,30 @@ TEST(chrono_test, year_month_day) {
10211021 EXPECT_THAT (months, Contains (fmt::format (loc, " {:L%b}" , month)));
10221022 }
10231023}
1024+
1025+ #if defined(__cpp_lib_chrono) && __cpp_lib_chrono >= 201907L
1026+ TEST (chrono_test, zoned_time) {
1027+ const static std::map<std::string, std::pair<std::string, std::string>> map_to_test{
1028+ {" Africa/Cairo" , {" EET" , " +0200" }},
1029+ {" Africa/Johannesburg" , {" SAST" , " +0200" }},
1030+ {" America/Chicago" , {" CST" , " -0600" }},
1031+ {" America/Denver" , {" MST" , " -0700" }},
1032+ {" America/Los_Angeles" , {" PST" , " -0800" }},
1033+ {" America/New_York" , {" EST" , " -0500" }},
1034+ {" Asia/Kolkata" , {" IST" , " +0530" }},
1035+ {" Asia/Riyadh" , {" +03" , " +0300" }},
1036+ {" Asia/Shanghai" , {" CST" , " +0800" }},
1037+ {" Asia/Tokyo" , {" JST" , " +0900" }},
1038+ {" Australia/Sydney" , {" AEDT" , " +1100" }},
1039+ {" Europe/Berlin" , {" CET" , " +0100" }},
1040+ {" Europe/London" , {" GMT" , " +0000" }},
1041+ {" Europe/Paris" , {" CET" , " +0100" }},
1042+ {" Pacific/Auckland" , {" NZDT" , " +1300" }}};
1043+ for (const auto & entry : map_to_test) {
1044+ const std::chrono::zoned_time entry_to_test{std::chrono::locate_zone (entry.first ),
1045+ std::chrono::system_clock::now ()};
1046+ EXPECT_EQ (fmt::format (" {:%Z}" , entry_to_test), entry.second .first );
1047+ EXPECT_EQ (fmt::format (" {:%z}" , entry_to_test), entry.second .second );
1048+ }
1049+ }
1050+ #endif
0 commit comments