Skip to content

Commit 14a3b85

Browse files
committed
P2372R3 Fixing locale handling in chrono formatters
In [time.zone.zonedtime.nonmembers], remove the separate "Returns" item now that have "Effects: Equivalent to: return ..."
1 parent 2360a59 commit 14a3b85

File tree

2 files changed

+40
-34
lines changed

2 files changed

+40
-34
lines changed

source/support.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@
609609
#define @\defnlibxname{cpp_lib_exchange_function}@ 201304L // also in \libheader{utility}
610610
#define @\defnlibxname{cpp_lib_execution}@ 201902L // also in \libheader{execution}
611611
#define @\defnlibxname{cpp_lib_filesystem}@ 201703L // also in \libheader{filesystem}
612-
#define @\defnlibxname{cpp_lib_format}@ 202106L // also in \libheader{format}
612+
#define @\defnlibxname{cpp_lib_format}@ 202110L // also in \libheader{format}
613613
#define @\defnlibxname{cpp_lib_gcd_lcm}@ 201606L // also in \libheader{numeric}
614614
#define @\defnlibxname{cpp_lib_generic_associative_lookup}@ 201304L // also in \libheader{map}, \libheader{set}
615615
#define @\defnlibxname{cpp_lib_generic_unordered_lookup}@ 201811L

source/time.tex

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,9 +2703,7 @@
27032703
\effects
27042704
Equivalent to:
27052705
\begin{codeblock}
2706-
auto const dp = floor<days>(tp);
2707-
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{} {}"),
2708-
year_month_day{dp}, hh_mm_ss{tp-dp});
2706+
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@("{:L%F %T}"), tp);
27092707
\end{codeblock}
27102708

27112709
\pnum
@@ -2901,7 +2899,7 @@
29012899
\effects
29022900
Equivalent to:
29032901
\begin{codeblock}
2904-
return os << format(@\placeholder{STATICALLY-WIDEN}@<charT>("{:%F %T}"), t);
2902+
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{:L%F %T}"), t);
29052903
\end{codeblock}
29062904

29072905
\pnum
@@ -3107,7 +3105,7 @@
31073105
\effects
31083106
Equivalent to:
31093107
\begin{codeblock}
3110-
return os << format(@\placeholder{STATICALLY-WIDEN}@<charT>("{:%F %T}"), t);
3108+
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{:L%F %T}"), t);
31113109
\end{codeblock}
31123110

31133111
\pnum
@@ -3270,7 +3268,7 @@
32703268
\effects
32713269
Equivalent to:
32723270
\begin{codeblock}
3273-
return os << format(@\placeholder{STATICALLY-WIDEN}@<charT>("{:%F %T}"), t);
3271+
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{:L%F %T}"), t);
32743272
\end{codeblock}
32753273

32763274
\pnum
@@ -3393,7 +3391,7 @@
33933391
\effects
33943392
Equivalent to:
33953393
\begin{codeblock}
3396-
return os << format(@\placeholder{STATICALLY-WIDEN}@<charT>("{:%F %T}"), t);
3394+
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{:L%F %T}"), t);
33973395
\end{codeblock}
33983396
\end{itemdescr}
33993397

@@ -4469,7 +4467,7 @@
44694467
Equivalent to:
44704468
\begin{codeblock}
44714469
return os << (m.ok() ?
4472-
format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{:%b}"), m) :
4470+
format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{:L%b}"), m) :
44734471
format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{} is not a valid month"),
44744472
static_cast<unsigned>(m)));
44754473
\end{codeblock}
@@ -5196,7 +5194,7 @@
51965194
Equivalent to:
51975195
\begin{codeblock}
51985196
return os << (wd.ok() ?
5199-
format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{:%a}"), wd) :
5197+
format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{:L%a}"), wd) :
52005198
format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{} is not a valid weekday"),
52015199
static_cast<unsigned>(wd.wd_)));
52025200
\end{codeblock}
@@ -5350,8 +5348,8 @@
53505348
\begin{codeblock}
53515349
auto i = wdi.index();
53525350
return os << (i >= 1 && i <= 5 ?
5353-
format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{}[{}]"), wdi.weekday(), i) :
5354-
format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{}[{} is not a valid index]"),
5351+
format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{:L}[{}]"), wdi.weekday(), i) :
5352+
format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{:L}[{} is not a valid index]"),
53555353
wdi.weekday(), i));
53565354
\end{codeblock}
53575355
\end{itemdescr}
@@ -5453,7 +5451,7 @@
54535451
\effects
54545452
Equivalent to:
54555453
\begin{codeblock}
5456-
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{}[last]"), wdl.weekday());
5454+
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{:L}[last]"), wdl.weekday());
54575455
\end{codeblock}
54585456
\end{itemdescr}
54595457

@@ -5580,7 +5578,7 @@
55805578
\effects
55815579
Equivalent to:
55825580
\begin{codeblock}
5583-
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{}/{}"),
5581+
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{:L}/{}"),
55845582
md.month(), md.day());
55855583
\end{codeblock}
55865584
\end{itemdescr}
@@ -5717,7 +5715,7 @@
57175715
\effects
57185716
Equivalent to:
57195717
\begin{codeblock}
5720-
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{}/last"), mdl.month());
5718+
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{:L}/last"), mdl.month());
57215719
\end{codeblock}
57225720
\end{itemdescr}
57235721

