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
aa3b5aba
Commit
aa3b5aba
authored
Dec 06, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement locale-specific minute formatting
parent
639de217
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
include/fmt/time.h
include/fmt/time.h
+6
-2
test/time-test.cc
test/time-test.cc
+3
-0
No files found.
include/fmt/time.h
View file @
aa3b5aba
...
@@ -206,9 +206,13 @@ struct chrono_formatter {
...
@@ -206,9 +206,13 @@ struct chrono_formatter {
format_localized
(
time
,
'I'
);
format_localized
(
time
,
'I'
);
}
}
void
on_minute
(
numeric_system
)
{
void
on_minute
(
numeric_system
ns
)
{
auto
minute
=
to_int
((
s
.
count
()
/
60
)
%
60
);
auto
minute
=
to_int
((
s
.
count
()
/
60
)
%
60
);
write
(
minute
,
2
);
if
(
ns
==
numeric_system
::
standard
)
return
write
(
minute
,
2
);
auto
time
=
tm
();
time
.
tm_minute
=
minute
;
format_localized
(
time
,
'M'
);
}
}
void
on_second
(
numeric_system
)
{
void
on_second
(
numeric_system
)
{
...
...
test/time-test.cc
View file @
aa3b5aba
...
@@ -107,5 +107,8 @@ TEST(TimeTest, ChronoLocale) {
...
@@ -107,5 +107,8 @@ TEST(TimeTest, ChronoLocale) {
EXPECT_EQ
(
str
(),
fmt
::
format
(
loc
,
"{:%OH}"
,
std
::
chrono
::
hours
(
14
)));
EXPECT_EQ
(
str
(),
fmt
::
format
(
loc
,
"{:%OH}"
,
std
::
chrono
::
hours
(
14
)));
os
<<
std
::
put_time
(
&
time
,
"%OI"
);
os
<<
std
::
put_time
(
&
time
,
"%OI"
);
EXPECT_EQ
(
str
(),
fmt
::
format
(
loc
,
"{:%OI}"
,
std
::
chrono
::
hours
(
14
)));
EXPECT_EQ
(
str
(),
fmt
::
format
(
loc
,
"{:%OI}"
,
std
::
chrono
::
hours
(
14
)));
time
.
tm_minute
=
42
;
os
<<
std
::
put_time
(
&
time
,
"%OM"
);
EXPECT_EQ
(
str
(),
fmt
::
format
(
loc
,
"{:%OM}"
,
std
::
chrono
::
minutes
(
42
)));
}
}
#endif
#endif
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