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
8b894549
Commit
8b894549
authored
Nov 13, 2021
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve consistency
parent
5380ff4d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
21 deletions
+20
-21
include/fmt/chrono.h
include/fmt/chrono.h
+20
-21
No files found.
include/fmt/chrono.h
View file @
8b894549
...
...
@@ -993,7 +993,7 @@ template <typename OutputIt, typename Char> class tm_writer {
}
public:
explicit
tm_writer
(
const
std
::
locale
&
loc
,
OutputIt
out
,
const
std
::
tm
&
tm
)
tm_writer
(
const
std
::
locale
&
loc
,
OutputIt
out
,
const
std
::
tm
&
tm
)
:
loc_
(
loc
),
is_classic_
(
loc_
==
get_classic_locale
()),
out_
(
out
),
...
...
@@ -1374,25 +1374,24 @@ OutputIt format_duration_unit(OutputIt out) {
return
out
;
}
struct
get_locale
{
explicit
get_locale
(
bool
localized
,
locale_ref
loc_ref
)
:
has_locale
{
localized
}
{
class
get_locale
{
private:
union
{
std
::
locale
locale_
;
};
bool
has_locale_
=
false
;
public:
get_locale
(
bool
localized
,
locale_ref
loc
)
:
has_locale_
(
localized
)
{
if
(
localized
)
::
new
(
&
locale
)
std
::
locale
{
loc_ref
.
template
get
<
std
::
locale
>()}
;
::
new
(
&
locale
_
)
std
::
locale
(
loc
.
template
get
<
std
::
locale
>())
;
}
~
get_locale
()
{
if
(
has_locale
)
locale
.
~
locale
();
if
(
has_locale
_
)
locale_
.
~
locale
();
}
operator
const
std
::
locale
&
()
const
{
return
has_locale
?
locale
:
get_classic_locale
();
return
has_locale
_
?
locale_
:
get_classic_locale
();
}
private:
union
{
monostate
dummy
{};
std
::
locale
locale
;
};
bool
has_locale
=
false
;
};
template
<
typename
FormatContext
,
typename
OutputIt
,
typename
Rep
,
...
...
@@ -1414,7 +1413,7 @@ struct chrono_formatter {
using
char_type
=
typename
FormatContext
::
char_type
;
explicit
chrono_formatter
(
FormatContext
&
ctx
,
OutputIt
o
,
chrono_formatter
(
FormatContext
&
ctx
,
OutputIt
o
,
std
::
chrono
::
duration
<
Rep
,
Period
>
d
)
:
context
(
ctx
),
out
(
o
),
...
...
@@ -1497,7 +1496,7 @@ struct chrono_formatter {
void
format_localized
(
const
tm
&
time
,
char
format
,
char
modifier
=
0
)
{
if
(
isnan
(
val
))
return
write_nan
();
out
=
detail
::
write
<
char_type
>
(
out
,
time
,
get_locale
{
localized
,
context
.
locale
()}
,
format
,
modifier
);
out
,
time
,
get_locale
(
localized
,
context
.
locale
())
,
format
,
modifier
);
}
void
on_text
(
const
char_type
*
begin
,
const
char_type
*
end
)
{
...
...
@@ -1665,7 +1664,7 @@ template <typename Char> struct formatter<weekday, Char> {
auto
time
=
std
::
tm
();
time
.
tm_wday
=
static_cast
<
int
>
(
wd
.
c_encoding
());
return
detail
::
write
<
Char
>
(
ctx
.
out
(),
time
,
detail
::
get_locale
{
localized
,
ctx
.
locale
()}
,
'a'
);
ctx
.
out
(),
time
,
detail
::
get_locale
(
localized
,
ctx
.
locale
())
,
'a'
);
}
};
...
...
@@ -1863,9 +1862,9 @@ template <typename Char> struct formatter<std::tm, Char> {
template
<
typename
FormatContext
>
auto
format
(
const
std
::
tm
&
tm
,
FormatContext
&
ctx
)
const
->
decltype
(
ctx
.
out
())
{
const
auto
loc
_ref
=
ctx
.
locale
();
return
this
->
do_format
(
ctx
.
out
(),
tm
,
detail
::
get_locale
{
static_cast
<
bool
>
(
loc_ref
),
loc_ref
}
);
const
auto
loc
=
ctx
.
locale
();
return
this
->
do_format
(
ctx
.
out
(),
tm
,
detail
::
get_locale
(
static_cast
<
bool
>
(
loc
),
loc
)
);
}
};
...
...
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