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
7c4eb0fb
Commit
7c4eb0fb
authored
Dec 05, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix warnings in time.h
parent
2d624218
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
include/fmt/time.h
include/fmt/time.h
+14
-8
No files found.
include/fmt/time.h
View file @
7c4eb0fb
...
...
@@ -137,6 +137,13 @@ struct chrono_format_checker {
#ifdef __cpp_lib_chrono
namespace
internal
{
template
<
typename
Int
>
inline
int
to_int
(
Int
value
)
{
FMT_ASSERT
(
value
>=
(
std
::
numeric_limits
<
int
>::
min
)()
&&
value
<=
(
std
::
numeric_limits
<
int
>::
max
)(),
"invalid value"
);
return
static_cast
<
int
>
(
value
);
}
template
<
typename
FormatContext
>
struct
chrono_formatter
{
FormatContext
&
context
;
...
...
@@ -149,9 +156,8 @@ struct chrono_formatter {
explicit
chrono_formatter
(
FormatContext
&
ctx
)
:
context
(
ctx
),
out
(
ctx
.
out
())
{}
template
<
typename
Int
>
void
write
(
Int
value
,
int
width
)
{
typedef
typename
int_traits
<
Int
>::
main_type
main_type
;
void
write
(
int
value
,
int
width
)
{
typedef
typename
int_traits
<
int
>::
main_type
main_type
;
main_type
n
=
value
;
auto
num_digits
=
internal
::
count_digits
(
n
);
if
(
width
>
num_digits
)
...
...
@@ -182,7 +188,7 @@ struct chrono_formatter {
void
on_full_month
()
{}
void
on_24_hour
(
numeric_system
ns
)
{
auto
hour
=
(
s
.
count
()
/
3600
)
%
24
;
auto
hour
=
to_int
((
s
.
count
()
/
3600
)
%
24
)
;
if
(
ns
==
numeric_system
::
standard
)
return
write
(
hour
,
2
);
auto
time
=
tm
();
...
...
@@ -191,7 +197,7 @@ struct chrono_formatter {
}
void
on_12_hour
(
numeric_system
ns
)
{
auto
hour
=
(
s
.
count
()
/
3600
)
%
12
;
auto
hour
=
to_int
((
s
.
count
()
/
3600
)
%
12
)
;
hour
=
hour
>
0
?
hour
:
12
;
if
(
ns
==
numeric_system
::
standard
)
return
write
(
hour
,
2
);
...
...
@@ -201,12 +207,12 @@ struct chrono_formatter {
}
void
on_minute
(
numeric_system
)
{
auto
minute
=
s
.
count
()
/
60
;
write
(
minute
%
60
,
2
);
auto
minute
=
to_int
((
s
.
count
()
/
60
)
%
60
)
;
write
(
minute
,
2
);
}
void
on_second
(
numeric_system
)
{
write
(
s
.
count
()
%
60
,
2
);
write
(
to_int
(
s
.
count
()
%
60
)
,
2
);
if
(
ms
!=
std
::
chrono
::
milliseconds
())
{
*
out
++
=
'.'
;
write
(
ms
.
count
(),
3
);
...
...
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