From c10b7292730acbe5c23f896a03dc27d74ab5e858 Mon Sep 17 00:00:00 2001
From: Howard Hinnant
Howard E. Hinnant
-2016-11-24
+2017-04-01
@@ -63,7 +63,7 @@ If you want detailed explanations of the algorithms, go there.
date
-It performs best with C++14, which has vastly improved constexpr
rules.
+It performs best with C++14, which has vastly improved constexpr
rules.
However, the library will auto-adopt to C++11, sacrificing several constexpr
declarations. In C++11, this will effectively transfer some computations that should be
done at compile-time to run-time. Porting to C++98/03 has not been attempted.
@@ -1206,7 +1206,7 @@ That is, first find the first Thursday in January for year y
, and t
the number of days required to find the Monday before this day. This could have been done
with days{3}
. But I chose to code this as (thu-mon)
.
Computationally and performance wise, these two choices are identical: they both subtract
-the literal 3. I chose the latter because I believe it to be more readable.
+the literal 3. I chose the latter because I believe it to be more readable.
"3
" is just a magic constant. But "(thu-mon)
" is the number of
days Thursday is past Monday.
I've included two extra units: picoseconds
, and the units used by Visual
Studio's system_clock::time_point
. Units finer than picoseconds
-do not work with this date library because the conversion factors needed to convert to
+do not work with this date library because the conversion factors needed to convert to
units such as days
overflow the compile-time machinery. As a practical
matter this is not important as the range of a 64 bit femtosecond is only about +/- 2.5
hours. On the other side, units coarser than hours
, if represented by at
@@ -1600,8 +1600,10 @@ operator<<(std::basic_ostream<CharT, Traits>& os, const local_ti
to_stream
formattingformat
from_stream
formattingparse
months
is the resultant type
when subtracting two month
field-based time points. months
is
-not implicitly convertible to days
or weeks
nor vice-versa.
+not implicitly convertible to days
or weeks
nor vice-versa.
months
will not implicitly convert to years
.
@@ -1672,6 +1674,53 @@ using months = std::chrono::duration <int, std::ratio_divide<years::period, std::ratio<12>>>;+
+template <class CharT, class Traits, class Rep, class Period> +void +to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt, + const std::chrono::duration<Rep, Period>& d); ++ +
++ ++Effects: Inserts
+d
, converted to the +common_type<duration, seconds>
intoos
using the format +stringfmt
as specified by the +to_stream
formatting flags. The behavior +is undefined except for the following flags (or modified versions of these flags): +%H
,%I
,%M
,%p
,%r
, +%R
,%S
,%T
,%X
,%n
, +%t
or%%
. +
+template <class Rep, class Period, class CharT, class Traits, class Alloc = std::allocator<CharT>> +void +from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt, + std::chrono::duration<Rep, Period>& d, + std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr, + std::chrono::minutes* offset = nullptr); ++ +
+++Effects: Extracts
+d
fromis
using the format string +fmt
as specified by the +from_stream
formatting flags. The +behavior is undefined except for the following flags (or modified versions of these +flags):%H
,%I
,%M
,%p
, +%r
,%R
,%S
,%T
,%X
, +%n
,%t
,%z
,%Z
or%%
. If +abbrev
is not equal tonullptr
, the information parsed by +%Z
(if present) will be placed in*abbrev
. If +offset
is not equal tonullptr
, the information parsed by +%z
(if present) will be placed in*offset
. +
sys_time
@@ -1710,7 +1759,7 @@ using sys_days = sys_time<days>;+
sys_seconds
is astd::chrono::time_point
using -std::chrono::system_clock
andstd::chrono::seconds
. +std::chrono::system_clock
andstd::chrono::seconds
. This makessys_seconds
interoperable withstd::chrono::system_clock::time_point
. It is simply a count of non-leap seconds since the epoch of @@ -1724,6 +1773,45 @@ using sys_seconds = sys_time<std::chrono::seconds>;+template <class CharT, class Traits, class Duration> +void +to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt, + const sys_time<Duration>& tp); ++ +++ ++Effects: Inserts
+tp
, converted to the +common_type<Duration, seconds>
intoos
using the format +stringfmt
as specified by the +to_stream
formatting flags. If +%Z
is in the formatting string"UTC"
will be used. If +%z
is in the formatting string"+0000"
will be used. ++template <class Duration, class CharT, class Traits, class Alloc = std::allocator<CharT>> +void +from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt, + sys_time<Duration>& tp, std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr, + std::chrono::minutes* offset = nullptr); ++ ++++Effects: Extracts
+tp
fromis
using the format string +fmt
as specified by the +from_stream
formatting flags. +If%z
is present, the parsed offset will be subtracted from the parsed time. +Ifabbrev
is not equal tonullptr
, the information parsed by +%Z
(if present) will be placed in*abbrev
. If +offset
is not equal tonullptr
, the information parsed by +%z
(if present) will be placed in*offset
. +
local_time
@@ -1778,6 +1866,51 @@ using local_seconds = local_time<std::chrono::seconds>;++template <class CharT, class Traits, class Duration> +void +to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt, + const local_time<Duration>& tp, const std::string* abbrev = nullptr, + const std::chrono::seconds* offset_sec = nullptr); ++ +++ ++Effects: Inserts
+ +tp
, converted to the +common_type<Duration, seconds>
intoos
using the format +stringfmt
as specified by the +to_stream
formatting flags. If +%Z
is in the formatting string*abbrev
will be used. If +%z
is in the formatting string*offset_sec
will be used. ++Throws: A
+std::runtime_error
if%Z
is in the formatting +string andabbrev == nullptr
, or if%z
is in the formatting string +andoffset_sec == nullptr
. ++template <class Duration, class CharT, class Traits, class Alloc = std::allocator<CharT>> +void +from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt, + local_time<Duration>& tp, std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr, + std::chrono::minutes* offset = nullptr); ++ ++++Effects: Extracts
+tp
fromis
using the format string +fmt
as specified by the +from_stream
formatting flags. +Ifabbrev
is not equal tonullptr
, the information parsed by +%Z
(if present) will be placed in*abbrev
. If +offset
is not equal tonullptr
, the information parsed by +%z
(if present) will be placed in*offset
. +
last_spec
@@ -1840,6 +1973,17 @@ template<class CharT, class Traits> std::basic_ostream<class CharT, class Traits>& operator<<(std::basic_ostream<class CharT, class Traits>& os, const day& d); +template<class CharT, class Traits> +void +to_stream(std::basic_ostream<class CharT, class Traits>& os, const CharT* fmt, + const day& d); + +template <class CharT, class Traits, class Alloc = std::allocator<CharT>> +void +from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt, day& d, + std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr, + std::chrono::minutes* offset = nullptr); + inline namespace literals { constexpr day operator "" _d(unsigned long long d) noexcept; } @@ -2103,6 +2247,47 @@ operator<<(std::basic_ostream<class CharT, class Traits>& os, co++template<class CharT, class Traits> +void +to_stream(std::basic_ostream<class CharT, class Traits>& os, const CharT* fmt, + const day& d); ++ +++ ++Effects: Inserts
+d
intoos
using the format string +fmt
as specified by the +to_stream
formatting flags. The behavior +is undefined except for the following flags (or modified versions of these flags): +%d
,%e
,%n
,%t
+or%%
. ++template <class CharT, class Traits, class Alloc = std::allocator<CharT>> +void +from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt, day& d, + std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr, + std::chrono::minutes* offset = nullptr); ++ ++++Effects: Extracts
+d
fromis
using the format string +fmt
as specified by the +from_stream
formatting flags. The +behavior is undefined except for the following flags (or modified versions of these +flags):%e
,%e
,%n
, +%t
,%z
,%Z
or%%
. If +abbrev
is not equal tonullptr
, the information parsed by +%Z
(if present) will be placed in*abbrev
. If +offset
is not equal tonullptr
, the information parsed by +%z
(if present) will be placed in*offset
. +
month
asctime
. Otherwise outputs
++template<class CharT, class Traits> +void +to_stream(std::basic_ostream<class CharT, class Traits>& os, const CharT* fmt, + const month& m); ++ +
++ ++Effects: Inserts
+m
intoos
using the format string +fmt
as specified by the +to_stream
formatting flags. The behavior +is undefined except for the following flags (or modified versions of these flags): +%b
,%B
,%h
,%m
,%n
, +%t
or%%
. +
+template <class CharT, class Traits, class Alloc = std::allocator<CharT>> +void +from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt, month& m, + std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr, + std::chrono::minutes* offset = nullptr); ++ +
+++Effects: Extracts
+m
fromis
using the format string +fmt
as specified by the +from_stream
formatting flags. The +behavior is undefined except for the following flags (or modified versions of these +flags):%b
,%B
,%h
,%m
, +%n
,%t
,%z
,%Z
or%%
. If +abbrev
is not equal tonullptr
, the information parsed by +%Z
(if present) will be placed in*abbrev
. If +offset
is not equal tonullptr
, the information parsed by +%z
(if present) will be placed in*offset
. +
year
os
. If the year is less than four decimal digits, pads the yea
++template<class CharT, class Traits> +void +to_stream(std::basic_ostream<class CharT, class Traits>& os, const CharT* fmt, + const year& y); ++ +
++ ++Effects: Inserts
+y
intoos
using the format string +fmt
as specified by the +to_stream
formatting flags. The behavior +is undefined except for the following flags (or modified versions of these flags): +%C
,%y
,%Y
,%n
,%t
+or%%
. +
+template <class CharT, class Traits, class Alloc = std::allocator<CharT>> +void +from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt, year& y, + std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr, + std::chrono::minutes* offset = nullptr); ++ +
+++Effects: Extracts
+y
fromis
using the format string +fmt
as specified by the +from_stream
formatting flags. The +behavior is undefined except for the following flags (or modified versions of these +flags):%C
,%y
,%Y
,%n
, +%t
,%z
,%Z
or%%
. If +abbrev
is not equal tonullptr
, the information parsed by +%Z
(if present) will be placed in*abbrev
. If +offset
is not equal tonullptr
, the information parsed by +%z
(if present) will be placed in*offset
. +
weekday
weekday
represents a day of the week in the Gregorian calendar. It should
-only be representing values in the range 0 to 6, corresponding to Sunday thru Saturday.
+only be representing values in the range 0 to 6, corresponding to Sunday thru Saturday.
However it may hold values outside this range. It can be constructed with any
unsigned
value, which will be subsequently truncated to fit into
weekday
's internal storage. weekday
is equality comparable.
@@ -3159,6 +3459,47 @@ output for the weekday field by asctime
. Otherwise outputs
+template<class CharT, class Traits> +void +to_stream(std::basic_ostream<class CharT, class Traits>& os, const CharT* fmt, + const weekday& wd); ++ +
++ ++Effects: Inserts
+wd
intoos
using the format string +fmt
as specified by the +to_stream
formatting flags. The behavior +is undefined except for the following flags (or modified versions of these flags): +%a
,%A
,%u
,%w
,%n
, +%t
or%%
. +
+template <class CharT, class Traits, class Alloc = std::allocator<CharT>> +void +from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt, weekday& wd, + std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr, + std::chrono::minutes* offset = nullptr); ++ +
+++Effects: Extracts
+wd
fromis
using the format string +fmt
as specified by the +from_stream
formatting flags. The +behavior is undefined except for the following flags (or modified versions of these +flags):%a
,%A
,%u
,%w
,%n
, +%t
,%z
,%Z
or%%
. If +abbrev
is not equal tonullptr
, the information parsed by +%Z
(if present) will be placed in*abbrev
. If +offset
is not equal tonullptr
, the information parsed by +%z
(if present) will be placed in*offset
. +
weekday_indexed
Overview
-weekday_last
represents the last weekday
of a month.
+weekday_last
represents the last weekday
of a month.
It is most easily constructed by indexing a weekday
with last
.
Overview
@@ -3591,6 +3943,48 @@ operator<<(std::basic_ostream<class CharT, class Traits>& os, co ++template<class CharT, class Traits> +void +to_stream(std::basic_ostream<class CharT, class Traits>& os, const CharT* fmt, + const month_day& md); ++ +
++ ++Effects: Inserts
+md
intoos
using the format string +fmt
as specified by the +to_stream
formatting flags. The behavior +is undefined except for the following flags (or modified versions of these flags): +%b
,%B
,%d
,%e
,%h
, +%m
,%n
,%t
or%%
. +
+template <class CharT, class Traits, class Alloc = std::allocator<CharT>> +void +from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt, month_day& md, + std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr, + std::chrono::minutes* offset = nullptr); ++ +
+++Effects: Extracts
+md
fromis
using the format string +fmt
as specified by the +from_stream
formatting flags. The +behavior is undefined except for the following flags (or modified versions of these +flags):%b
,%B
,%d
,%e
, +%h
,%m
,%n
,%t
,%z
, +%Z
or%%
. Ifabbrev
is not equal to +nullptr
, the information parsed by%Z
(if present) will be +placed in*abbrev
. Ifoffset
is not equal to +nullptr
, the information parsed by%z
(if present) will be +placed in*offset
. +
month_day_last
Overview
@@ -4316,6 +4721,48 @@ operator<<(std::basic_ostream<class CharT, class Traits>& os, co ++template<class CharT, class Traits> +void +to_stream(std::basic_ostream<class CharT, class Traits>& os, const CharT* fmt, + const year_month& ym); ++ +
++ ++Effects: Inserts
+ym
intoos
using the format string +fmt
as specified by the +to_stream
formatting flags. The behavior +is undefined except for the following flags (or modified versions of these flags): +%b
,%B
,%C
,%h
,%m
, +%y
,%Y
,%n
,%t
or%%
. +
+template <class CharT, class Traits, class Alloc = std::allocator<CharT>> +void +from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt, year_month& ym, + std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr, + std::chrono::minutes* offset = nullptr); ++ +
+++Effects: Extracts
+ym
fromis
using the format string +fmt
as specified by the +from_stream
formatting flags. The +behavior is undefined except for the following flags (or modified versions of these +flags):%b
,%B
,%C
,%h
, +%m
,%y
,%Y
,%n
,%t
, +%z
,%Z
or%%
. Ifabbrev
is not equal +tonullptr
, the information parsed by%Z
(if present) will be +placed in*abbrev
. Ifoffset
is not equal to +nullptr
, the information parsed by%z
(if present) will be +placed in*offset
. +
year_month_day
Overview
@@ -4378,7 +4836,7 @@ andday
. year_month_day
is a field-based time point w
resolution of days
. One can observe each field. year_month_day
supports years
and months
oriented arithmetic, but not
days
oriented arithmetic. For the latter, there is a conversion to
-sys_days
which efficiently supports days
oriented arithmetic.
+sys_days
which efficiently supports days
oriented arithmetic.
There is also a conversion from sys_days
.
year_month_day
is equality and less-than comparable.
@@ -4736,6 +5194,45 @@ are prefixed with '0'
if necessary..
++template<class CharT, class Traits> +void +to_stream(std::basic_ostream<class CharT, class Traits>& os, const CharT* fmt, + const year_month_day& ymd); ++ +
++ ++Effects: Inserts
+ymd
intoos
using the format string +fmt
as specified by the +to_stream
formatting flags. ++Throws: A
+std::runtime_error
if%z
or%Z
is +used in thefmt
string. +
+template <class CharT, class Traits, class Alloc = std::allocator<CharT>> +void +from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt, year_month_day& ymd, + std::basic_string<CharT, Traits, Alloc>* abbrev = nullptr, + std::chrono::minutes* offset = nullptr); ++ +
+++Effects: Extracts
+ymd
fromis
using the format string +fmt
as specified by the +from_stream
formatting flags. If +abbrev
is not equal tonullptr
, the information parsed by +%Z
(if present) will be placed in*abbrev
. If +offset
is not equal tonullptr
, the information parsed by +%z
(if present) will be placed in*offset
. +
year_month_day_last
year_month_weekday
represents a specific year
,
-month
, and nth weekday
of the month
.
+month
, and nth weekday
of the month
.
year_month_weekday
is a field-based time point with a resolution of
days
. One can observe each field. year_month_weekday
supports
years
and months
oriented arithmetic, but not days
oriented arithmetic. For the latter, there is a conversion to sys_days
which
-efficiently supports days
oriented arithmetic.
+efficiently supports days
oriented arithmetic.
year_month_weekday
is equality comparable.
Period < 1s
.
-constexpr +constexpr time_of_day<std::chrono::duration<Rep, Period>>::time_of_day() noexcept;@@ -6836,7 +7333,7 @@ corresponding to 0 fractional seconds after 00:00:00.
-constexpr explicit +constexpr explicit time_of_day<std::chrono::duration<Rep, Period>>::time_of_day(std::chrono::duration<Rep, Period> since_midnight) noexcept;@@ -7037,5 +7534,778 @@ os << year_month_day(floor<days>(tp)); +
to_stream
formatting
+Each flag begins with a %
. Some flags can be modified by E
or
+O
. During streaming each flag is replaced according to the table below. All
+characters in the format string which are not represented in the table below are inserted
+unchanged into the stream.
+
++ ++ +
++ + ++ %a
The locale's abbreviated weekday name. ++ + ++ %A
The locale's full weekday name. ++ + ++ %b
The locale's abbreviated month name. ++ + ++ %B
The locale's full month name. ++ + ++ %c
The locale's date and time representation. The modified command +%Ec
+produces the locale's alternate date and time representation.+ + ++ %C
The year divided by 100 using floored division. If the result is a single decimal +digit, it is prefixed with +0
. The modified command%EC
+produces the locale's alternative representation of the century.+ + ++ %d
The day of month as a decimal number. If the result is a single decimal +digit, it is prefixed with +0
. The modified command%Od
+produces the locale's alternative representation.+ + ++ %D
Equivalent to +%m/%d/%y
.+ + ++ %e
The day of month as a decimal number. If the result is a single decimal +digit, it is prefixed with a space. The modified command +%Oe
+produces the locale's alternative representation.+ + ++ %F
Equivalent to +%Y-%m-%d
.+ + ++ %g
The last two decimal digits of the ISO week-based year. If the result is a single +digit it is prefixed by +0
.+ + ++ %G
The ISO week-based year as a decimal number. If the result is less than four +digits it is left-padded with +0
to four digits.+ + ++ %h
Equivalent to +%b
.+ + ++ %H
The hour (24-hour clock) as a decimal number. If the result is a single +digit, it is prefixed with +0
. The modified command%OH
+produces the locale's alternative representation.+ + ++ %I
The hour (12-hour clock) as a decimal number. If the result is a single +digit, it is prefixed with +0
. The modified command%OI
+produces the locale's alternative representation.+ + ++ %j
The day of the year as a decimal number. Jan 1 is +001
. If the result +is less than three digits, it is left-padded with0
to three digits.+ + ++ %m
The month as a decimal number. Jan is +01
. If the result is a single +digit, it is prefixed with0
. The modified command%Om
+produces the locale's alternative representation.+ + ++ %M
The minute as a decimal number. If the result is a single +digit, it is prefixed with +0
. The modified command%OM
+produces the locale's alternative representation.+ + ++ %n
A newline character. ++ + ++ %p
The locale's equivalent of the AM/PM designations associated with a 12-hour +clock. ++ + ++ %r
The locale's 12-hour clock time. ++ + ++ %R
Equivalent to +%H:%M
.+ + ++ %S
Seconds as a decimal number. If the number of seconds is less than 10, the result is +prefixed with +0
. If the precision of the input can not be exactly +represented with seconds, then the format is a decimal floating point number with a fixed +format and a precision matching that of the precision of the input (or to a microseconds +precision if the conversion to floating point decimal seconds can not be made within 18 +fractional digits). The character for the decimal point is localized according to the +locale. The modified command%OS
produces the locale's alternative +representation.+ + ++ %t
A horizontal-tab character. ++ + ++ %T
Equivalent to +%H:%M:%S
.+ + ++ %u
The ISO weekday as a decimal number (1-7), where Monday is 1. The modified command + +%Ou
produces the locale's alternative representation.+ + ++ %U
The week number of the year as a decimal number. The first Sunday of the year is the +first day of week +01
. Days of the same year prior to that are in week +00
. If the result is a single digit, it is prefixed with0
. +The modified command%OU
produces the locale's alternative +representation.+ + ++ %V
The ISO week-based week number as a decimal number. If the result is a single digit, +it is prefixed with +0
. The modified command%OV
produces the +locale's alternative representation.+ + ++ %w
The weekday as a decimal number (0-6), where Sunday is 0. The modified command + +%Ow
produces the locale's alternative representation.+ + ++ %W
The week number of the year as a decimal number. The first Monday of the year is the +first day of week +01
. Days of the same year prior to that are in week +00
. If the result is a single digit, it is prefixed with0
. The +modified command%OW
produces the locale's alternative representation.+ + ++ %x
The locale's date representation. The modified command +%Ex
+produces the locale's alternate date representation.+ + ++ %X
The locale's time representation. The modified command +%Ex
+produces the locale's alternate time representation.+ + ++ %y
The last two decimal digits of the year. If the result is a single digit it is +prefixed by +0
.+ + ++ %Y
The year as a decimal number. If the result is less than four digits it is +left-padded with +0
to four digits.+ + ++ %z
The offset from UTC in the ISO 8601 format. For example +-0430
refers to +4 hours 30 minutes behind UTC. If the offset is zero,+0000
is used. +The modified commands%Ez
and%Ez
insert a:
+between the hours and minutes:-04:30
. Astd::runtime_error
is +thrown if the offset information is not available.+ + ++ %Z
The time zone abbreviation. A +std::runtime_error
is thrown if the time +zone abbreviation is not available.UTC
is used for +sys_time
.+ + ++ %%
A +%
character.
format
+template <class CharT, class Streamable> +std::basic_string<CharT> +format(const std::locale& loc, const CharT* fmt, const Streamable& tp); ++ +
++ ++Remarks: This function does not participate in overload resolution unless +
+to_stream(std::declval<std::basic_ostream<CharT>&>(), fmt, tp)
+is valid. ++Effects: Constructs a
+std::basic_ostringstream<CharT> os
and +imbues it withloc
. Callsto_stream(os, fmt, tp)
. ++Returns:
+os.str()
. +
+template <class CharT, class Streamable> +std::basic_string<CharT> +format(const CharT* fmt, const Streamable& tp); ++ +
++ ++Remarks: This function does not participate in overload resolution unless +
+to_stream(std::declval<std::basic_ostream<CharT>&>(), fmt, tp)
+is valid. ++Effects: Constructs a
+std::basic_ostringstream<CharT> os
. +Callsto_stream(os, fmt, tp)
. ++Returns:
+os.str()
. +
+template <class CharT, class Traits, class Streamable> +std::basic_string<CharT> +format(const std::locale& loc, const std::basic_string<CharT, Traits>& fmt, const Streamable& tp); ++ +
++ ++Remarks: This function does not participate in overload resolution unless +
+to_stream(std::declval<std::basic_ostream<CharT>&>(), fmt.c_str(), tp)
+is valid. ++Effects: Constructs a
+std::basic_ostringstream<CharT> os
and +imbues it withloc
. Callsto_stream(os, fmt.c_str(), tp)
. ++Returns:
+os.str()
. +
+template <class CharT, class Traits, class Streamable> +std::basic_string<CharT> +format(const std::basic_string<CharT, Traits>& fmt, const Streamable& tp); ++ +
++ ++Remarks: This function does not participate in overload resolution unless +
+to_stream(std::declval<std::basic_ostream<CharT>&>(), fmt.c_str(), tp)
+is valid. ++Effects: Constructs a
+std::basic_ostringstream<CharT> os
. +Callsto_stream(os, fmt.c_str(), tp)
. ++Returns:
+os.str()
. +
from_stream
formatting
+Each flag begins with a %
. Some flags can be modified by E
or
+O
. During parsing each flag interprets characters as parts of date and time
+type according to the table below. Some flags can be modified by a width parameter which
+governs how many characters are parsed from the stream in interpreting the flag. All
+characters in the format string which are not represented in the table below are parsed
+unchanged from the stream. The C++ specification says that the parsing of month and
+weekday names is both locale sensitive and case insensitive. If you find this not
+to be the case, file a bug with your std::lib vendor.
+
++ ++ +
++ + ++ %a
The locale's full or abbreviated case-insensitive weekday name. ++ + ++ %A
Equivalent to +%a
.+ + ++ %b
The locale's full or abbreviated case-insensitive month name. ++ + ++ %B
Equivalent to +%b
.+ + ++ %c
The locale's date and time representation. The modified command +%Ec
+interprets the locale's alternate date and time representation.+ + ++ %C
The century as a decimal number. The modified command +%NC
where +N
is a positive decimal integer specifies the maximum number of characters to +read. If not specified, the default is 2. Leading zeroes are permitted but not required. +The modified commands%EC
and%OC
interpret the locale's +alternative representation of the century.+ + ++ %d
The day of the month as a decimal number. The modified command +%Nd
where +N
is a positive decimal integer specifies the maximum number of characters to +read. If not specified, the default is 2. Leading zeroes are permitted but not required. +The modified command%EC
interprets the locale's alternative representation +of the day of the month.+ + ++ %D
Equivalent to +%m/%d/%y
.+ + ++ %e
Equivalent to +%d
and can be modified like%d
.+ + ++ %F
Equivalent to +%Y-%m-%d
. If modified with a width, the width is applied +to only%Y
.+ + ++ %g
The last two decimal digits of the ISO week-based year. The modified command + +%Ng
whereN
is a positive decimal integer specifies the maximum +number of characters to read. If not specified, the default is 2. Leading zeroes are +permitted but not required.+ + ++ %G
The ISO week-based year as a decimal number. The modified command +%NG
+whereN
is a positive decimal integer specifies the maximum number of +characters to read. If not specified, the default is 4. Leading zeroes are permitted +but not required.+ + ++ %h
Equivalent to +%b
.+ + ++ %H
The hour (24-hour clock) as a decimal number. The modified command +%NH
+whereN
is a positive decimal integer specifies the maximum number of +characters to read. If not specified, the default is 2. Leading zeroes are permitted +but not required. The modified command%OH
interprets the locale's +alternative representation.+ + ++ %I
The hour (12-hour clock) as a decimal number. The modified command +%NI
+whereN
is a positive decimal integer specifies the maximum number of +characters to read. If not specified, the default is 2. Leading zeroes are permitted +but not required.+ + ++ %j
The day of the year as a decimal number. Jan 1 is +1
. The modified +command%Nj
whereN
is a positive decimal integer specifies the +maximum number of characters to read. If not specified, the default is 3. Leading zeroes +are permitted but not required.+ + ++ %m
The month as a decimal number. Jan is +1
. The modified command +%Nm
whereN
is a positive decimal integer specifies the maximum +number of characters to read. If not specified, the default is 2. Leading zeroes are +permitted but not required. The modified command%Om
interprets the locale's +alternative representation.+ + ++ %M
The minutes as a decimal number. The modified command + +%NM
whereN
is a positive decimal integer specifies the maximum +number of characters to read. If not specified, the default is 2. Leading zeroes are +permitted but not required. The modified command%OM
interprets the locale's +alternative representation.+ + ++ %n
Matches one or more white space characters. Consecutive +%n
and +%t
act as a single%n
.+ + ++ %p
The locale's equivalent of the AM/PM designations associated with a 12-hour clock. +The command +%I
must precede%p
in the format string.+ + ++ %r
The locale's 12-hour clock time. ++ + ++ %R
Equivalent to +%H:%M
.+ + ++ %S
The seconds as a decimal number. The modified command +%NS
where +N
is a positive decimal integer specifies the maximum number of characters to +read. If not specified, the default is 2 if the input time has a precision convertible to +seconds. Otherwise the default width is determined by the decimal precision of the input +and the field is interpreted as a long double in a fixed format. If encountered, the +locale determines the decimal point character. Leading zeroes are permitted but not +required. The modified command%OS
interprets the locale's alternative +representation.+ + ++ %t
Equivalent to +%n
.+ + ++ %T
Equivalent to +%H:%M:%S
.+ + ++ %u
The ISO weekday as a decimal number (1-7), where Monday is 1. The modified command + +%Nu
whereN
is a positive decimal integer specifies the maximum +number of characters to read. If not specified, the default is 1. Leading zeroes are +permitted but not required. The modified command%Ou
interprets the locale's +alternative representation.+ + ++ %U
The week number of the year as a decimal number. The first Sunday of the year is the +first day of week +01
. Days of the same year prior to that are in week +00
. The modified command%NU
whereN
is a +positive decimal integer specifies the maximum number of characters to read. If not +specified, the default is 2. Leading zeroes are permitted but not required.+ + ++ %V
The ISO week-based week number as a decimal number. The modified command + +%NV
whereN
is a positive decimal integer specifies the maximum +number of characters to read. If not specified, the default is 2. Leading zeroes are +permitted but not required.+ + ++ %w
The weekday as a decimal number (0-6), where Sunday is 0. The modified command + +%Nw
whereN
is a positive decimal integer specifies the maximum +number of characters to read. If not specified, the default is 1. Leading zeroes are +permitted but not required. The modified command%Ou
interprets the locale's +alternative representation.+ + ++ %W
The week number of the year as a decimal number. The first Monday of the year is the +first day of week +01
. Days of the same year prior to that are in week +00
. The modified command%NW
whereN
is a positive +decimal integer specifies the maximum number of characters to read. If not specified, the +default is 2. Leading zeroes are permitted but not required.+ + ++ %x
The locale's date representation. The modified command +%Ex
+produces the locale's alternate date representation.+ + ++ %X
The locale's time representation. The modified command +%Ex
+produces the locale's alternate time representation.+ + ++ %y
The last two decimal digits of the year. The modified command +%Ny
where +N
is a positive decimal integer specifies the maximum number of characters to +read. If not specified, the default is 2. Leading zeroes are permitted but not required. +The modified commands%Ey
and%Oy
interpret the locale's +alternative representation.+ + ++ %Y
The year as a decimal number. The modified command +%NY
where +N
is a positive decimal integer specifies the maximum number of characters to +read. If not specified, the default is 4. Leading zeroes are permitted but not required. +The modified command%EY
interprets the locale's alternative +representation.+ + ++ %z
The offset from UTC in the ISO 8601 format. For example +-0430
refers to +4 hours 30 minutes behind UTC. The modified commands%Ez
and%Ez
+parse a:
between the hours and minutes and leading zeroes on the hour field +are optional:-4:30
.+ + ++ %Z
The time zone abbreviation. A single word is read as specified by the extraction +operator for +std::basic_string
.+ + ++ %%
A +%
character is extracted.
parse
+template <class Parsable, class CharT, class Traits, class Alloc> +unspecified +parse(const std::basic_string<CharT, Traits, Alloc>& format, Parsable& tp); ++ +
++ ++Remarks: This function does not participate in overload resolution unless +
+from_stream(std::declval<std::basic_istream<CharT, Traits>&>(), format.c_str(), tp)
+is valid ++Returns: A
+basic_istream<CharT, Traits>
manipulator that on +extraction from abasic_istream<CharT, Traits> is
calls +from_stream(is, format.c_str(), tp)
. +
+template <class Parsable, class CharT, class Traits, class Alloc> +unspecified +parse(const std::basic_string<CharT, Traits, Alloc>& format, Parsable& tp, + std::basic_string<CharT, Traits, Alloc>& abbrev); ++ +
++ ++Remarks: This function does not participate in overload resolution unless +
+from_stream(std::declval<std::basic_istream<CharT, Traits>&>(), format.c_str(), tp, &abbrev)
+is valid ++Returns: A
+basic_istream<CharT, Traits>
manipulator that on +extraction from abasic_istream<CharT, Traits> is
calls +from_stream(is, format.c_str(), tp, &abbrev)
. +
+template <class Parsable, class CharT, class Traits, class Alloc> +unspecified +parse(const std::basic_string<CharT, Traits, Alloc>& format, Parsable& tp, + std::chrono::minutes& offset); ++ +
++ ++Remarks: This function does not participate in overload resolution unless +
+from_stream(std::declval<std::basic_istream<CharT, Traits>&>(), format.c_str(), tp, nullptr, &offset)
+is valid ++Returns: A
+basic_istream<CharT, Traits>
manipulator that on +extraction from abasic_istream<CharT, Traits> is
calls +from_stream(is, format.c_str(), tp, nullptr, &offset)
. +
+template <class Parsable, class CharT, class Traits> +unspecified +parse(const std::basic_string<CharT, Traits>& format, Parsable& tp, + std::basic_string<CharT, Traits>& abbrev, std::chrono::minutes& offset); ++ +
++ ++Remarks: This function does not participate in overload resolution unless +
+from_stream(std::declval<std::basic_istream<CharT, Traits>&>(), format.c_str(), tp, &abbrev, &offset)
+is valid ++Returns: A
+basic_istream<CharT, Traits>
manipulator that on +extraction from abasic_istream<CharT, Traits> is
calls +from_stream(is, format.c_str(), tp, &abbrev, &offset)
. +
+// const CharT* formats + +template <class Parsable, class CharT> +unspecified +parse(const CharT* format, Parsable& tp); ++ +
++ ++Remarks: This function does not participate in overload resolution unless +
+from_stream(std::declval<std::basic_istream<CharT, Traits>&>(), format, tp)
+is valid ++Returns: A
+basic_istream<CharT, Traits>
manipulator that on +extraction from abasic_istream<CharT, Traits> is
calls +from_stream(is, format, tp)
. +
+template <class Parsable, class CharT, class Traits, class Alloc> +unspecified +parse(const CharT* format, Parsable& tp, std::basic_string<CharT, Traits, Alloc>& abbrev); ++ +
++ ++Remarks: This function does not participate in overload resolution unless +
+from_stream(std::declval<std::basic_istream<CharT, Traits>&>(), format, tp, &abbrev)
+is valid ++Returns: A
+basic_istream<CharT, Traits>
manipulator that on +extraction from abasic_istream<CharT, Traits> is
calls +from_stream(is, format, tp, &abbrev)
. +
+template <class Parsable, class CharT> +unspecified +parse(const CharT* format, Parsable& tp, std::chrono::minutes& offset); ++ +
++ ++Remarks: This function does not participate in overload resolution unless +
+from_stream(std::declval<std::basic_istream<CharT, Traits>&>(), format, tp, nullptr, &offset)
+is valid ++Returns: A
+basic_istream<CharT, Traits>
manipulator that on +extraction from abasic_istream<CharT, Traits> is
calls +from_stream(is, format, tp, nullptr, &offset)
. +
+template <class Parsable, class CharT, class Traits, class Alloc> +unspecified +parse(const CharT* format, Parsable& tp, + std::basic_string<CharT, Traits, Alloc>& abbrev, std::chrono::minutes& offset); ++ +
+++Remarks: This function does not participate in overload resolution unless +
+from_stream(std::declval<std::basic_istream<CharT, Traits>&>(), format, tp, &abbrev, &offset)
+is valid ++Returns: A
+basic_istream<CharT, Traits>
manipulator that on +extraction from abasic_istream<CharT, Traits> is
calls +from_stream(is, format, tp, &abbrev, &offset)
. +