585 lines
27 KiB
Markdown
585 lines
27 KiB
Markdown
[category.time]
|
||
|
||
# 28 Text processing library [[text]](./#text)
|
||
|
||
## 28.3 Localization library [[localization]](localization#category.time)
|
||
|
||
### 28.3.4 Standard locale categories [[locale.categories]](locale.categories#category.time)
|
||
|
||
#### 28.3.4.6 The time category [category.time]
|
||
|
||
#### [28.3.4.6.1](#general) General [[category.time.general]](category.time.general)
|
||
|
||
[1](#general-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3512)
|
||
|
||
Templatestime_get<charT, InputIterator> andtime_put<charT, OutputIterator> provide date and time formatting and parsing[.](#general-1.sentence-1)
|
||
|
||
All specifications of member functions for time_put and time_get in the subclauses of [category.time] only apply to the
|
||
specializations required in Tables [91](locale.category#tab:locale.category.facets "Table 91: Locale category facets") and [92](locale.category#tab:locale.spec "Table 92: Required specializations") ([[locale.category]](locale.category "28.3.3.1.2.1 Type locale::category"))[.](#general-1.sentence-2)
|
||
|
||
Their members use theirios_base&, ios_base::iostate&, and fill arguments
|
||
as described in [[locale.categories]](locale.categories "28.3.4 Standard locale categories"),
|
||
and the ctype<> facet,
|
||
to determine formatting details[.](#general-1.sentence-3)
|
||
|
||
#### [28.3.4.6.2](#locale.time.get) Class template time_get [[locale.time.get]](locale.time.get)
|
||
|
||
#### [28.3.4.6.2.1](#locale.time.get.general) General [[locale.time.get.general]](locale.time.get.general)
|
||
|
||
[ð](#lib:time_get)
|
||
|
||
namespace std {class time_base {public:enum dateorder { no_order, dmy, mdy, ymd, ydm }; }; template<class charT, class InputIterator = istreambuf_iterator<charT>>class time_get : public locale::facet, public time_base {public:using char_type = charT; using iter_type = InputIterator; explicit time_get(size_t refs = 0);
|
||
|
||
dateorder date_order() const { return do_date_order(); } iter_type get_time(iter_type s, iter_type end, ios_base& f,
|
||
ios_base::iostate& err, tm* t) const;
|
||
iter_type get_date(iter_type s, iter_type end, ios_base& f,
|
||
ios_base::iostate& err, tm* t) const;
|
||
iter_type get_weekday(iter_type s, iter_type end, ios_base& f,
|
||
ios_base::iostate& err, tm* t) const;
|
||
iter_type get_monthname(iter_type s, iter_type end, ios_base& f,
|
||
ios_base::iostate& err, tm* t) const;
|
||
iter_type get_year(iter_type s, iter_type end, ios_base& f,
|
||
ios_base::iostate& err, tm* t) const;
|
||
iter_type get(iter_type s, iter_type end, ios_base& f,
|
||
ios_base::iostate& err, tm* t, char format, char modifier = 0) const;
|
||
iter_type get(iter_type s, iter_type end, ios_base& f,
|
||
ios_base::iostate& err, tm* t, const char_type* fmt, const char_type* fmtend) const; static locale::id id; protected:~time_get(); virtual dateorder do_date_order() const; virtual iter_type do_get_time(iter_type s, iter_type end, ios_base&,
|
||
ios_base::iostate& err, tm* t) const; virtual iter_type do_get_date(iter_type s, iter_type end, ios_base&,
|
||
ios_base::iostate& err, tm* t) const; virtual iter_type do_get_weekday(iter_type s, iter_type end, ios_base&,
|
||
ios_base::iostate& err, tm* t) const; virtual iter_type do_get_monthname(iter_type s, iter_type end, ios_base&,
|
||
ios_base::iostate& err, tm* t) const; virtual iter_type do_get_year(iter_type s, iter_type end, ios_base&,
|
||
ios_base::iostate& err, tm* t) const; virtual iter_type do_get(iter_type s, iter_type end, ios_base& f,
|
||
ios_base::iostate& err, tm* t, char format, char modifier) const; };}
|
||
|
||
[1](#locale.time.get.general-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3585)
|
||
|
||
time_get is used to parse a character sequence,
|
||
extracting components of a time or date into a tm object[.](#locale.time.get.general-1.sentence-1)
|
||
|
||
Each get member parses a format as produced by a corresponding format specifier totime_put<>::put[.](#locale.time.get.general-1.sentence-2)
|
||
|
||
If the sequence being parsed matches the correct format, the corresponding
|
||
members of thetm argument are set to the values used to produce the sequence; otherwise
|
||
either an error is reported or unspecified values are assigned[.](#locale.time.get.general-1.sentence-3)[227](#footnote-227 "In other words, user confirmation is required for reliable parsing of user-entered dates and times, but machine-generated formats can be parsed reliably. This allows parsers to be aggressive about interpreting user variations on standard formats.")
|
||
|
||
[2](#locale.time.get.general-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3604)
|
||
|
||
If the end iterator is reached during parsing by any of theget() member functions, the member setsios_base::eofbit in err[.](#locale.time.get.general-2.sentence-1)
|
||
|
||
[227)](#footnote-227)[227)](#footnoteref-227)
|
||
|
||
In
|
||
other words, user confirmation is required for reliable parsing of
|
||
user-entered dates and times, but machine-generated formats can be
|
||
parsed reliably[.](#footnote-227.sentence-1)
|
||
|
||
This allows parsers to be aggressive about
|
||
interpreting user variations on standard formats[.](#footnote-227.sentence-2)
|
||
|
||
#### [28.3.4.6.2.2](#locale.time.get.members) Members [[locale.time.get.members]](locale.time.get.members)
|
||
|
||
[ð](#lib:time_get,date_order)
|
||
|
||
`dateorder date_order() const;
|
||
`
|
||
|
||
[1](#locale.time.get.members-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3619)
|
||
|
||
*Returns*: do_date_order()[.](#locale.time.get.members-1.sentence-1)
|
||
|
||
[ð](#lib:time_get,get_time)
|
||
|
||
`iter_type get_time(iter_type s, iter_type end, ios_base& str,
|
||
ios_base::iostate& err, tm* t) const;
|
||
`
|
||
|
||
[2](#locale.time.get.members-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3631)
|
||
|
||
*Returns*: do_get_time(s, end, str, err, t)[.](#locale.time.get.members-2.sentence-1)
|
||
|
||
[ð](#lib:time_get,get_date)
|
||
|
||
`iter_type get_date(iter_type s, iter_type end, ios_base& str,
|
||
ios_base::iostate& err, tm* t) const;
|
||
`
|
||
|
||
[3](#locale.time.get.members-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3643)
|
||
|
||
*Returns*: do_get_date(s, end, str, err, t)[.](#locale.time.get.members-3.sentence-1)
|
||
|
||
[ð](#lib:time_get,get_weekday)
|
||
|
||
`iter_type get_weekday(iter_type s, iter_type end, ios_base& str,
|
||
ios_base::iostate& err, tm* t) const;
|
||
iter_type get_monthname(iter_type s, iter_type end, ios_base& str,
|
||
ios_base::iostate& err, tm* t) const;
|
||
`
|
||
|
||
[4](#locale.time.get.members-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3658)
|
||
|
||
*Returns*: do_get_weekday(s, end, str, err, t) ordo_get_monthname(s, end, str, err, t)[.](#locale.time.get.members-4.sentence-1)
|
||
|
||
[ð](#lib:time_get,get_year)
|
||
|
||
`iter_type get_year(iter_type s, iter_type end, ios_base& str,
|
||
ios_base::iostate& err, tm* t) const;
|
||
`
|
||
|
||
[5](#locale.time.get.members-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3672)
|
||
|
||
*Returns*: do_get_year(s, end, str, err, t)[.](#locale.time.get.members-5.sentence-1)
|
||
|
||
[ð](#lib:get,time_get)
|
||
|
||
`iter_type get(iter_type s, iter_type end, ios_base& f, ios_base::iostate& err,
|
||
tm* t, char format, char modifier = 0) const;
|
||
`
|
||
|
||
[6](#locale.time.get.members-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3684)
|
||
|
||
*Returns*: do_get(s, end, f, err, t, format, modifier)[.](#locale.time.get.members-6.sentence-1)
|
||
|
||
[ð](#lib:get,time_get_)
|
||
|
||
`iter_type get(iter_type s, iter_type end, ios_base& f, ios_base::iostate& err,
|
||
tm* t, const char_type* fmt, const char_type* fmtend) const;
|
||
`
|
||
|
||
[7](#locale.time.get.members-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3696)
|
||
|
||
*Preconditions*: [fmt, fmtend) is a valid range[.](#locale.time.get.members-7.sentence-1)
|
||
|
||
[8](#locale.time.get.members-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3700)
|
||
|
||
*Effects*: The function starts by evaluating err = ios_base::goodbit[.](#locale.time.get.members-8.sentence-1)
|
||
|
||
It then enters a loop,
|
||
reading zero or more characters from s at each iteration[.](#locale.time.get.members-8.sentence-2)
|
||
|
||
Unless otherwise specified below,
|
||
the loop terminates when the first of the following conditions holds:
|
||
|
||
- [(8.1)](#locale.time.get.members-8.1)
|
||
|
||
The expression fmt == fmtend evaluates to true[.](#locale.time.get.members-8.1.sentence-1)
|
||
|
||
- [(8.2)](#locale.time.get.members-8.2)
|
||
|
||
The expression err == ios_base::goodbit evaluates to false[.](#locale.time.get.members-8.2.sentence-1)
|
||
|
||
- [(8.3)](#locale.time.get.members-8.3)
|
||
|
||
The expression s == end evaluates to true,
|
||
in which case
|
||
the function evaluates err = ios_base::eofbit | ios_base::failbit[.](#locale.time.get.members-8.3.sentence-1)
|
||
|
||
- [(8.4)](#locale.time.get.members-8.4)
|
||
|
||
The next element of fmt is equal to '%',
|
||
optionally followed by a modifier character,
|
||
followed by a conversion specifier character, format,
|
||
together forming a conversion specification
|
||
valid for the POSIX function strptime[.](#locale.time.get.members-8.4.sentence-1)
|
||
If the number of elements in the range [fmt, fmtend)
|
||
is not sufficient to unambiguously determine
|
||
whether the conversion specification is complete and valid,
|
||
the function evaluates err = ios_base::failbit[.](#locale.time.get.members-8.4.sentence-2)
|
||
Otherwise,
|
||
the function evaluates s = do_get(s, end, f, err, t, format, modifier),
|
||
where the value of modifier is '\0' when the optional modifier is absent from the conversion specification[.](#locale.time.get.members-8.4.sentence-3)
|
||
If err == ios_base::goodbit holds
|
||
after the evaluation of the expression,
|
||
the function increments fmt to point just past the end of the conversion specification and
|
||
continues looping[.](#locale.time.get.members-8.4.sentence-4)
|
||
|
||
- [(8.5)](#locale.time.get.members-8.5)
|
||
|
||
The expression isspace(*fmt, f.getloc()) evaluates to true,
|
||
in which case the function first increments fmt untilfmt == fmtend || !isspace(*fmt, f.getloc()) evaluates to true,
|
||
then advances s until s == end || !isspace(*s, f.getloc()) is true, and
|
||
finally resumes looping[.](#locale.time.get.members-8.5.sentence-1)
|
||
|
||
- [(8.6)](#locale.time.get.members-8.6)
|
||
|
||
The next character read from s matches the element pointed to by fmt in a case-insensitive comparison,
|
||
in which case the function evaluates ++fmt, ++s and continues looping[.](#locale.time.get.members-8.6.sentence-1)
|
||
Otherwise, the function evaluates err = ios_base::failbit[.](#locale.time.get.members-8.6.sentence-2)
|
||
|
||
[9](#locale.time.get.members-9)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3752)
|
||
|
||
[*Note [1](#locale.time.get.members-note-1)*:
|
||
|
||
The function uses the ctype<charT> facet
|
||
installed in f's locale
|
||
to determine valid whitespace characters[.](#locale.time.get.members-9.sentence-1)
|
||
|
||
It is unspecified
|
||
by what means the function performs case-insensitive comparison or
|
||
whether multi-character sequences are considered while doing so[.](#locale.time.get.members-9.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
[10](#locale.time.get.members-10)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3762)
|
||
|
||
*Returns*: s[.](#locale.time.get.members-10.sentence-1)
|
||
|
||
#### [28.3.4.6.2.3](#locale.time.get.virtuals) Virtual functions [[locale.time.get.virtuals]](locale.time.get.virtuals)
|
||
|
||
[ð](#lib:time_get,do_date_order)
|
||
|
||
`dateorder do_date_order() const;
|
||
`
|
||
|
||
[1](#locale.time.get.virtuals-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3775)
|
||
|
||
*Returns*: An enumeration value indicating the preferred order of components
|
||
for those date formats that are composed of day, month, and year[.](#locale.time.get.virtuals-1.sentence-1)[228](#footnote-228 "This function is intended as a convenience only, for common formats, and can return no_order in valid locales.")
|
||
|
||
Returns no_order if the date format specified by 'x' contains other variable components (e.g., Julian day, week number, week day)[.](#locale.time.get.virtuals-1.sentence-2)
|
||
|
||
[ð](#lib:time_get,do_get_time)
|
||
|
||
`iter_type do_get_time(iter_type s, iter_type end, ios_base& str,
|
||
ios_base::iostate& err, tm* t) const;
|
||
`
|
||
|
||
[2](#locale.time.get.virtuals-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3794)
|
||
|
||
*Effects*: Reads characters starting at s until it has extracted those tm members, and
|
||
remaining format characters,
|
||
used by time_put<>::put to produce the format specified by "%H:%M:%S",
|
||
or until it encounters an error or end of sequence[.](#locale.time.get.virtuals-2.sentence-1)
|
||
|
||
[3](#locale.time.get.virtuals-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3803)
|
||
|
||
*Returns*: An iterator pointing immediately beyond
|
||
the last character recognized as possibly part of a valid time[.](#locale.time.get.virtuals-3.sentence-1)
|
||
|
||
[ð](#lib:time_get,do_get_date)
|
||
|
||
`iter_type do_get_date(iter_type s, iter_type end, ios_base& str,
|
||
ios_base::iostate& err, tm* t) const;
|
||
`
|
||
|
||
[4](#locale.time.get.virtuals-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3816)
|
||
|
||
*Effects*: Reads characters starting at s until it has extracted those tm members and
|
||
remaining format characters
|
||
used by time_put<>::put to produce one of the following formats,
|
||
or until it encounters an error[.](#locale.time.get.virtuals-4.sentence-1)
|
||
|
||
The format depends on the value returned by date_order() as shown in Table [102](#tab:locale.time.get.dogetdate "Table 102: do_get_date effects")[.](#locale.time.get.virtuals-4.sentence-2)
|
||
|
||
Table [102](#tab:locale.time.get.dogetdate) — do_get_date effects [[tab:locale.time.get.dogetdate]](./tab:locale.time.get.dogetdate)
|
||
|
||
| [ð](#tab:locale.time.get.dogetdate-row-1)<br>**date_order()** | **Format** |
|
||
| --- | --- |
|
||
| [ð](#tab:locale.time.get.dogetdate-row-2)<br>no_order | "%m%d%y" |
|
||
| [ð](#tab:locale.time.get.dogetdate-row-3)<br>dmy | "%d%m%y" |
|
||
| [ð](#tab:locale.time.get.dogetdate-row-4)<br>mdy | "%m%d%y" |
|
||
| [ð](#tab:locale.time.get.dogetdate-row-5)<br>ymd | "%y%m%d" |
|
||
| [ð](#tab:locale.time.get.dogetdate-row-6)<br>ydm | "%y%d%m" |
|
||
|
||
[5](#locale.time.get.virtuals-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3836)
|
||
|
||
An implementation may also accept additionalimplementation-defined formats[.](#locale.time.get.virtuals-5.sentence-1)
|
||
|
||
[6](#locale.time.get.virtuals-6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3840)
|
||
|
||
*Returns*: An iterator pointing immediately beyond
|
||
the last character recognized as possibly part of a valid date[.](#locale.time.get.virtuals-6.sentence-1)
|
||
|
||
[ð](#lib:time_get,do_get_weekday)
|
||
|
||
`iter_type do_get_weekday(iter_type s, iter_type end, ios_base& str,
|
||
ios_base::iostate& err, tm* t) const;
|
||
iter_type do_get_monthname(iter_type s, iter_type end, ios_base& str,
|
||
ios_base::iostate& err, tm* t) const;
|
||
`
|
||
|
||
[7](#locale.time.get.virtuals-7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3856)
|
||
|
||
*Effects*: Reads characters starting at s until it has extracted the (perhaps abbreviated) name of a weekday or month[.](#locale.time.get.virtuals-7.sentence-1)
|
||
|
||
If it finds an abbreviation
|
||
that is followed by characters that can match a full name,
|
||
it continues reading until it matches the full name or fails[.](#locale.time.get.virtuals-7.sentence-2)
|
||
|
||
It sets the appropriate tm member accordingly[.](#locale.time.get.virtuals-7.sentence-3)
|
||
|
||
[8](#locale.time.get.virtuals-8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3865)
|
||
|
||
*Returns*: An iterator pointing immediately beyond the last character recognized
|
||
as part of a valid name[.](#locale.time.get.virtuals-8.sentence-1)
|
||
|
||
[ð](#lib:time_get,do_get_year)
|
||
|
||
`iter_type do_get_year(iter_type s, iter_type end, ios_base& str,
|
||
ios_base::iostate& err, tm* t) const;
|
||
`
|
||
|
||
[9](#locale.time.get.virtuals-9)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3878)
|
||
|
||
*Effects*: Reads characters starting at s until it has extracted an unambiguous year identifier[.](#locale.time.get.virtuals-9.sentence-1)
|
||
|
||
It isimplementation-defined
|
||
whether two-digit year numbers are accepted,
|
||
and (if so) what century they are assumed to lie in[.](#locale.time.get.virtuals-9.sentence-2)
|
||
|
||
Sets the t->tm_year member accordingly[.](#locale.time.get.virtuals-9.sentence-3)
|
||
|
||
[10](#locale.time.get.virtuals-10)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3888)
|
||
|
||
*Returns*: An iterator pointing immediately beyond
|
||
the last character recognized as part of a valid year identifier[.](#locale.time.get.virtuals-10.sentence-1)
|
||
|
||
[ð](#lib:do_get,time_get)
|
||
|
||
`iter_type do_get(iter_type s, iter_type end, ios_base& f,
|
||
ios_base::iostate& err, tm* t, char format, char modifier) const;
|
||
`
|
||
|
||
[11](#locale.time.get.virtuals-11)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3901)
|
||
|
||
*Preconditions*: t points to an object[.](#locale.time.get.virtuals-11.sentence-1)
|
||
|
||
[12](#locale.time.get.virtuals-12)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3905)
|
||
|
||
*Effects*: The function starts by evaluating err = ios_base::goodbit[.](#locale.time.get.virtuals-12.sentence-1)
|
||
|
||
It then reads characters starting at s until it encounters an error, or
|
||
until it has extracted and assigned those tm members, and
|
||
any remaining format characters,
|
||
corresponding to a conversion specification appropriate for
|
||
the POSIX function strptime,
|
||
formed by concatenating '%',
|
||
the modifier character, when non-NUL, and
|
||
the format character[.](#locale.time.get.virtuals-12.sentence-2)
|
||
|
||
When the concatenation fails to yield a complete valid directive
|
||
the function leaves the object pointed to by t unchanged and
|
||
evaluates err |= ios_base::failbit[.](#locale.time.get.virtuals-12.sentence-3)
|
||
|
||
When s == end evaluates to true after reading a character
|
||
the function evaluates err |= ios_base::eofbit[.](#locale.time.get.virtuals-12.sentence-4)
|
||
|
||
[13](#locale.time.get.virtuals-13)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3922)
|
||
|
||
For complex conversion specifications
|
||
such as %c, %x, or %X, or
|
||
conversion specifications that involve the optional modifiers E or O,
|
||
when the function is unable to unambiguously determine
|
||
some or all tm members from the input sequence [s, end),
|
||
it evaluates err |= ios_base::eofbit[.](#locale.time.get.virtuals-13.sentence-1)
|
||
|
||
In such cases the values of those tm members are unspecified
|
||
and may be outside their valid range[.](#locale.time.get.virtuals-13.sentence-2)
|
||
|
||
[14](#locale.time.get.virtuals-14)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3932)
|
||
|
||
*Returns*: An iterator pointing immediately beyond
|
||
the last character recognized as possibly part of
|
||
a valid input sequence for the given format and modifier[.](#locale.time.get.virtuals-14.sentence-1)
|
||
|
||
[15](#locale.time.get.virtuals-15)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L3938)
|
||
|
||
*Remarks*: It is unspecified whether multiple calls to do_get() with the address of the same tm object
|
||
will update the current contents of the object or simply overwrite its members[.](#locale.time.get.virtuals-15.sentence-1)
|
||
|
||
Portable programs should zero out the object before invoking the function[.](#locale.time.get.virtuals-15.sentence-2)
|
||
|
||
[228)](#footnote-228)[228)](#footnoteref-228)
|
||
|
||
This function is intended as a convenience only, for common formats, and
|
||
can return no_order in valid locales[.](#footnote-228.sentence-1)
|
||
|
||
#### [28.3.4.6.3](#locale.time.get.byname) Class template time_get_byname [[locale.time.get.byname]](locale.time.get.byname)
|
||
|
||
[ð](#lib:time_get_byname)
|
||
|
||
namespace std {template<class charT, class InputIterator = istreambuf_iterator<charT>>class time_get_byname : public time_get<charT, InputIterator> {public:using dateorder = time_base::dateorder; using iter_type = InputIterator; explicit time_get_byname(const char*, size_t refs = 0); explicit time_get_byname(const string&, size_t refs = 0); protected:~time_get_byname(); };}
|
||
|
||
#### [28.3.4.6.4](#locale.time.put) Class template time_put [[locale.time.put]](locale.time.put)
|
||
|
||
#### [28.3.4.6.4.1](#locale.time.put.general) General [[locale.time.put.general]](locale.time.put.general)
|
||
|
||
[ð](#lib:time_put)
|
||
|
||
namespace std {template<class charT, class OutputIterator = ostreambuf_iterator<charT>>class time_put : public locale::facet {public:using char_type = charT; using iter_type = OutputIterator; explicit time_put(size_t refs = 0); // the following is implemented in terms of other member functions. iter_type put(iter_type s, ios_base& f, char_type fill, const tm* tmb, const charT* pattern, const charT* pat_end) const;
|
||
iter_type put(iter_type s, ios_base& f, char_type fill, const tm* tmb, char format, char modifier = 0) const; static locale::id id; protected:~time_put(); virtual iter_type do_put(iter_type s, ios_base&, char_type, const tm* t, char format, char modifier) const; };}
|
||
|
||
#### [28.3.4.6.4.2](#locale.time.put.members) Members [[locale.time.put.members]](locale.time.put.members)
|
||
|
||
[ð](#lib:time_put,put)
|
||
|
||
`iter_type put(iter_type s, ios_base& str, char_type fill, const tm* t,
|
||
const charT* pattern, const charT* pat_end) const;
|
||
iter_type put(iter_type s, ios_base& str, char_type fill, const tm* t,
|
||
char format, char modifier = 0) const;
|
||
`
|
||
|
||
[1](#locale.time.put.members-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4008)
|
||
|
||
*Effects*: The first form steps through the sequence
|
||
from pattern to pat_end,
|
||
identifying characters that are part of a format sequence[.](#locale.time.put.members-1.sentence-1)
|
||
|
||
Each character that is not part of a format sequence
|
||
is written to s immediately, and
|
||
each format sequence, as it is identified, results in a call to do_put;
|
||
thus, format elements and other characters are interleaved in the output
|
||
in the order in which they appear in the pattern[.](#locale.time.put.members-1.sentence-2)
|
||
|
||
Format sequences are identified by converting each character c to
|
||
a char value as if by ct.narrow(c, 0),
|
||
where ct is a reference to ctype<charT> obtained from str.getloc()[.](#locale.time.put.members-1.sentence-3)
|
||
|
||
The first character of each sequence is equal to '%',
|
||
followed by an optional modifier character mod and a format specifier character spec as defined for the function strftime[.](#locale.time.put.members-1.sentence-4)
|
||
|
||
If no modifier character is present, mod is zero[.](#locale.time.put.members-1.sentence-5)
|
||
|
||
For each valid format sequence identified,
|
||
calls do_put(s, str, fill, t, spec, mod)[.](#locale.time.put.members-1.sentence-6)
|
||
|
||
[2](#locale.time.put.members-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4030)
|
||
|
||
The second form calls do_put(s, str, fill, t, format, modifier)[.](#locale.time.put.members-2.sentence-1)
|
||
|
||
[3](#locale.time.put.members-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4033)
|
||
|
||
[*Note [1](#locale.time.put.members-note-1)*:
|
||
|
||
The fill argument can be used
|
||
in the implementation-defined formats or by derivations[.](#locale.time.put.members-3.sentence-1)
|
||
|
||
A space character is a reasonable default for this argument[.](#locale.time.put.members-3.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
[4](#locale.time.put.members-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4040)
|
||
|
||
*Returns*: An iterator pointing immediately after the last character produced[.](#locale.time.put.members-4.sentence-1)
|
||
|
||
#### [28.3.4.6.4.3](#locale.time.put.virtuals) Virtual functions [[locale.time.put.virtuals]](locale.time.put.virtuals)
|
||
|
||
[ð](#lib:time_put,do_put)
|
||
|
||
`iter_type do_put(iter_type s, ios_base&, char_type fill, const tm* t,
|
||
char format, char modifier) const;
|
||
`
|
||
|
||
[1](#locale.time.put.virtuals-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4054)
|
||
|
||
*Effects*: Formats the contents of the parameter t into characters placed on the output sequence s[.](#locale.time.put.virtuals-1.sentence-1)
|
||
|
||
Formatting is controlled by the parameters format and modifier,
|
||
interpreted identically as the format specifiers
|
||
in the string argument to the standard library functionstrftime(),
|
||
except that the sequence of characters produced for those specifiers
|
||
that are described as depending on the C locale
|
||
are insteadimplementation-defined[.](#locale.time.put.virtuals-1.sentence-2)
|
||
|
||
[*Note [1](#locale.time.put.virtuals-note-1)*:
|
||
|
||
Interpretation of the modifier argument is implementation-defined[.](#locale.time.put.virtuals-1.sentence-3)
|
||
|
||
â *end note*]
|
||
|
||
[2](#locale.time.put.virtuals-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4072)
|
||
|
||
*Returns*: An iterator pointing immediately after the last character produced[.](#locale.time.put.virtuals-2.sentence-1)
|
||
|
||
[*Note [2](#locale.time.put.virtuals-note-2)*:
|
||
|
||
The fill argument can be used
|
||
in the implementation-defined formats or by derivations[.](#locale.time.put.virtuals-2.sentence-2)
|
||
|
||
A space character is a reasonable default for this argument[.](#locale.time.put.virtuals-2.sentence-3)
|
||
|
||
â *end note*]
|
||
|
||
[3](#locale.time.put.virtuals-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L4081)
|
||
|
||
*Recommended practice*: Interpretation of the modifier should follow POSIX conventions[.](#locale.time.put.virtuals-3.sentence-1)
|
||
|
||
Implementations should refer to other standards such as POSIX
|
||
for a specification of the character sequences produced for
|
||
those specifiers described as depending on the C locale[.](#locale.time.put.virtuals-3.sentence-2)
|
||
|
||
#### [28.3.4.6.5](#locale.time.put.byname) Class template time_put_byname [[locale.time.put.byname]](locale.time.put.byname)
|
||
|
||
[ð](#lib:time_put_byname)
|
||
|
||
namespace std {template<class charT, class OutputIterator = ostreambuf_iterator<charT>>class time_put_byname : public time_put<charT, OutputIterator> {public:using char_type = charT; using iter_type = OutputIterator; explicit time_put_byname(const char*, size_t refs = 0); explicit time_put_byname(const string&, size_t refs = 0); protected:~time_put_byname(); };}
|