Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
d9fd695a
Commit
d9fd695a
authored
Sep 13, 2021
by
Vladislav Shchapov
Committed by
Victor Zverovich
Sep 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix wchar_t tm formatting
parent
92614ecb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
include/fmt/chrono.h
include/fmt/chrono.h
+7
-4
test/xchar-test.cc
test/xchar-test.cc
+2
-0
No files found.
include/fmt/chrono.h
View file @
d9fd695a
...
@@ -564,10 +564,13 @@ template <typename Char> struct formatter<std::tm, Char> {
...
@@ -564,10 +564,13 @@ template <typename Char> struct formatter<std::tm, Char> {
while
(
end
!=
ctx
.
end
()
&&
*
end
!=
'}'
)
++
end
;
while
(
end
!=
ctx
.
end
()
&&
*
end
!=
'}'
)
++
end
;
auto
size
=
detail
::
to_unsigned
(
end
-
it
);
auto
size
=
detail
::
to_unsigned
(
end
-
it
);
specs
=
{
it
,
size
};
specs
=
{
it
,
size
};
if
(
specs
==
string_view
(
"%F"
,
2
))
// basic_string_view<>::compare isn't constexpr before C++17
spec_
=
spec
::
year_month_day
;
if
(
specs
.
size
()
==
2
&&
specs
[
0
]
==
Char
(
'%'
))
{
else
if
(
specs
==
string_view
(
"%T"
,
2
))
if
(
specs
[
1
]
==
Char
(
'F'
))
spec_
=
spec
::
hh_mm_ss
;
spec_
=
spec
::
year_month_day
;
else
if
(
specs
[
1
]
==
Char
(
'T'
))
spec_
=
spec
::
hh_mm_ss
;
}
return
end
;
return
end
;
}
}
...
...
test/xchar-test.cc
View file @
d9fd695a
...
@@ -261,6 +261,8 @@ TEST(xchar_test, chrono) {
...
@@ -261,6 +261,8 @@ TEST(xchar_test, chrono) {
EXPECT_EQ
(
fmt
::
format
(
"The date is {:%Y-%m-%d %H:%M:%S}."
,
tm
),
EXPECT_EQ
(
fmt
::
format
(
"The date is {:%Y-%m-%d %H:%M:%S}."
,
tm
),
"The date is 2016-04-25 11:22:33."
);
"The date is 2016-04-25 11:22:33."
);
EXPECT_EQ
(
L"42s"
,
fmt
::
format
(
L"{}"
,
std
::
chrono
::
seconds
(
42
)));
EXPECT_EQ
(
L"42s"
,
fmt
::
format
(
L"{}"
,
std
::
chrono
::
seconds
(
42
)));
EXPECT_EQ
(
fmt
::
format
(
L"{:%F}"
,
tm
),
L"2016-04-25"
);
EXPECT_EQ
(
fmt
::
format
(
L"{:%T}"
,
tm
),
L"11:22:33"
);
}
}
TEST
(
xchar_test
,
color
)
{
TEST
(
xchar_test
,
color
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment