tmp/tmpft94s67z/{from.md → to.md}
RENAMED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
#### Class template `time_get` <a id="locale.time.get">[[locale.time.get]]</a>
|
| 2 |
|
|
|
|
|
|
|
| 3 |
``` cpp
|
| 4 |
namespace std {
|
| 5 |
class time_base {
|
| 6 |
public:
|
| 7 |
enum dateorder { no_order, dmy, mdy, ymd, ydm };
|
|
@@ -51,19 +53,17 @@ namespace std {
|
|
| 51 |
ios_base::iostate& err, tm* t, char format, char modifier) const;
|
| 52 |
};
|
| 53 |
}
|
| 54 |
```
|
| 55 |
|
| 56 |
-
`time_get`
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
or date into a `struct tm` object. Each `get` member parses a format as
|
| 60 |
-
produced by a corresponding format specifier to `time_put<>::put`. If
|
| 61 |
the sequence being parsed matches the correct format, the corresponding
|
| 62 |
-
members of the `
|
| 63 |
-
|
| 64 |
-
|
| 65 |
|
| 66 |
If the end iterator is reached during parsing by any of the `get()`
|
| 67 |
member functions, the member sets `ios_base::eofbit` in `err`.
|
| 68 |
|
| 69 |
##### Members <a id="locale.time.get.members">[[locale.time.get.members]]</a>
|
|
@@ -129,12 +129,12 @@ the first of the following conditions holds:
|
|
| 129 |
- The expression `s == end` evaluates to `true`, in which case the
|
| 130 |
function evaluates `err = ios_base::eofbit | ios_base::failbit`.
|
| 131 |
- The next element of `fmt` is equal to `’%’`, optionally followed by a
|
| 132 |
modifier character, followed by a conversion specifier character,
|
| 133 |
`format`, together forming a conversion specification valid for the
|
| 134 |
-
|
| 135 |
-
|
| 136 |
whether the conversion specification is complete and valid, the
|
| 137 |
function evaluates `err = ios_base::failbit`. Otherwise, the function
|
| 138 |
evaluates `s = do_get(s, end, f, err, t, format, modifier)`, where the
|
| 139 |
value of `modifier` is `’\0’` when the optional modifier is absent
|
| 140 |
from the conversion specification. If `err == ios_base::goodbit` holds
|
|
@@ -165,37 +165,38 @@ so. — *end note*]
|
|
| 165 |
dateorder do_date_order() const;
|
| 166 |
```
|
| 167 |
|
| 168 |
*Returns:* An enumeration value indicating the preferred order of
|
| 169 |
components for those date formats that are composed of day, month, and
|
| 170 |
-
year.[^16]
|
| 171 |
-
|
| 172 |
-
|
|
|
|
| 173 |
|
| 174 |
``` cpp
|
| 175 |
iter_type do_get_time(iter_type s, iter_type end, ios_base& str,
|
| 176 |
ios_base::iostate& err, tm* t) const;
|
| 177 |
```
|
| 178 |
|
| 179 |
*Effects:* Reads characters starting at `s` until it has extracted those
|
| 180 |
-
`
|
| 181 |
-
|
| 182 |
-
|
| 183 |
|
| 184 |
*Returns:* An iterator pointing immediately beyond the last character
|
| 185 |
recognized as possibly part of a valid time.
|
| 186 |
|
| 187 |
``` cpp
|
| 188 |
iter_type do_get_date(iter_type s, iter_type end, ios_base& str,
|
| 189 |
ios_base::iostate& err, tm* t) const;
|
| 190 |
```
|
| 191 |
|
| 192 |
*Effects:* Reads characters starting at `s` until it has extracted those
|
| 193 |
-
`
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
|
| 198 |
**Table: `do_get_date` effects** <a id="locale.time.get.dogetdate">[locale.time.get.dogetdate]</a>
|
| 199 |
|
| 200 |
| `date_order()` | Format |
|
| 201 |
| -------------- | ---------- |
|
|
@@ -219,13 +220,13 @@ iter_type do_get_monthname(iter_type s, iter_type end, ios_base& str,
|
|
| 219 |
ios_base::iostate& err, tm* t) const;
|
| 220 |
```
|
| 221 |
|
| 222 |
*Effects:* Reads characters starting at `s` until it has extracted the
|
| 223 |
(perhaps abbreviated) name of a weekday or month. If it finds an
|
| 224 |
-
abbreviation that is followed by characters that
|
| 225 |
-
|
| 226 |
-
|
| 227 |
|
| 228 |
*Returns:* An iterator pointing immediately beyond the last character
|
| 229 |
recognized as part of a valid name.
|
| 230 |
|
| 231 |
``` cpp
|
|
@@ -248,31 +249,31 @@ iter_type do_get(iter_type s, iter_type end, ios_base& f,
|
|
| 248 |
|
| 249 |
*Preconditions:* `t` points to an object.
|
| 250 |
|
| 251 |
*Effects:* The function starts by evaluating `err = ios_base::goodbit`.
|
| 252 |
It then reads characters starting at `s` until it encounters an error,
|
| 253 |
-
or until it has extracted and assigned those `
|
| 254 |
-
|
| 255 |
-
appropriate for the
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
`err |= ios_base::eofbit`.
|
| 262 |
|
| 263 |
-
For complex conversion
|
| 264 |
-
|
| 265 |
-
function is unable to unambiguously determine some or all
|
| 266 |
-
members from the input sequence \[`s`, `end`), it evaluates
|
| 267 |
-
`err |= ios_base::eofbit`. In such cases the values of those `
|
| 268 |
members are unspecified and may be outside their valid range.
|
| 269 |
|
| 270 |
-
*Remarks:* It is unspecified whether multiple calls to `do_get()` with
|
| 271 |
-
the address of the same `struct tm` object will update the current
|
| 272 |
-
contents of the object or simply overwrite its members. Portable
|
| 273 |
-
programs should zero out the object before invoking the function.
|
| 274 |
-
|
| 275 |
*Returns:* An iterator pointing immediately beyond the last character
|
| 276 |
recognized as possibly part of a valid input sequence for the given
|
| 277 |
`format` and `modifier`.
|
| 278 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
#### Class template `time_get` <a id="locale.time.get">[[locale.time.get]]</a>
|
| 2 |
|
| 3 |
+
##### General <a id="locale.time.get.general">[[locale.time.get.general]]</a>
|
| 4 |
+
|
| 5 |
``` cpp
|
| 6 |
namespace std {
|
| 7 |
class time_base {
|
| 8 |
public:
|
| 9 |
enum dateorder { no_order, dmy, mdy, ymd, ydm };
|
|
|
|
| 53 |
ios_base::iostate& err, tm* t, char format, char modifier) const;
|
| 54 |
};
|
| 55 |
}
|
| 56 |
```
|
| 57 |
|
| 58 |
+
`time_get` is used to parse a character sequence, extracting components
|
| 59 |
+
of a time or date into a `tm` object. Each `get` member parses a format
|
| 60 |
+
as produced by a corresponding format specifier to `time_put<>::put`. If
|
|
|
|
|
|
|
| 61 |
the sequence being parsed matches the correct format, the corresponding
|
| 62 |
+
members of the `tm` argument are set to the values used to produce the
|
| 63 |
+
sequence; otherwise either an error is reported or unspecified values
|
| 64 |
+
are assigned.[^15]
|
| 65 |
|
| 66 |
If the end iterator is reached during parsing by any of the `get()`
|
| 67 |
member functions, the member sets `ios_base::eofbit` in `err`.
|
| 68 |
|
| 69 |
##### Members <a id="locale.time.get.members">[[locale.time.get.members]]</a>
|
|
|
|
| 129 |
- The expression `s == end` evaluates to `true`, in which case the
|
| 130 |
function evaluates `err = ios_base::eofbit | ios_base::failbit`.
|
| 131 |
- The next element of `fmt` is equal to `’%’`, optionally followed by a
|
| 132 |
modifier character, followed by a conversion specifier character,
|
| 133 |
`format`, together forming a conversion specification valid for the
|
| 134 |
+
POSIX function `strptime`. If the number of elements in the range
|
| 135 |
+
\[`fmt`, `fmtend`) is not sufficient to unambiguously determine
|
| 136 |
whether the conversion specification is complete and valid, the
|
| 137 |
function evaluates `err = ios_base::failbit`. Otherwise, the function
|
| 138 |
evaluates `s = do_get(s, end, f, err, t, format, modifier)`, where the
|
| 139 |
value of `modifier` is `’\0’` when the optional modifier is absent
|
| 140 |
from the conversion specification. If `err == ios_base::goodbit` holds
|
|
|
|
| 165 |
dateorder do_date_order() const;
|
| 166 |
```
|
| 167 |
|
| 168 |
*Returns:* An enumeration value indicating the preferred order of
|
| 169 |
components for those date formats that are composed of day, month, and
|
| 170 |
+
year.[^16]
|
| 171 |
+
|
| 172 |
+
Returns `no_order` if the date format specified by `’x’` contains other
|
| 173 |
+
variable components (e.g., Julian day, week number, week day).
|
| 174 |
|
| 175 |
``` cpp
|
| 176 |
iter_type do_get_time(iter_type s, iter_type end, ios_base& str,
|
| 177 |
ios_base::iostate& err, tm* t) const;
|
| 178 |
```
|
| 179 |
|
| 180 |
*Effects:* Reads characters starting at `s` until it has extracted those
|
| 181 |
+
`tm` members, and remaining format characters, used by `time_put<>::put`
|
| 182 |
+
to produce the format specified by `"%H:%M:%S"`, or until it encounters
|
| 183 |
+
an error or end of sequence.
|
| 184 |
|
| 185 |
*Returns:* An iterator pointing immediately beyond the last character
|
| 186 |
recognized as possibly part of a valid time.
|
| 187 |
|
| 188 |
``` cpp
|
| 189 |
iter_type do_get_date(iter_type s, iter_type end, ios_base& str,
|
| 190 |
ios_base::iostate& err, tm* t) const;
|
| 191 |
```
|
| 192 |
|
| 193 |
*Effects:* Reads characters starting at `s` until it has extracted those
|
| 194 |
+
`tm` members and remaining format characters used by `time_put<>::put`
|
| 195 |
+
to produce one of the following formats, or until it encounters an
|
| 196 |
+
error. The format depends on the value returned by `date_order()` as
|
| 197 |
+
shown in [[locale.time.get.dogetdate]].
|
| 198 |
|
| 199 |
**Table: `do_get_date` effects** <a id="locale.time.get.dogetdate">[locale.time.get.dogetdate]</a>
|
| 200 |
|
| 201 |
| `date_order()` | Format |
|
| 202 |
| -------------- | ---------- |
|
|
|
|
| 220 |
ios_base::iostate& err, tm* t) const;
|
| 221 |
```
|
| 222 |
|
| 223 |
*Effects:* Reads characters starting at `s` until it has extracted the
|
| 224 |
(perhaps abbreviated) name of a weekday or month. If it finds an
|
| 225 |
+
abbreviation that is followed by characters that can match a full name,
|
| 226 |
+
it continues reading until it matches the full name or fails. It sets
|
| 227 |
+
the appropriate `tm` member accordingly.
|
| 228 |
|
| 229 |
*Returns:* An iterator pointing immediately beyond the last character
|
| 230 |
recognized as part of a valid name.
|
| 231 |
|
| 232 |
``` cpp
|
|
|
|
| 249 |
|
| 250 |
*Preconditions:* `t` points to an object.
|
| 251 |
|
| 252 |
*Effects:* The function starts by evaluating `err = ios_base::goodbit`.
|
| 253 |
It then reads characters starting at `s` until it encounters an error,
|
| 254 |
+
or until it has extracted and assigned those `tm` members, and any
|
| 255 |
+
remaining format characters, corresponding to a conversion specification
|
| 256 |
+
appropriate for the POSIX function `strptime`, formed by concatenating
|
| 257 |
+
`’%’`, the `modifier` character, when non-NUL, and the `format`
|
| 258 |
+
character. When the concatenation fails to yield a complete valid
|
| 259 |
+
directive the function leaves the object pointed to by `t` unchanged and
|
| 260 |
+
evaluates `err |= ios_base::failbit`. When `s == end` evaluates to
|
| 261 |
+
`true` after reading a character the function evaluates
|
| 262 |
`err |= ios_base::eofbit`.
|
| 263 |
|
| 264 |
+
For complex conversion specifications such as `%c`, `%x`, or `%X`, or
|
| 265 |
+
conversion specifications that involve the optional modifiers `E` or
|
| 266 |
+
`O`, when the function is unable to unambiguously determine some or all
|
| 267 |
+
`tm` members from the input sequence \[`s`, `end`), it evaluates
|
| 268 |
+
`err |= ios_base::eofbit`. In such cases the values of those `tm`
|
| 269 |
members are unspecified and may be outside their valid range.
|
| 270 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
*Returns:* An iterator pointing immediately beyond the last character
|
| 272 |
recognized as possibly part of a valid input sequence for the given
|
| 273 |
`format` and `modifier`.
|
| 274 |
|
| 275 |
+
*Remarks:* It is unspecified whether multiple calls to `do_get()` with
|
| 276 |
+
the address of the same `tm` object will update the current contents of
|
| 277 |
+
the object or simply overwrite its members. Portable programs should
|
| 278 |
+
zero out the object before invoking the function.
|
| 279 |
+
|