tmp/tmpbp1zv8cm/{from.md → to.md}
RENAMED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
### The time category <a id="category.time">[[category.time]]</a>
|
| 2 |
|
|
|
|
|
|
|
| 3 |
Templates `time_get<charT, InputIterator>` and
|
| 4 |
`time_put<charT, OutputIterator>` provide date and time formatting and
|
| 5 |
parsing. All specifications of member functions for `time_put` and
|
| 6 |
`time_get` in the subclauses of [[category.time]] only apply to the
|
| 7 |
specializations required in Tables [[tab:locale.category.facets]] and
|
|
@@ -10,10 +12,12 @@ specializations required in Tables [[tab:locale.category.facets]] and
|
|
| 10 |
[[locale.categories]], and the `ctype<>` facet, to determine formatting
|
| 11 |
details.
|
| 12 |
|
| 13 |
#### Class template `time_get` <a id="locale.time.get">[[locale.time.get]]</a>
|
| 14 |
|
|
|
|
|
|
|
| 15 |
``` cpp
|
| 16 |
namespace std {
|
| 17 |
class time_base {
|
| 18 |
public:
|
| 19 |
enum dateorder { no_order, dmy, mdy, ymd, ydm };
|
|
@@ -63,19 +67,17 @@ namespace std {
|
|
| 63 |
ios_base::iostate& err, tm* t, char format, char modifier) const;
|
| 64 |
};
|
| 65 |
}
|
| 66 |
```
|
| 67 |
|
| 68 |
-
`time_get`
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
or date into a `struct tm` object. Each `get` member parses a format as
|
| 72 |
-
produced by a corresponding format specifier to `time_put<>::put`. If
|
| 73 |
the sequence being parsed matches the correct format, the corresponding
|
| 74 |
-
members of the `
|
| 75 |
-
|
| 76 |
-
|
| 77 |
|
| 78 |
If the end iterator is reached during parsing by any of the `get()`
|
| 79 |
member functions, the member sets `ios_base::eofbit` in `err`.
|
| 80 |
|
| 81 |
##### Members <a id="locale.time.get.members">[[locale.time.get.members]]</a>
|
|
@@ -141,12 +143,12 @@ the first of the following conditions holds:
|
|
| 141 |
- The expression `s == end` evaluates to `true`, in which case the
|
| 142 |
function evaluates `err = ios_base::eofbit | ios_base::failbit`.
|
| 143 |
- The next element of `fmt` is equal to `’%’`, optionally followed by a
|
| 144 |
modifier character, followed by a conversion specifier character,
|
| 145 |
`format`, together forming a conversion specification valid for the
|
| 146 |
-
|
| 147 |
-
|
| 148 |
whether the conversion specification is complete and valid, the
|
| 149 |
function evaluates `err = ios_base::failbit`. Otherwise, the function
|
| 150 |
evaluates `s = do_get(s, end, f, err, t, format, modifier)`, where the
|
| 151 |
value of `modifier` is `’\0’` when the optional modifier is absent
|
| 152 |
from the conversion specification. If `err == ios_base::goodbit` holds
|
|
@@ -177,37 +179,38 @@ so. — *end note*]
|
|
| 177 |
dateorder do_date_order() const;
|
| 178 |
```
|
| 179 |
|
| 180 |
*Returns:* An enumeration value indicating the preferred order of
|
| 181 |
components for those date formats that are composed of day, month, and
|
| 182 |
-
year.[^16]
|
| 183 |
-
|
| 184 |
-
|
|
|
|
| 185 |
|
| 186 |
``` cpp
|
| 187 |
iter_type do_get_time(iter_type s, iter_type end, ios_base& str,
|
| 188 |
ios_base::iostate& err, tm* t) const;
|
| 189 |
```
|
| 190 |
|
| 191 |
*Effects:* Reads characters starting at `s` until it has extracted those
|
| 192 |
-
`
|
| 193 |
-
|
| 194 |
-
|
| 195 |
|
| 196 |
*Returns:* An iterator pointing immediately beyond the last character
|
| 197 |
recognized as possibly part of a valid time.
|
| 198 |
|
| 199 |
``` cpp
|
| 200 |
iter_type do_get_date(iter_type s, iter_type end, ios_base& str,
|
| 201 |
ios_base::iostate& err, tm* t) const;
|
| 202 |
```
|
| 203 |
|
| 204 |
*Effects:* Reads characters starting at `s` until it has extracted those
|
| 205 |
-
`
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
|
| 210 |
**Table: `do_get_date` effects** <a id="locale.time.get.dogetdate">[locale.time.get.dogetdate]</a>
|
| 211 |
|
| 212 |
| `date_order()` | Format |
|
| 213 |
| -------------- | ---------- |
|
|
@@ -231,13 +234,13 @@ iter_type do_get_monthname(iter_type s, iter_type end, ios_base& str,
|
|
| 231 |
ios_base::iostate& err, tm* t) const;
|
| 232 |
```
|
| 233 |
|
| 234 |
*Effects:* Reads characters starting at `s` until it has extracted the
|
| 235 |
(perhaps abbreviated) name of a weekday or month. If it finds an
|
| 236 |
-
abbreviation that is followed by characters that
|
| 237 |
-
|
| 238 |
-
|
| 239 |
|
| 240 |
*Returns:* An iterator pointing immediately beyond the last character
|
| 241 |
recognized as part of a valid name.
|
| 242 |
|
| 243 |
``` cpp
|
|
@@ -260,36 +263,36 @@ iter_type do_get(iter_type s, iter_type end, ios_base& f,
|
|
| 260 |
|
| 261 |
*Preconditions:* `t` points to an object.
|
| 262 |
|
| 263 |
*Effects:* The function starts by evaluating `err = ios_base::goodbit`.
|
| 264 |
It then reads characters starting at `s` until it encounters an error,
|
| 265 |
-
or until it has extracted and assigned those `
|
| 266 |
-
|
| 267 |
-
appropriate for the
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
`err |= ios_base::eofbit`.
|
| 274 |
|
| 275 |
-
For complex conversion
|
| 276 |
-
|
| 277 |
-
function is unable to unambiguously determine some or all
|
| 278 |
-
members from the input sequence \[`s`, `end`), it evaluates
|
| 279 |
-
`err |= ios_base::eofbit`. In such cases the values of those `
|
| 280 |
members are unspecified and may be outside their valid range.
|
| 281 |
|
| 282 |
-
*Remarks:* It is unspecified whether multiple calls to `do_get()` with
|
| 283 |
-
the address of the same `struct tm` object will update the current
|
| 284 |
-
contents of the object or simply overwrite its members. Portable
|
| 285 |
-
programs should zero out the object before invoking the function.
|
| 286 |
-
|
| 287 |
*Returns:* An iterator pointing immediately beyond the last character
|
| 288 |
recognized as possibly part of a valid input sequence for the given
|
| 289 |
`format` and `modifier`.
|
| 290 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 291 |
#### Class template `time_get_byname` <a id="locale.time.get.byname">[[locale.time.get.byname]]</a>
|
| 292 |
|
| 293 |
``` cpp
|
| 294 |
namespace std {
|
| 295 |
template<class charT, class InputIterator = istreambuf_iterator<charT>>
|
|
@@ -352,18 +355,20 @@ call to `do_put`; thus, format elements and other characters are
|
|
| 352 |
interleaved in the output in the order in which they appear in the
|
| 353 |
pattern. Format sequences are identified by converting each character
|
| 354 |
`c` to a `char` value as if by `ct.narrow(c, 0)`, where `ct` is a
|
| 355 |
reference to `ctype<charT>` obtained from `str.getloc()`. The first
|
| 356 |
character of each sequence is equal to `’%’`, followed by an optional
|
| 357 |
-
modifier character `mod`[^17]
|
| 358 |
-
|
| 359 |
-
|
|
|
|
|
|
|
| 360 |
`do_put(s, str, fill, t, spec, mod)`.
|
| 361 |
|
| 362 |
The second form calls `do_put(s, str, fill, t, format, modifier)`.
|
| 363 |
|
| 364 |
-
[*Note 1*: The `fill` argument
|
| 365 |
implementation-defined formats or by derivations. A space character is a
|
| 366 |
reasonable default for this argument. — *end note*]
|
| 367 |
|
| 368 |
*Returns:* An iterator pointing immediately after the last character
|
| 369 |
produced.
|
|
@@ -377,21 +382,29 @@ iter_type do_put(iter_type s, ios_base&, char_type fill, const tm* t,
|
|
| 377 |
|
| 378 |
*Effects:* Formats the contents of the parameter `t` into characters
|
| 379 |
placed on the output sequence `s`. Formatting is controlled by the
|
| 380 |
parameters `format` and `modifier`, interpreted identically as the
|
| 381 |
format specifiers in the string argument to the standard library
|
| 382 |
-
function `strftime()`
|
| 383 |
-
|
| 384 |
-
|
|
|
|
|
|
|
|
|
|
| 385 |
|
| 386 |
*Returns:* An iterator pointing immediately after the last character
|
| 387 |
produced.
|
| 388 |
|
| 389 |
-
[*Note
|
| 390 |
implementation-defined formats or by derivations. A space character is a
|
| 391 |
reasonable default for this argument. — *end note*]
|
| 392 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 393 |
#### Class template `time_put_byname` <a id="locale.time.put.byname">[[locale.time.put.byname]]</a>
|
| 394 |
|
| 395 |
``` cpp
|
| 396 |
namespace std {
|
| 397 |
template<class charT, class OutputIterator = ostreambuf_iterator<charT>>
|
|
|
|
| 1 |
### The time category <a id="category.time">[[category.time]]</a>
|
| 2 |
|
| 3 |
+
#### General <a id="category.time.general">[[category.time.general]]</a>
|
| 4 |
+
|
| 5 |
Templates `time_get<charT, InputIterator>` and
|
| 6 |
`time_put<charT, OutputIterator>` provide date and time formatting and
|
| 7 |
parsing. All specifications of member functions for `time_put` and
|
| 8 |
`time_get` in the subclauses of [[category.time]] only apply to the
|
| 9 |
specializations required in Tables [[tab:locale.category.facets]] and
|
|
|
|
| 12 |
[[locale.categories]], and the `ctype<>` facet, to determine formatting
|
| 13 |
details.
|
| 14 |
|
| 15 |
#### Class template `time_get` <a id="locale.time.get">[[locale.time.get]]</a>
|
| 16 |
|
| 17 |
+
##### General <a id="locale.time.get.general">[[locale.time.get.general]]</a>
|
| 18 |
+
|
| 19 |
``` cpp
|
| 20 |
namespace std {
|
| 21 |
class time_base {
|
| 22 |
public:
|
| 23 |
enum dateorder { no_order, dmy, mdy, ymd, ydm };
|
|
|
|
| 67 |
ios_base::iostate& err, tm* t, char format, char modifier) const;
|
| 68 |
};
|
| 69 |
}
|
| 70 |
```
|
| 71 |
|
| 72 |
+
`time_get` is used to parse a character sequence, extracting components
|
| 73 |
+
of a time or date into a `tm` object. Each `get` member parses a format
|
| 74 |
+
as produced by a corresponding format specifier to `time_put<>::put`. If
|
|
|
|
|
|
|
| 75 |
the sequence being parsed matches the correct format, the corresponding
|
| 76 |
+
members of the `tm` argument are set to the values used to produce the
|
| 77 |
+
sequence; otherwise either an error is reported or unspecified values
|
| 78 |
+
are assigned.[^15]
|
| 79 |
|
| 80 |
If the end iterator is reached during parsing by any of the `get()`
|
| 81 |
member functions, the member sets `ios_base::eofbit` in `err`.
|
| 82 |
|
| 83 |
##### Members <a id="locale.time.get.members">[[locale.time.get.members]]</a>
|
|
|
|
| 143 |
- The expression `s == end` evaluates to `true`, in which case the
|
| 144 |
function evaluates `err = ios_base::eofbit | ios_base::failbit`.
|
| 145 |
- The next element of `fmt` is equal to `’%’`, optionally followed by a
|
| 146 |
modifier character, followed by a conversion specifier character,
|
| 147 |
`format`, together forming a conversion specification valid for the
|
| 148 |
+
POSIX function `strptime`. If the number of elements in the range
|
| 149 |
+
\[`fmt`, `fmtend`) is not sufficient to unambiguously determine
|
| 150 |
whether the conversion specification is complete and valid, the
|
| 151 |
function evaluates `err = ios_base::failbit`. Otherwise, the function
|
| 152 |
evaluates `s = do_get(s, end, f, err, t, format, modifier)`, where the
|
| 153 |
value of `modifier` is `’\0’` when the optional modifier is absent
|
| 154 |
from the conversion specification. If `err == ios_base::goodbit` holds
|
|
|
|
| 179 |
dateorder do_date_order() const;
|
| 180 |
```
|
| 181 |
|
| 182 |
*Returns:* An enumeration value indicating the preferred order of
|
| 183 |
components for those date formats that are composed of day, month, and
|
| 184 |
+
year.[^16]
|
| 185 |
+
|
| 186 |
+
Returns `no_order` if the date format specified by `’x’` contains other
|
| 187 |
+
variable components (e.g., Julian day, week number, week day).
|
| 188 |
|
| 189 |
``` cpp
|
| 190 |
iter_type do_get_time(iter_type s, iter_type end, ios_base& str,
|
| 191 |
ios_base::iostate& err, tm* t) const;
|
| 192 |
```
|
| 193 |
|
| 194 |
*Effects:* Reads characters starting at `s` until it has extracted those
|
| 195 |
+
`tm` members, and remaining format characters, used by `time_put<>::put`
|
| 196 |
+
to produce the format specified by `"%H:%M:%S"`, or until it encounters
|
| 197 |
+
an error or end of sequence.
|
| 198 |
|
| 199 |
*Returns:* An iterator pointing immediately beyond the last character
|
| 200 |
recognized as possibly part of a valid time.
|
| 201 |
|
| 202 |
``` cpp
|
| 203 |
iter_type do_get_date(iter_type s, iter_type end, ios_base& str,
|
| 204 |
ios_base::iostate& err, tm* t) const;
|
| 205 |
```
|
| 206 |
|
| 207 |
*Effects:* Reads characters starting at `s` until it has extracted those
|
| 208 |
+
`tm` members and remaining format characters used by `time_put<>::put`
|
| 209 |
+
to produce one of the following formats, or until it encounters an
|
| 210 |
+
error. The format depends on the value returned by `date_order()` as
|
| 211 |
+
shown in [[locale.time.get.dogetdate]].
|
| 212 |
|
| 213 |
**Table: `do_get_date` effects** <a id="locale.time.get.dogetdate">[locale.time.get.dogetdate]</a>
|
| 214 |
|
| 215 |
| `date_order()` | Format |
|
| 216 |
| -------------- | ---------- |
|
|
|
|
| 234 |
ios_base::iostate& err, tm* t) const;
|
| 235 |
```
|
| 236 |
|
| 237 |
*Effects:* Reads characters starting at `s` until it has extracted the
|
| 238 |
(perhaps abbreviated) name of a weekday or month. If it finds an
|
| 239 |
+
abbreviation that is followed by characters that can match a full name,
|
| 240 |
+
it continues reading until it matches the full name or fails. It sets
|
| 241 |
+
the appropriate `tm` member accordingly.
|
| 242 |
|
| 243 |
*Returns:* An iterator pointing immediately beyond the last character
|
| 244 |
recognized as part of a valid name.
|
| 245 |
|
| 246 |
``` cpp
|
|
|
|
| 263 |
|
| 264 |
*Preconditions:* `t` points to an object.
|
| 265 |
|
| 266 |
*Effects:* The function starts by evaluating `err = ios_base::goodbit`.
|
| 267 |
It then reads characters starting at `s` until it encounters an error,
|
| 268 |
+
or until it has extracted and assigned those `tm` members, and any
|
| 269 |
+
remaining format characters, corresponding to a conversion specification
|
| 270 |
+
appropriate for the POSIX function `strptime`, formed by concatenating
|
| 271 |
+
`’%’`, the `modifier` character, when non-NUL, and the `format`
|
| 272 |
+
character. When the concatenation fails to yield a complete valid
|
| 273 |
+
directive the function leaves the object pointed to by `t` unchanged and
|
| 274 |
+
evaluates `err |= ios_base::failbit`. When `s == end` evaluates to
|
| 275 |
+
`true` after reading a character the function evaluates
|
| 276 |
`err |= ios_base::eofbit`.
|
| 277 |
|
| 278 |
+
For complex conversion specifications such as `%c`, `%x`, or `%X`, or
|
| 279 |
+
conversion specifications that involve the optional modifiers `E` or
|
| 280 |
+
`O`, when the function is unable to unambiguously determine some or all
|
| 281 |
+
`tm` members from the input sequence \[`s`, `end`), it evaluates
|
| 282 |
+
`err |= ios_base::eofbit`. In such cases the values of those `tm`
|
| 283 |
members are unspecified and may be outside their valid range.
|
| 284 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
*Returns:* An iterator pointing immediately beyond the last character
|
| 286 |
recognized as possibly part of a valid input sequence for the given
|
| 287 |
`format` and `modifier`.
|
| 288 |
|
| 289 |
+
*Remarks:* It is unspecified whether multiple calls to `do_get()` with
|
| 290 |
+
the address of the same `tm` object will update the current contents of
|
| 291 |
+
the object or simply overwrite its members. Portable programs should
|
| 292 |
+
zero out the object before invoking the function.
|
| 293 |
+
|
| 294 |
#### Class template `time_get_byname` <a id="locale.time.get.byname">[[locale.time.get.byname]]</a>
|
| 295 |
|
| 296 |
``` cpp
|
| 297 |
namespace std {
|
| 298 |
template<class charT, class InputIterator = istreambuf_iterator<charT>>
|
|
|
|
| 355 |
interleaved in the output in the order in which they appear in the
|
| 356 |
pattern. Format sequences are identified by converting each character
|
| 357 |
`c` to a `char` value as if by `ct.narrow(c, 0)`, where `ct` is a
|
| 358 |
reference to `ctype<charT>` obtained from `str.getloc()`. The first
|
| 359 |
character of each sequence is equal to `’%’`, followed by an optional
|
| 360 |
+
modifier character `mod`[^17]
|
| 361 |
+
|
| 362 |
+
and a format specifier character `spec` as defined for the function
|
| 363 |
+
`strftime`. If no modifier character is present, `mod` is zero. For each
|
| 364 |
+
valid format sequence identified, calls
|
| 365 |
`do_put(s, str, fill, t, spec, mod)`.
|
| 366 |
|
| 367 |
The second form calls `do_put(s, str, fill, t, format, modifier)`.
|
| 368 |
|
| 369 |
+
[*Note 1*: The `fill` argument can be used in the
|
| 370 |
implementation-defined formats or by derivations. A space character is a
|
| 371 |
reasonable default for this argument. — *end note*]
|
| 372 |
|
| 373 |
*Returns:* An iterator pointing immediately after the last character
|
| 374 |
produced.
|
|
|
|
| 382 |
|
| 383 |
*Effects:* Formats the contents of the parameter `t` into characters
|
| 384 |
placed on the output sequence `s`. Formatting is controlled by the
|
| 385 |
parameters `format` and `modifier`, interpreted identically as the
|
| 386 |
format specifiers in the string argument to the standard library
|
| 387 |
+
function `strftime()`, except that the sequence of characters produced
|
| 388 |
+
for those specifiers that are described as depending on the C locale are
|
| 389 |
+
instead *implementation-defined*.
|
| 390 |
+
|
| 391 |
+
[*Note 2*: Interpretation of the `modifier` argument is
|
| 392 |
+
implementation-defined. — *end note*]
|
| 393 |
|
| 394 |
*Returns:* An iterator pointing immediately after the last character
|
| 395 |
produced.
|
| 396 |
|
| 397 |
+
[*Note 3*: The `fill` argument can be used in the
|
| 398 |
implementation-defined formats or by derivations. A space character is a
|
| 399 |
reasonable default for this argument. — *end note*]
|
| 400 |
|
| 401 |
+
*Recommended practice:* Interpretation of the `modifier` should follow
|
| 402 |
+
POSIX conventions. Implementations should refer to other standards such
|
| 403 |
+
as POSIX for a specification of the character sequences produced for
|
| 404 |
+
those specifiers described as depending on the C locale.
|
| 405 |
+
|
| 406 |
#### Class template `time_put_byname` <a id="locale.time.put.byname">[[locale.time.put.byname]]</a>
|
| 407 |
|
| 408 |
``` cpp
|
| 409 |
namespace std {
|
| 410 |
template<class charT, class OutputIterator = ostreambuf_iterator<charT>>
|