Fix scope for glibc ext for sec, min, and hour (#3812)

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
This commit is contained in:
Vladislav Shchapov 2024-01-17 02:54:19 +05:00 committed by GitHub
parent 13ec66bf78
commit 470c4e6ca8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View File

@ -708,8 +708,8 @@ FMT_CONSTEXPR auto parse_chrono_format(const Char* begin, const Char* end,
if (begin == end || *begin == '}') return begin;
if (*begin != '%') FMT_THROW(format_error("invalid format"));
auto ptr = begin;
pad_type pad = pad_type::unspecified;
while (ptr != end) {
pad_type pad = pad_type::unspecified;
auto c = *ptr;
if (c == '}') break;
if (c != '%') {

View File

@ -956,6 +956,7 @@ TEST(chrono_test, glibc_extensions) {
EXPECT_EQ(fmt::format("{:%0I,%0H,%0M,%0S}", d), "01,01,02,03");
EXPECT_EQ(fmt::format("{:%_I,%_H,%_M,%_S}", d), " 1, 1, 2, 3");
EXPECT_EQ(fmt::format("{:%-I,%-H,%-M,%-S}", d), "1,1,2,3");
EXPECT_EQ(fmt::format("{:%-I,%H,%M,%S}", d), "1,01,02,03");
EXPECT_EQ(fmt::format("{:%OI,%OH,%OM,%OS}", d), "01,01,02,03");
EXPECT_EQ(fmt::format("{:%0OI,%0OH,%0OM,%0OS}", d), "01,01,02,03");