@@ -5830,7 +5828,7 @@
58305828
\effects
58315829
Equivalent to:
58325830
\begin{codeblock}
5833-
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{}/{}"),
5831+
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{:L}/{:L}"),
58345832
mwd.month(), mwd.weekday_indexed());
58355833
\end{codeblock}
58365834
\end{itemdescr}
@@ -5946,7 +5944,7 @@
59465944
\effects
59475945
Equivalent to:
59485946
\begin{codeblock}
5949-
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{}/{}"),
5947+
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{:L}/{:L}"),
59505948
mwdl.month(), mwdl.weekday_last());
59515949
\end{codeblock}
59525950
\end{itemdescr}
@@ -6260,7 +6258,7 @@
62606258
\effects
62616259
Equivalent to:
62626260
\begin{codeblock}
6263-
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{}/{}"),
6261+
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{}/{:L}"),
62646262
ym.year(), ym.month());
62656263
\end{codeblock}
62666264
\end{itemdescr}
@@ -7119,7 +7117,7 @@
71197117
\effects
71207118
Equivalent to:
71217119
\begin{codeblock}
7122-
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{}/{}"),
7120+
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{}/{:L}"),
71237121
ymdl.year(), ymdl.month_day_last());
71247122
\end{codeblock}
71257123
\end{itemdescr}
@@ -7515,7 +7513,7 @@
75157513
\effects
75167514
Equivalent to:
75177515
\begin{codeblock}
7518-
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{}/{}/{}"),
7516+
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{}/{:L}/{:L}"),
75197517
ymwd.year(), ymwd.month(), ymwd.weekday_indexed());
75207518
\end{codeblock}
75217519
\end{itemdescr}
@@ -7863,7 +7861,7 @@
78637861
\effects
78647862
Equivalent to:
78657863
\begin{codeblock}
7866-
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{}/{}/{}"),
7864+
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{}/{:L}/{:L}"),
78677865
ymwdl.year(), ymwdl.month(), ymwdl.weekday_last());
78687866
\end{codeblock}
78697867
\end{itemdescr}
@@ -8609,7 +8607,7 @@
86098607
\effects
86108608
Equivalent to:
86118609
\begin{codeblock}
8612-
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{:%T}"), hms);
8610+
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@<charT>("{:L%T}"), hms);
86138611
\end{codeblock}
86148612

86158613
\pnum
@@ -10086,14 +10084,10 @@
1008610084
\begin{itemdescr}
1008710085
\pnum
1008810086
\effects
10089-
Streams
10090-
the value returned from \tcode{t.get_local_time()}
10091-
to \tcode{os}
10092-
using the format \tcode{"\%F \%T \%Z"}.
10093-
10094-
\pnum
10095-
\returns
10096-
\tcode{os}.
10087+
Equivalent to:
10088+
\begin{codeblock}
10089+
return os << format(os.getloc(), @\placeholder{STATICALLY-WIDEN}@("{:L%F %T %Z}"), t);
10090+
\end{codeblock}
1009710091
\end{itemdescr}
1009810092

1009910093
\rSec2[time.zone.leap]{Class \tcode{leap_second}}
@@ -10432,7 +10426,7 @@
1043210426

1043310427
\begin{ncbnf}
1043410428
\fmtnontermdef{chrono-format-spec}\br
10435-
\opt{fill-and-align} \opt{width} \opt{precision} \opt{chrono-specs}
10429+
\opt{fill-and-align} \opt{width} \opt{precision} \opt{\terminal{L}} \opt{chrono-specs}
1043610430
\end{ncbnf}
1043710431

1043810432
\begin{ncbnf}
@@ -10481,15 +10475,26 @@
1048110475
represented by \fmtgrammarterm{literal-char}
1048210476
are copied unchanged to the output.
1048310477

10478+
\pnum
10479+
A \defnadj{formatting}{locale} is an instance of \tcode{locale}
10480+
used by a formatting function, that is determined as follows:
10481+
\begin{itemize}
10482+
\item
10483+
the "C" locale if the \tcode{L} option
10484+
is not present in \fmtgrammarterm{chrono-format-spec}, otherwise
10485+
\item
10486+
the locale passed to the formatting function if any, otherwise
10487+
\item
10488+
the global locale.
10489+
\end{itemize}
10490+
1048410491
\pnum
1048510492
Each conversion specifier \fmtgrammarterm{conversion-spec}
1048610493
is replaced by appropriate characters
1048710494
as described in \tref{time.format.spec};
1048810495
the formats specified in ISO 8601:2004 shall be used where so described.
1048910496
Some of the conversion specifiers
10490-
depend on the locale that is passed to the formatting function
10491-
if the latter takes one,
10492-
or the global locale otherwise.
10497+
depend on the formatting locale.
1049310498
If the formatted object does not contain the information
1049410499
the conversion specifier refers to,
1049510500
an exception of type \tcode{format_error} is thrown.
@@ -10764,6 +10769,7 @@
1076410769
If the \fmtgrammarterm{chrono-specs} is omitted,
1076510770
the chrono object is formatted
1076610771
as if by streaming it to \tcode{std::ostringstream os}
10772+
with the formatting locale imbued
1076710773
and copying \tcode{os.str()} through the output iterator of the context
1076810774
with additional padding and adjustments as specified by the format specifiers.
1076910775
\begin{example}

0 commit comments

Comments
 (0)