- tmp/tmppkl0c77_/{from.md → to.md} +262 -156
tmp/tmppkl0c77_/{from.md → to.md}
RENAMED
|
@@ -30,38 +30,39 @@ and `L"..."` if `charT` is `wchar_t`.
|
|
| 30 |
## Header `<chrono>` synopsis <a id="time.syn">[[time.syn]]</a>
|
| 31 |
|
| 32 |
``` cpp
|
| 33 |
#include <compare> // see [compare.syn]
|
| 34 |
|
| 35 |
-
namespace std {
|
| 36 |
-
namespace chrono {
|
| 37 |
// [time.duration], class template duration
|
| 38 |
template<class Rep, class Period = ratio<1>> class duration;
|
| 39 |
|
| 40 |
// [time.point], class template time_point
|
| 41 |
template<class Clock, class Duration = typename Clock::duration> class time_point;
|
| 42 |
}
|
| 43 |
|
|
|
|
| 44 |
// [time.traits.specializations], common_type specializations
|
| 45 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 46 |
struct common_type<chrono::duration<Rep1, Period1>,
|
| 47 |
chrono::duration<Rep2, Period2>>;
|
| 48 |
|
| 49 |
template<class Clock, class Duration1, class Duration2>
|
| 50 |
struct common_type<chrono::time_point<Clock, Duration1>,
|
| 51 |
chrono::time_point<Clock, Duration2>>;
|
|
|
|
| 52 |
|
| 53 |
-
|
| 54 |
// [time.traits], customization traits
|
| 55 |
template<class Rep> struct treat_as_floating_point;
|
| 56 |
template<class Rep>
|
| 57 |
-
|
| 58 |
|
| 59 |
template<class Rep> struct duration_values;
|
| 60 |
|
| 61 |
template<class T> struct is_clock;
|
| 62 |
-
|
| 63 |
|
| 64 |
// [time.duration.nonmember], duration arithmetic
|
| 65 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 66 |
constexpr common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
|
| 67 |
operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
|
@@ -561,11 +562,11 @@ namespace std {
|
|
| 561 |
constexpr year_month_weekday
|
| 562 |
operator-(const year_month_weekday& ymwd, const years& dy) noexcept;
|
| 563 |
|
| 564 |
template<class charT, class traits>
|
| 565 |
basic_ostream<charT, traits>&
|
| 566 |
-
|
| 567 |
|
| 568 |
// [time.cal.ymwdlast], class year_month_weekday_last
|
| 569 |
class year_month_weekday_last;
|
| 570 |
|
| 571 |
constexpr bool operator==(const year_month_weekday_last& x,
|
|
@@ -737,31 +738,31 @@ namespace std {
|
|
| 737 |
const zoned_time<Duration, TimeZonePtr>& t);
|
| 738 |
|
| 739 |
// [time.zone.leap], leap second support
|
| 740 |
class leap_second;
|
| 741 |
|
| 742 |
-
|
| 743 |
-
|
| 744 |
|
| 745 |
template<class Duration>
|
| 746 |
-
|
| 747 |
template<class Duration>
|
| 748 |
-
|
| 749 |
template<class Duration>
|
| 750 |
-
|
| 751 |
template<class Duration>
|
| 752 |
-
|
| 753 |
template<class Duration>
|
| 754 |
-
|
| 755 |
template<class Duration>
|
| 756 |
-
|
| 757 |
template<class Duration>
|
| 758 |
-
|
| 759 |
template<class Duration>
|
| 760 |
-
|
| 761 |
template<class Duration>
|
| 762 |
-
|
| 763 |
template<class Duration>
|
| 764 |
requires three_way_comparable_with<sys_seconds, sys_time<Duration>>
|
| 765 |
constexpr auto operator<=>(const leap_second& x, const sys_time<Duration>& y);
|
| 766 |
|
| 767 |
// [time.zone.link], class time_zone_link
|
|
@@ -776,10 +777,11 @@ namespace std {
|
|
| 776 |
local-time-format-t<Duration>
|
| 777 |
local_time_format(local_time<Duration> time, const string* abbrev = nullptr,
|
| 778 |
const seconds* offset_sec = nullptr);
|
| 779 |
}
|
| 780 |
|
|
|
|
| 781 |
template<class Rep, class Period, class charT>
|
| 782 |
struct formatter<chrono::duration<Rep, Period>, charT>;
|
| 783 |
template<class Duration, class charT>
|
| 784 |
struct formatter<chrono::sys_time<Duration>, charT>;
|
| 785 |
template<class Duration, class charT>
|
|
@@ -813,30 +815,45 @@ namespace std {
|
|
| 813 |
struct formatter<chrono::hh_mm_ss<duration<Rep, Period>>, charT>;
|
| 814 |
template<class charT> struct formatter<chrono::sys_info, charT>;
|
| 815 |
template<class charT> struct formatter<chrono::local_info, charT>;
|
| 816 |
template<class Duration, class TimeZonePtr, class charT>
|
| 817 |
struct formatter<chrono::zoned_time<Duration, TimeZonePtr>, charT>;
|
|
|
|
| 818 |
|
| 819 |
-
|
| 820 |
// [time.parse], parsing
|
|
|
|
|
|
|
|
|
|
| 821 |
template<class charT, class traits, class Alloc, class Parsable>
|
| 822 |
unspecified
|
| 823 |
-
|
| 824 |
|
| 825 |
template<class charT, class traits, class Alloc, class Parsable>
|
| 826 |
unspecified
|
| 827 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 828 |
basic_string<charT, traits, Alloc>& abbrev);
|
| 829 |
|
|
|
|
|
|
|
|
|
|
| 830 |
template<class charT, class traits, class Alloc, class Parsable>
|
| 831 |
unspecified
|
| 832 |
-
|
| 833 |
minutes& offset);
|
| 834 |
|
| 835 |
template<class charT, class traits, class Alloc, class Parsable>
|
| 836 |
unspecified
|
| 837 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 838 |
basic_string<charT, traits, Alloc>& abbrev, minutes& offset);
|
| 839 |
|
| 840 |
// calendrical constants
|
| 841 |
inline constexpr last_spec last{};
|
| 842 |
|
|
@@ -860,12 +877,11 @@ namespace std {
|
|
| 860 |
inline constexpr month October{10};
|
| 861 |
inline constexpr month November{11};
|
| 862 |
inline constexpr month December{12};
|
| 863 |
}
|
| 864 |
|
| 865 |
-
|
| 866 |
-
inline namespace chrono_literals {
|
| 867 |
// [time.duration.literals], suffixes for duration literals
|
| 868 |
constexpr chrono::hours operator""h(unsigned long long);
|
| 869 |
constexpr chrono::duration<unspecified, ratio<3600, 1>> operator""h(long double);
|
| 870 |
|
| 871 |
constexpr chrono::minutes operator""min(unsigned long long);
|
|
@@ -887,16 +903,14 @@ namespace std {
|
|
| 887 |
constexpr chrono::day operator""d(unsigned long long d) noexcept;
|
| 888 |
|
| 889 |
// [time.cal.year.nonmembers], non-member functions
|
| 890 |
constexpr chrono::year operator""y(unsigned long long y) noexcept;
|
| 891 |
}
|
| 892 |
-
}
|
| 893 |
|
| 894 |
-
|
| 895 |
using namespace literals::chrono_literals;
|
| 896 |
}
|
| 897 |
-
}
|
| 898 |
```
|
| 899 |
|
| 900 |
## *Cpp17Clock* requirements <a id="time.clock.req">[[time.clock.req]]</a>
|
| 901 |
|
| 902 |
A clock is a bundle consisting of a `duration`, a `time_point`, and a
|
|
@@ -916,19 +930,18 @@ calls occur before `C1::time_point::max()`.
|
|
| 916 |
by a given clock and the SI definition is a measure of the quality of
|
| 917 |
implementation. — *end note*]
|
| 918 |
|
| 919 |
A type `TC` meets the *Cpp17TrivialClock* requirements if:
|
| 920 |
|
| 921 |
-
- `TC` meets the *Cpp17Clock* requirements
|
| 922 |
- the types `TC::rep`, `TC::duration`, and `TC::time_point` meet the
|
| 923 |
*Cpp17EqualityComparable* ([[cpp17.equalitycomparable]]) and
|
| 924 |
-
*Cpp17LessThanComparable* ([[cpp17.lessthancomparable]])
|
| 925 |
-
|
|
|
|
| 926 |
\[*Note 3*: This means, in particular, that operations on these types
|
| 927 |
will not throw exceptions. — *end note*]
|
| 928 |
-
- lvalues of the types `TC::rep`, `TC::duration`, and `TC::time_point`
|
| 929 |
-
are swappable [[swappable.requirements]],
|
| 930 |
- the function `TC::now()` does not throw exceptions, and
|
| 931 |
- the type `TC::time_point::clock` meets the *Cpp17TrivialClock*
|
| 932 |
requirements, recursively.
|
| 933 |
|
| 934 |
## Time-related traits <a id="time.traits">[[time.traits]]</a>
|
|
@@ -965,22 +978,22 @@ template<class Rep>
|
|
| 965 |
};
|
| 966 |
```
|
| 967 |
|
| 968 |
The `duration` template uses the `duration_values` trait to construct
|
| 969 |
special values of the duration’s representation (`Rep`). This is done
|
| 970 |
-
because the representation
|
| 971 |
requires some other implementation to return these special values. In
|
| 972 |
that case, the author of that class type should specialize
|
| 973 |
`duration_values` to return the indicated values.
|
| 974 |
|
| 975 |
``` cpp
|
| 976 |
static constexpr Rep zero() noexcept;
|
| 977 |
```
|
| 978 |
|
| 979 |
*Returns:* `Rep(0)`.
|
| 980 |
|
| 981 |
-
[*Note 1*: `Rep(0)` is specified instead of `Rep()` because `Rep()`
|
| 982 |
have some other meaning, such as an uninitialized value. — *end note*]
|
| 983 |
|
| 984 |
*Remarks:* The value returned shall be the additive identity.
|
| 985 |
|
| 986 |
``` cpp
|
|
@@ -1019,11 +1032,11 @@ multiple of `Period1::den` and `Period2::den`. — *end note*]
|
|
| 1019 |
[*Note 2*: The `typedef` name `type` is a synonym for the `duration`
|
| 1020 |
with the largest tick `period` possible where both `duration` arguments
|
| 1021 |
will convert to it without requiring a division operation. The
|
| 1022 |
representation of this type is intended to be able to hold any value
|
| 1023 |
resulting from this conversion with no truncation error, although
|
| 1024 |
-
floating-point durations
|
| 1025 |
|
| 1026 |
``` cpp
|
| 1027 |
template<class Clock, class Duration1, class Duration2>
|
| 1028 |
struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>> {
|
| 1029 |
using type = chrono::time_point<Clock, common_type_t<Duration1, Duration2>>;
|
|
@@ -1049,19 +1062,21 @@ unspecified, except that as a minimum a type `T` shall not qualify as a
|
|
| 1049 |
*Cpp17Clock* unless it meets all of the following conditions:
|
| 1050 |
|
| 1051 |
- the *qualified-id*s `T::rep`, `T::period`, `T::duration`, and
|
| 1052 |
`T::time_point` are valid and each denotes a type [[temp.deduct]],
|
| 1053 |
- the expression `T::is_steady` is well-formed when treated as an
|
| 1054 |
-
unevaluated operand,
|
| 1055 |
- the expression `T::now()` is well-formed when treated as an
|
| 1056 |
unevaluated operand.
|
| 1057 |
|
| 1058 |
The behavior of a program that adds specializations for `is_clock` is
|
| 1059 |
undefined.
|
| 1060 |
|
| 1061 |
## Class template `duration` <a id="time.duration">[[time.duration]]</a>
|
| 1062 |
|
|
|
|
|
|
|
| 1063 |
A `duration` type measures time between two points in time
|
| 1064 |
(`time_point`s). A `duration` has a representation which holds a count
|
| 1065 |
of ticks and a tick period. The tick period is the amount of time which
|
| 1066 |
occurs from one tick to the next, in units of seconds. It is expressed
|
| 1067 |
as a rational constant using the template `ratio`.
|
|
@@ -1125,12 +1140,11 @@ ill-formed. If `Period::num` is not positive, the program is ill-formed.
|
|
| 1125 |
Members of `duration` do not throw exceptions other than those thrown by
|
| 1126 |
the indicated operations on their representations.
|
| 1127 |
|
| 1128 |
The defaulted copy constructor of duration shall be a constexpr function
|
| 1129 |
if and only if the required initialization of the member `rep_` for copy
|
| 1130 |
-
and move, respectively, would
|
| 1131 |
-
function.
|
| 1132 |
|
| 1133 |
[*Example 1*:
|
| 1134 |
|
| 1135 |
``` cpp
|
| 1136 |
duration<long, ratio<60>> d0; // holds a count of minutes using a long
|
|
@@ -1160,11 +1174,11 @@ duration<int, milli> d(3); // OK
|
|
| 1160 |
duration<int, milli> d(3.5); // error
|
| 1161 |
```
|
| 1162 |
|
| 1163 |
— *end example*]
|
| 1164 |
|
| 1165 |
-
*
|
| 1166 |
|
| 1167 |
``` cpp
|
| 1168 |
template<class Rep2, class Period2>
|
| 1169 |
constexpr duration(const duration<Rep2, Period2>& d);
|
| 1170 |
```
|
|
@@ -1657,11 +1671,11 @@ where *`units-suffix`* depends on the type `Period::type` as follows:
|
|
| 1657 |
`"d"`.
|
| 1658 |
- Otherwise, if `Period::type::den == 1`, *`units-suffix`* is
|
| 1659 |
`"[`*`num`*`]s"`.
|
| 1660 |
- Otherwise, *`units-suffix`* is `"[`*`num`*`/`*`den`*`]s"`.
|
| 1661 |
|
| 1662 |
-
In the list above, the use of *`num`* and *`den`*
|
| 1663 |
data members of `Period::type`, which are converted to arrays of `charT`
|
| 1664 |
using a decimal conversion with no leading zeroes.
|
| 1665 |
|
| 1666 |
*Returns:* `os`.
|
| 1667 |
|
|
@@ -1674,22 +1688,23 @@ template<class charT, class traits, class Rep, class Period, class Alloc = alloc
|
|
| 1674 |
minutes* offset = nullptr);
|
| 1675 |
```
|
| 1676 |
|
| 1677 |
*Effects:* Attempts to parse the input stream `is` into the duration `d`
|
| 1678 |
using the format flags given in the NTCTS `fmt` as specified in
|
| 1679 |
-
[[time.parse]]. If the parse
|
| 1680 |
-
|
| 1681 |
-
|
| 1682 |
-
|
| 1683 |
-
|
| 1684 |
-
|
| 1685 |
-
`offset` is non-null.
|
| 1686 |
|
| 1687 |
*Returns:* `is`.
|
| 1688 |
|
| 1689 |
## Class template `time_point` <a id="time.point">[[time.point]]</a>
|
| 1690 |
|
|
|
|
|
|
|
| 1691 |
``` cpp
|
| 1692 |
namespace std::chrono {
|
| 1693 |
template<class Clock, class Duration = typename Clock::duration>
|
| 1694 |
class time_point {
|
| 1695 |
public:
|
|
@@ -1724,14 +1739,11 @@ namespace std::chrono {
|
|
| 1724 |
static constexpr time_point max() noexcept;
|
| 1725 |
};
|
| 1726 |
}
|
| 1727 |
```
|
| 1728 |
|
| 1729 |
-
`
|
| 1730 |
-
[[time.clock.req]] or be the type `local_t`.
|
| 1731 |
-
|
| 1732 |
-
If `Duration` is not an instance of `duration`, the program is
|
| 1733 |
ill-formed.
|
| 1734 |
|
| 1735 |
### Constructors <a id="time.point.cons">[[time.point.cons]]</a>
|
| 1736 |
|
| 1737 |
``` cpp
|
|
@@ -1958,11 +1970,13 @@ template<class ToDuration, class Clock, class Duration>
|
|
| 1958 |
*Returns:*
|
| 1959 |
`time_point<Clock, ToDuration>(round<ToDuration>(tp.time_since_epoch()))`.
|
| 1960 |
|
| 1961 |
## Clocks <a id="time.clock">[[time.clock]]</a>
|
| 1962 |
|
| 1963 |
-
|
|
|
|
|
|
|
| 1964 |
requirements [[time.clock.req]] unless otherwise specified.
|
| 1965 |
|
| 1966 |
### Class `system_clock` <a id="time.clock.system">[[time.clock.system]]</a>
|
| 1967 |
|
| 1968 |
#### Overview <a id="time.clock.system.overview">[[time.clock.system.overview]]</a>
|
|
@@ -2040,13 +2054,11 @@ template<class charT, class traits, class Duration>
|
|
| 2040 |
`false`, and `Duration{1} < days{1}` is `true`.
|
| 2041 |
|
| 2042 |
*Effects:* Equivalent to:
|
| 2043 |
|
| 2044 |
``` cpp
|
| 2045 |
-
|
| 2046 |
-
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{} {}"),
|
| 2047 |
-
year_month_day{dp}, hh_mm_ss{tp-dp});
|
| 2048 |
```
|
| 2049 |
|
| 2050 |
[*Example 1*:
|
| 2051 |
|
| 2052 |
``` cpp
|
|
@@ -2125,11 +2137,12 @@ measure time since this epoch instead, one can add/subtract the constant
|
|
| 2125 |
|
| 2126 |
[*Example 1*:
|
| 2127 |
`clock_cast<utc_clock>(sys_seconds{sys_days{1970y/January/1}}).time_since_epoch()`
|
| 2128 |
is `0s`.
|
| 2129 |
`clock_cast<utc_clock>(sys_seconds{sys_days{2000y/January/1}}).time_since_epoch()`
|
| 2130 |
-
is `946'684'822s`,
|
|
|
|
| 2131 |
— *end example*]
|
| 2132 |
|
| 2133 |
`utc_clock` is not a *Cpp17TrivialClock* unless the implementation can
|
| 2134 |
guarantee that `utc_clock::now()` does not propagate an exception.
|
| 2135 |
|
|
@@ -2197,11 +2210,11 @@ template<class charT, class traits, class Duration>
|
|
| 2197 |
```
|
| 2198 |
|
| 2199 |
*Effects:* Equivalent to:
|
| 2200 |
|
| 2201 |
``` cpp
|
| 2202 |
-
return os << format(STATICALLY-WIDEN<charT>("{:%F %T}"), t);
|
| 2203 |
```
|
| 2204 |
|
| 2205 |
[*Example 1*:
|
| 2206 |
|
| 2207 |
``` cpp
|
|
@@ -2368,11 +2381,11 @@ template<class charT, class traits, class Duration>
|
|
| 2368 |
```
|
| 2369 |
|
| 2370 |
*Effects:* Equivalent to:
|
| 2371 |
|
| 2372 |
``` cpp
|
| 2373 |
-
return os << format(STATICALLY-WIDEN<charT>("{:%F %T}"), t);
|
| 2374 |
```
|
| 2375 |
|
| 2376 |
[*Example 1*:
|
| 2377 |
|
| 2378 |
``` cpp
|
|
@@ -2466,11 +2479,11 @@ template<class Duration>
|
|
| 2466 |
```
|
| 2467 |
|
| 2468 |
*Returns:*
|
| 2469 |
|
| 2470 |
``` cpp
|
| 2471 |
-
|
| 2472 |
```
|
| 2473 |
|
| 2474 |
[*Note 1*:
|
| 2475 |
|
| 2476 |
``` cpp
|
|
@@ -2508,11 +2521,11 @@ template<class charT, class traits, class Duration>
|
|
| 2508 |
```
|
| 2509 |
|
| 2510 |
*Effects:* Equivalent to:
|
| 2511 |
|
| 2512 |
``` cpp
|
| 2513 |
-
return os << format(STATICALLY-WIDEN<charT>("{:%F %T}"), t);
|
| 2514 |
```
|
| 2515 |
|
| 2516 |
[*Example 1*:
|
| 2517 |
|
| 2518 |
``` cpp
|
|
@@ -2564,11 +2577,11 @@ namespace std::chrono {
|
|
| 2564 |
requirements [[time.clock.req]], and using a signed arithmetic type for
|
| 2565 |
`file_clock::rep`. `file_clock` is used to create the `time_point`
|
| 2566 |
system used for `file_time_type` [[filesystems]]. Its epoch is
|
| 2567 |
unspecified, and `noexcept(file_clock::now())` is `true`.
|
| 2568 |
|
| 2569 |
-
[*Note 1*: The type that `file_clock` denotes
|
| 2570 |
namespace than `std::chrono`, such as `std::filesystem`. — *end note*]
|
| 2571 |
|
| 2572 |
#### Member functions <a id="time.clock.file.members">[[time.clock.file.members]]</a>
|
| 2573 |
|
| 2574 |
The type denoted by `file_clock` provides precisely one of the following
|
|
@@ -2608,11 +2621,11 @@ template<class charT, class traits, class Duration>
|
|
| 2608 |
```
|
| 2609 |
|
| 2610 |
*Effects:* Equivalent to:
|
| 2611 |
|
| 2612 |
``` cpp
|
| 2613 |
-
return os << format(STATICALLY-WIDEN<charT>("{:%F %T}"), t);
|
| 2614 |
```
|
| 2615 |
|
| 2616 |
``` cpp
|
| 2617 |
template<class charT, class traits, class Duration, class Alloc = allocator<charT>>
|
| 2618 |
basic_istream<charT, traits>&
|
|
@@ -2856,12 +2869,12 @@ template<class Duration>
|
|
| 2856 |
-> decltype(SourceClock::to_sys(t));
|
| 2857 |
```
|
| 2858 |
|
| 2859 |
*Constraints:* `SourceClock::to_sys(t)` is well-formed.
|
| 2860 |
|
| 2861 |
-
*Mandates:* `SourceClock::to_sys(t)` returns a `sys_time<
|
| 2862 |
-
|
| 2863 |
|
| 2864 |
*Returns:* `SourceClock::to_sys(t)`.
|
| 2865 |
|
| 2866 |
``` cpp
|
| 2867 |
template<class DestClock>
|
|
@@ -2879,12 +2892,12 @@ template<class Duration>
|
|
| 2879 |
```
|
| 2880 |
|
| 2881 |
*Constraints:* `DestClock::from_sys(t)` is well-formed.
|
| 2882 |
|
| 2883 |
*Mandates:* `DestClock::from_sys(t)` returns a
|
| 2884 |
-
`time_point<DestClock,
|
| 2885 |
-
|
| 2886 |
|
| 2887 |
*Returns:* `DestClock::from_sys(t)`.
|
| 2888 |
|
| 2889 |
#### Conversions between `utc_clock` and other clocks <a id="time.clock.cast.utc">[[time.clock.cast.utc]]</a>
|
| 2890 |
|
|
@@ -2903,12 +2916,12 @@ template<class Duration>
|
|
| 2903 |
-> decltype(SourceClock::to_utc(t));
|
| 2904 |
```
|
| 2905 |
|
| 2906 |
*Constraints:* `SourceClock::to_utc(t)` is well-formed.
|
| 2907 |
|
| 2908 |
-
*Mandates:* `SourceClock::to_utc(t)` returns a `utc_time<
|
| 2909 |
-
|
| 2910 |
|
| 2911 |
*Returns:* `SourceClock::to_utc(t)`.
|
| 2912 |
|
| 2913 |
``` cpp
|
| 2914 |
template<class DestClock>
|
|
@@ -2926,12 +2939,12 @@ template<class Duration>
|
|
| 2926 |
```
|
| 2927 |
|
| 2928 |
*Constraints:* `DestClock::from_utc(t)` is well-formed.
|
| 2929 |
|
| 2930 |
*Mandates:* `DestClock::from_utc(t)` returns a
|
| 2931 |
-
`time_point<DestClock,
|
| 2932 |
-
|
| 2933 |
|
| 2934 |
*Returns:* `DestClock::from_utc(t)`.
|
| 2935 |
|
| 2936 |
#### Function template `clock_cast` <a id="time.clock.cast.fn">[[time.clock.cast.fn]]</a>
|
| 2937 |
|
|
@@ -3359,11 +3372,11 @@ template<class charT, class traits>
|
|
| 3359 |
|
| 3360 |
*Effects:* Equivalent to:
|
| 3361 |
|
| 3362 |
``` cpp
|
| 3363 |
return os << (m.ok() ?
|
| 3364 |
-
format(os.getloc(), STATICALLY-WIDEN<charT>("{:%b}"), m) :
|
| 3365 |
format(os.getloc(), STATICALLY-WIDEN<charT>("{} is not a valid month"),
|
| 3366 |
static_cast<unsigned>(m)));
|
| 3367 |
```
|
| 3368 |
|
| 3369 |
``` cpp
|
|
@@ -3494,11 +3507,11 @@ constexpr year operator+() const noexcept;
|
|
| 3494 |
```
|
| 3495 |
|
| 3496 |
*Returns:* `*this`.
|
| 3497 |
|
| 3498 |
``` cpp
|
| 3499 |
-
constexpr year
|
| 3500 |
```
|
| 3501 |
|
| 3502 |
*Returns:* `year{-y_}`.
|
| 3503 |
|
| 3504 |
``` cpp
|
|
@@ -3547,11 +3560,11 @@ constexpr strong_ordering operator<=>(const year& x, const year& y) noexcept;
|
|
| 3547 |
|
| 3548 |
``` cpp
|
| 3549 |
constexpr year operator+(const year& x, const years& y) noexcept;
|
| 3550 |
```
|
| 3551 |
|
| 3552 |
-
*Returns:* `year{int{x} + y.count()}`.
|
| 3553 |
|
| 3554 |
``` cpp
|
| 3555 |
constexpr year operator+(const years& x, const year& y) noexcept;
|
| 3556 |
```
|
| 3557 |
|
|
@@ -3823,11 +3836,11 @@ template<class charT, class traits>
|
|
| 3823 |
|
| 3824 |
*Effects:* Equivalent to:
|
| 3825 |
|
| 3826 |
``` cpp
|
| 3827 |
return os << (wd.ok() ?
|
| 3828 |
-
format(os.getloc(), STATICALLY-WIDEN<charT>("{:%a}"), wd) :
|
| 3829 |
format(os.getloc(), STATICALLY-WIDEN<charT>("{} is not a valid weekday"),
|
| 3830 |
static_cast<unsigned>(wd.wd_)));
|
| 3831 |
```
|
| 3832 |
|
| 3833 |
``` cpp
|
|
@@ -3935,12 +3948,12 @@ template<class charT, class traits>
|
|
| 3935 |
*Effects:* Equivalent to:
|
| 3936 |
|
| 3937 |
``` cpp
|
| 3938 |
auto i = wdi.index();
|
| 3939 |
return os << (i >= 1 && i <= 5 ?
|
| 3940 |
-
format(os.getloc(), STATICALLY-WIDEN<charT>("{}[{}]"), wdi.weekday(), i) :
|
| 3941 |
-
format(os.getloc(), STATICALLY-WIDEN<charT>("{}[{} is not a valid index]"),
|
| 3942 |
wdi.weekday(), i));
|
| 3943 |
```
|
| 3944 |
|
| 3945 |
### Class `weekday_last` <a id="time.cal.wdlast">[[time.cal.wdlast]]</a>
|
| 3946 |
|
|
@@ -4011,11 +4024,11 @@ template<class charT, class traits>
|
|
| 4011 |
```
|
| 4012 |
|
| 4013 |
*Effects:* Equivalent to:
|
| 4014 |
|
| 4015 |
``` cpp
|
| 4016 |
-
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}[last]"), wdl.weekday());
|
| 4017 |
```
|
| 4018 |
|
| 4019 |
### Class `month_day` <a id="time.cal.md">[[time.cal.md]]</a>
|
| 4020 |
|
| 4021 |
#### Overview <a id="time.cal.md.overview">[[time.cal.md.overview]]</a>
|
|
@@ -4099,11 +4112,11 @@ template<class charT, class traits>
|
|
| 4099 |
```
|
| 4100 |
|
| 4101 |
*Effects:* Equivalent to:
|
| 4102 |
|
| 4103 |
``` cpp
|
| 4104 |
-
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{}"),
|
| 4105 |
md.month(), md.day());
|
| 4106 |
```
|
| 4107 |
|
| 4108 |
``` cpp
|
| 4109 |
template<class charT, class traits, class Alloc = allocator<charT>>
|
|
@@ -4194,11 +4207,11 @@ template<class charT, class traits>
|
|
| 4194 |
```
|
| 4195 |
|
| 4196 |
*Effects:* Equivalent to:
|
| 4197 |
|
| 4198 |
``` cpp
|
| 4199 |
-
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/last"), mdl.month());
|
| 4200 |
```
|
| 4201 |
|
| 4202 |
### Class `month_weekday` <a id="time.cal.mwd">[[time.cal.mwd]]</a>
|
| 4203 |
|
| 4204 |
#### Overview <a id="time.cal.mwd.overview">[[time.cal.mwd.overview]]</a>
|
|
@@ -4277,11 +4290,11 @@ template<class charT, class traits>
|
|
| 4277 |
```
|
| 4278 |
|
| 4279 |
*Effects:* Equivalent to:
|
| 4280 |
|
| 4281 |
``` cpp
|
| 4282 |
-
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{}"),
|
| 4283 |
mwd.month(), mwd.weekday_indexed());
|
| 4284 |
```
|
| 4285 |
|
| 4286 |
### Class `month_weekday_last` <a id="time.cal.mwdlast">[[time.cal.mwdlast]]</a>
|
| 4287 |
|
|
@@ -4364,11 +4377,11 @@ template<class charT, class traits>
|
|
| 4364 |
```
|
| 4365 |
|
| 4366 |
*Effects:* Equivalent to:
|
| 4367 |
|
| 4368 |
``` cpp
|
| 4369 |
-
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{}"),
|
| 4370 |
mwdl.month(), mwdl.weekday_last());
|
| 4371 |
```
|
| 4372 |
|
| 4373 |
### Class `year_month` <a id="time.cal.ym">[[time.cal.ym]]</a>
|
| 4374 |
|
|
@@ -4564,11 +4577,11 @@ template<class charT, class traits>
|
|
| 4564 |
```
|
| 4565 |
|
| 4566 |
*Effects:* Equivalent to:
|
| 4567 |
|
| 4568 |
``` cpp
|
| 4569 |
-
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{}"),
|
| 4570 |
ym.year(), ym.month());
|
| 4571 |
```
|
| 4572 |
|
| 4573 |
``` cpp
|
| 4574 |
template<class charT, class traits, class Alloc = allocator<charT>>
|
|
@@ -4654,11 +4667,11 @@ constexpr year_month_day(const year_month_day_last& ymdl) noexcept;
|
|
| 4654 |
|
| 4655 |
*Effects:* Initializes `y_` with `ymdl.year()`, `m_` with
|
| 4656 |
`ymdl.month()`, and `d_` with `ymdl.day()`.
|
| 4657 |
|
| 4658 |
[*Note 1*: This conversion from `year_month_day_last` to
|
| 4659 |
-
`year_month_day`
|
| 4660 |
`year_month_day_last` to a `sys_days`, and then converting that
|
| 4661 |
`sys_days` to a `year_month_day`. — *end note*]
|
| 4662 |
|
| 4663 |
``` cpp
|
| 4664 |
constexpr year_month_day(const sys_days& dp) noexcept;
|
|
@@ -4838,11 +4851,11 @@ constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) n
|
|
| 4838 |
```
|
| 4839 |
|
| 4840 |
*Returns:* `(ymd.year() + dy) / ymd.month() / ymd.day()`.
|
| 4841 |
|
| 4842 |
[*Note 2*: If `ymd.month()` is February and `ymd.day()` is not in the
|
| 4843 |
-
range \[`1d`, `28d`\], `ok()`
|
| 4844 |
`year_month_day`. — *end note*]
|
| 4845 |
|
| 4846 |
``` cpp
|
| 4847 |
constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept;
|
| 4848 |
```
|
|
@@ -5011,11 +5024,11 @@ constexpr chrono::day day() const noexcept;
|
|
| 5011 |
|
| 5012 |
*Returns:* If `ok()` is `true`, returns a `day` representing the last
|
| 5013 |
day of the (`year`, `month`) pair represented by `*this`. Otherwise, the
|
| 5014 |
returned value is unspecified.
|
| 5015 |
|
| 5016 |
-
[*Note 1*: This value
|
| 5017 |
|
| 5018 |
``` cpp
|
| 5019 |
constexpr operator sys_days() const noexcept;
|
| 5020 |
```
|
| 5021 |
|
|
@@ -5118,11 +5131,11 @@ template<class charT, class traits>
|
|
| 5118 |
```
|
| 5119 |
|
| 5120 |
*Effects:* Equivalent to:
|
| 5121 |
|
| 5122 |
``` cpp
|
| 5123 |
-
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{}"),
|
| 5124 |
ymdl.year(), ymdl.month_day_last());
|
| 5125 |
```
|
| 5126 |
|
| 5127 |
### Class `year_month_weekday` <a id="time.cal.ymwd">[[time.cal.ymwd]]</a>
|
| 5128 |
|
|
@@ -5190,12 +5203,12 @@ constexpr year_month_weekday(const sys_days& dp) noexcept;
|
|
| 5190 |
```
|
| 5191 |
|
| 5192 |
*Effects:* Constructs an object of type `year_month_weekday` which
|
| 5193 |
corresponds to the date represented by `dp`.
|
| 5194 |
|
| 5195 |
-
*Remarks:* For any value `
|
| 5196 |
-
`
|
| 5197 |
`true`.
|
| 5198 |
|
| 5199 |
``` cpp
|
| 5200 |
constexpr explicit year_month_weekday(const local_days& dp) noexcept;
|
| 5201 |
```
|
|
@@ -5369,11 +5382,11 @@ template<class charT, class traits>
|
|
| 5369 |
```
|
| 5370 |
|
| 5371 |
*Effects:* Equivalent to:
|
| 5372 |
|
| 5373 |
``` cpp
|
| 5374 |
-
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{}/{}"),
|
| 5375 |
ymwd.year(), ymwd.month(), ymwd.weekday_indexed());
|
| 5376 |
```
|
| 5377 |
|
| 5378 |
### Class `year_month_weekday_last` <a id="time.cal.ymwdlast">[[time.cal.ymwdlast]]</a>
|
| 5379 |
|
|
@@ -5596,11 +5609,11 @@ template<class charT, class traits>
|
|
| 5596 |
```
|
| 5597 |
|
| 5598 |
*Effects:* Equivalent to:
|
| 5599 |
|
| 5600 |
``` cpp
|
| 5601 |
-
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{}/{}"),
|
| 5602 |
ymwdl.year(), ymwdl.month(), ymwdl.weekday_last());
|
| 5603 |
```
|
| 5604 |
|
| 5605 |
### Conventional syntax operators <a id="time.cal.operators">[[time.cal.operators]]</a>
|
| 5606 |
|
|
@@ -5974,11 +5987,11 @@ the time is split. A `hh_mm_ss` models negative durations with a
|
|
| 5974 |
distinct `is_negative` getter that returns `true` when the input
|
| 5975 |
duration is negative. The individual duration fields always return
|
| 5976 |
non-negative durations even when `is_negative()` indicates the structure
|
| 5977 |
is representing a negative duration.
|
| 5978 |
|
| 5979 |
-
If `Duration` is not
|
| 5980 |
ill-formed.
|
| 5981 |
|
| 5982 |
### Members <a id="time.hms.members">[[time.hms.members]]</a>
|
| 5983 |
|
| 5984 |
``` cpp
|
|
@@ -6107,11 +6120,11 @@ operator<<(basic_ostream<charT, traits>& os, const hh_mm_ss<Duration>& hms);
|
|
| 6107 |
```
|
| 6108 |
|
| 6109 |
*Effects:* Equivalent to:
|
| 6110 |
|
| 6111 |
``` cpp
|
| 6112 |
-
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:%T}"), hms);
|
| 6113 |
```
|
| 6114 |
|
| 6115 |
[*Example 1*:
|
| 6116 |
|
| 6117 |
``` cpp
|
|
@@ -6211,11 +6224,11 @@ const time_zone* locate_zone(string_view tz_name) const;
|
|
| 6211 |
|
| 6212 |
[*Note 1*: A `time_zone_link` specifies an alternative name for a
|
| 6213 |
`time_zone`. — *end note*]
|
| 6214 |
|
| 6215 |
*Throws:* If a `const time_zone*` cannot be found as described in the
|
| 6216 |
-
*Returns:*
|
| 6217 |
|
| 6218 |
[*Note 2*: On non-exceptional return, the return value is always a
|
| 6219 |
pointer to a valid `time_zone`. — *end note*]
|
| 6220 |
|
| 6221 |
``` cpp
|
|
@@ -6283,19 +6296,19 @@ const_iterator erase_after(const_iterator p);
|
|
| 6283 |
|
| 6284 |
*Preconditions:* The iterator following `p` is dereferenceable.
|
| 6285 |
|
| 6286 |
*Effects:* Erases the `tzdb` referred to by the iterator following `p`.
|
| 6287 |
|
| 6288 |
-
*Returns:* An iterator pointing to the element following the one that
|
| 6289 |
-
was erased, or `end()` if no such element exists.
|
| 6290 |
-
|
| 6291 |
*Ensures:* No pointers, references, or iterators are invalidated except
|
| 6292 |
those referring to the erased `tzdb`.
|
| 6293 |
|
| 6294 |
[*Note 2*: It is not possible to erase the `tzdb` referred to by
|
| 6295 |
`begin()`. — *end note*]
|
| 6296 |
|
|
|
|
|
|
|
|
|
|
| 6297 |
*Throws:* Nothing.
|
| 6298 |
|
| 6299 |
``` cpp
|
| 6300 |
const_iterator begin() const noexcept;
|
| 6301 |
```
|
|
@@ -6816,32 +6829,32 @@ namespace std::chrono {
|
|
| 6816 |
zoned_time(const sys_time<Duration>& st);
|
| 6817 |
explicit zoned_time(TimeZonePtr z);
|
| 6818 |
explicit zoned_time(string_view name);
|
| 6819 |
|
| 6820 |
template<class Duration2>
|
| 6821 |
-
zoned_time(const zoned_time<Duration2, TimeZonePtr>&
|
| 6822 |
|
| 6823 |
zoned_time(TimeZonePtr z, const sys_time<Duration>& st);
|
| 6824 |
zoned_time(string_view name, const sys_time<Duration>& st);
|
| 6825 |
|
| 6826 |
zoned_time(TimeZonePtr z, const local_time<Duration>& tp);
|
| 6827 |
zoned_time(string_view name, const local_time<Duration>& tp);
|
| 6828 |
zoned_time(TimeZonePtr z, const local_time<Duration>& tp, choose c);
|
| 6829 |
zoned_time(string_view name, const local_time<Duration>& tp, choose c);
|
| 6830 |
|
| 6831 |
template<class Duration2, class TimeZonePtr2>
|
| 6832 |
-
zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>&
|
| 6833 |
template<class Duration2, class TimeZonePtr2>
|
| 6834 |
-
zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>&
|
| 6835 |
|
| 6836 |
template<class Duration2, class TimeZonePtr2>
|
| 6837 |
-
zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>&
|
| 6838 |
template<class Duration2, class TimeZonePtr2>
|
| 6839 |
-
zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>&
|
| 6840 |
|
| 6841 |
zoned_time& operator=(const sys_time<Duration>& st);
|
| 6842 |
-
zoned_time& operator=(const local_time<Duration>&
|
| 6843 |
|
| 6844 |
operator sys_time<duration>() const;
|
| 6845 |
explicit operator local_time<duration>() const;
|
| 6846 |
|
| 6847 |
TimeZonePtr get_time_zone() const;
|
|
@@ -6967,22 +6980,22 @@ zoned_time(string_view name, const sys_time<Duration>& st);
|
|
| 6967 |
|
| 6968 |
``` cpp
|
| 6969 |
zoned_time(TimeZonePtr z, const local_time<Duration>& tp);
|
| 6970 |
```
|
| 6971 |
|
| 6972 |
-
*Preconditions:* `z` refers to a time zone.
|
| 6973 |
-
|
| 6974 |
*Constraints:*
|
| 6975 |
|
| 6976 |
``` cpp
|
| 6977 |
is_convertible_v<
|
| 6978 |
decltype(declval<TimeZonePtr&>()->to_sys(local_time<Duration>{})),
|
| 6979 |
sys_time<duration>>
|
| 6980 |
```
|
| 6981 |
|
| 6982 |
is `true`.
|
| 6983 |
|
|
|
|
|
|
|
| 6984 |
*Effects:* Initializes `zone_` with `std::move(z)` and `tp_` with
|
| 6985 |
`zone_->to_sys(tp)`.
|
| 6986 |
|
| 6987 |
``` cpp
|
| 6988 |
zoned_time(string_view name, const local_time<Duration>& tp);
|
|
@@ -6996,22 +7009,22 @@ zoned_time(string_view name, const local_time<Duration>& tp);
|
|
| 6996 |
|
| 6997 |
``` cpp
|
| 6998 |
zoned_time(TimeZonePtr z, const local_time<Duration>& tp, choose c);
|
| 6999 |
```
|
| 7000 |
|
| 7001 |
-
*Preconditions:* `z` refers to a time zone.
|
| 7002 |
-
|
| 7003 |
*Constraints:*
|
| 7004 |
|
| 7005 |
``` cpp
|
| 7006 |
is_convertible_v<
|
| 7007 |
decltype(declval<TimeZonePtr&>()->to_sys(local_time<Duration>{}, choose::earliest)),
|
| 7008 |
sys_time<duration>>
|
| 7009 |
```
|
| 7010 |
|
| 7011 |
is `true`.
|
| 7012 |
|
|
|
|
|
|
|
| 7013 |
*Effects:* Initializes `zone_` with `std::move(z)` and `tp_` with
|
| 7014 |
`zone_->to_sys(tp, c)`.
|
| 7015 |
|
| 7016 |
``` cpp
|
| 7017 |
zoned_time(string_view name, const local_time<Duration>& tp, choose c);
|
|
@@ -7147,14 +7160,15 @@ template<class charT, class traits, class Duration, class TimeZonePtr>
|
|
| 7147 |
basic_ostream<charT, traits>&
|
| 7148 |
operator<<(basic_ostream<charT, traits>& os,
|
| 7149 |
const zoned_time<Duration, TimeZonePtr>& t);
|
| 7150 |
```
|
| 7151 |
|
| 7152 |
-
*Effects:*
|
| 7153 |
-
using the format `"%F %T %Z"`.
|
| 7154 |
|
| 7155 |
-
|
|
|
|
|
|
|
| 7156 |
|
| 7157 |
### Class `leap_second` <a id="time.zone.leap">[[time.zone.leap]]</a>
|
| 7158 |
|
| 7159 |
#### Overview <a id="time.zone.leap.overview">[[time.zone.leap.overview]]</a>
|
| 7160 |
|
|
@@ -7232,11 +7246,11 @@ constexpr seconds value() const noexcept;
|
|
| 7232 |
```
|
| 7233 |
|
| 7234 |
*Returns:* `+1s` to indicate a positive leap second or `-1s` to indicate
|
| 7235 |
a negative leap second.
|
| 7236 |
|
| 7237 |
-
[*Note 1*: All leap seconds inserted up through
|
| 7238 |
seconds. — *end note*]
|
| 7239 |
|
| 7240 |
#### Non-member functions <a id="time.zone.leap.nonmembers">[[time.zone.leap.nonmembers]]</a>
|
| 7241 |
|
| 7242 |
``` cpp
|
|
@@ -7382,11 +7396,11 @@ The `parse` member functions of these formatters interpret the format
|
|
| 7382 |
specification as a *chrono-format-spec* according to the following
|
| 7383 |
syntax:
|
| 7384 |
|
| 7385 |
``` bnf
|
| 7386 |
chrono-format-spec
|
| 7387 |
-
fill-and-alignₒₚₜ widthₒₚₜ precisionₒₚₜ chrono-specsₒₚₜ
|
| 7388 |
```
|
| 7389 |
|
| 7390 |
``` bnf
|
| 7391 |
chrono-specs
|
| 7392 |
conversion-spec
|
|
@@ -7415,23 +7429,35 @@ type one of
|
|
| 7415 |
'p q Q r R S t T u U V w W x X y Y z Z %'
|
| 7416 |
```
|
| 7417 |
|
| 7418 |
The productions *fill-and-align*, *width*, and *precision* are described
|
| 7419 |
in [[format.string]]. Giving a *precision* specification in the
|
| 7420 |
-
*chrono-format-spec* is valid only for
|
| 7421 |
-
|
| 7422 |
-
|
| 7423 |
-
*chrono-format-spec* contains a
|
| 7424 |
-
|
| 7425 |
-
to the output.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7426 |
|
| 7427 |
Each conversion specifier *conversion-spec* is replaced by appropriate
|
| 7428 |
-
characters as described in [[time.format.spec]]
|
| 7429 |
-
|
| 7430 |
-
|
| 7431 |
-
|
| 7432 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7433 |
|
| 7434 |
The result of formatting a `std::chrono::duration` instance holding a
|
| 7435 |
negative value, or an `hh_mm_ss` object `h` for which `h.is_negative()`
|
| 7436 |
is `true`, is equivalent to the output of the corresponding positive
|
| 7437 |
value, with a `STATICALLY-WIDEN<charT>("-")` character sequence placed
|
|
@@ -7461,11 +7487,11 @@ If the type being formatted does not contain the information that the
|
|
| 7461 |
format flag needs, an exception of type `format_error` is thrown.
|
| 7462 |
|
| 7463 |
[*Example 2*: A `duration` does not contain enough information to
|
| 7464 |
format as a `weekday`. — *end example*]
|
| 7465 |
|
| 7466 |
-
However, if a flag refers to a “time of day” (e.g. `%H`, `%I`, `%p`,
|
| 7467 |
etc.), then a specialization of `duration` is interpreted as the time of
|
| 7468 |
day elapsed since midnight.
|
| 7469 |
|
| 7470 |
**Table: Meaning of conversion specifiers** <a id="time.format.spec">[time.format.spec]</a>
|
| 7471 |
|
|
@@ -7505,19 +7531,20 @@ day elapsed since midnight.
|
|
| 7505 |
| `%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 with `0`. The modified command `%OW` produces the locale's alternative representation. |
|
| 7506 |
| `%x` | The locale's date representation. The modified command `%Ex` produces the locale's alternate date representation. |
|
| 7507 |
| `%X` | The locale's time representation. The modified command `%EX` produces the locale's alternate time representation. |
|
| 7508 |
| `%y` | The last two decimal digits of the year. If the result is a single digit it is prefixed by `0`. The modified command `%Oy` produces the locale's alternative representation. The modified command `%Ey` produces the locale's alternative representation of offset from `%EC` (year only). |
|
| 7509 |
| `%Y` | The year as a decimal number. If the result is less than four digits it is left-padded with `0` to four digits. The modified command `%EY` produces the locale's alternative full year representation. |
|
| 7510 |
-
| `%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 `%Oz` insert a `:` between the hours and minutes: `-04:30`. If the offset information is not available, an exception of type `format_error` is thrown.
|
| 7511 |
| `%Z` | The time zone abbreviation. If the time zone abbreviation is not available, an exception of type `format_error` is thrown. |
|
| 7512 |
| `%%` | A `%` character. |
|
| 7513 |
|
| 7514 |
|
| 7515 |
If the *chrono-specs* is omitted, the chrono object is formatted as if
|
| 7516 |
-
by streaming it to `
|
| 7517 |
-
through the output iterator of the
|
| 7518 |
-
adjustments as specified by the
|
|
|
|
| 7519 |
|
| 7520 |
[*Example 3*:
|
| 7521 |
|
| 7522 |
``` cpp
|
| 7523 |
string s = format("{:=>8}", 42ms); // value of s is "====42ms"
|
|
@@ -7636,18 +7663,18 @@ value. If `%z` (or a modified variant of `%z`) is used and
|
|
| 7636 |
template<class Duration, class TimeZonePtr, class charT>
|
| 7637 |
struct formatter<chrono::zoned_time<Duration, TimeZonePtr>, charT>
|
| 7638 |
: formatter<chrono::local-time-format-t<Duration>, charT> {
|
| 7639 |
template<class FormatContext>
|
| 7640 |
typename FormatContext::iterator
|
| 7641 |
-
format(const chrono::zoned_time<Duration, TimeZonePtr>& tp, FormatContext& ctx);
|
| 7642 |
};
|
| 7643 |
```
|
| 7644 |
|
| 7645 |
``` cpp
|
| 7646 |
template<class FormatContext>
|
| 7647 |
typename FormatContext::iterator
|
| 7648 |
-
format(const chrono::zoned_time<Duration, TimeZonePtr>& tp, FormatContext& ctx);
|
| 7649 |
```
|
| 7650 |
|
| 7651 |
*Effects:* Equivalent to:
|
| 7652 |
|
| 7653 |
``` cpp
|
|
@@ -7663,94 +7690,130 @@ unqualified, so as to enable argument dependent lookup
|
|
| 7663 |
[[basic.lookup.argdep]]. In the following paragraphs, let `is` denote an
|
| 7664 |
object of type `basic_istream<charT, traits>` and let `I` be
|
| 7665 |
`basic_istream<charT, traits>&`, where `charT` and `traits` are template
|
| 7666 |
parameters in that context.
|
| 7667 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7668 |
``` cpp
|
|
|
|
|
|
|
|
|
|
| 7669 |
template<class charT, class traits, class Alloc, class Parsable>
|
| 7670 |
unspecified
|
| 7671 |
parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp);
|
| 7672 |
```
|
| 7673 |
|
|
|
|
|
|
|
|
|
|
| 7674 |
*Constraints:* The expression
|
| 7675 |
|
| 7676 |
``` cpp
|
| 7677 |
-
from_stream(declval<basic_istream<charT, traits>&>(),
|
| 7678 |
```
|
| 7679 |
|
| 7680 |
-
is well-formed when treated as an unevaluated
|
|
|
|
| 7681 |
|
| 7682 |
*Returns:* A manipulator such that the expression `is >> parse(fmt, tp)`
|
| 7683 |
-
has type `I`, has value `is`, and calls
|
| 7684 |
-
`from_stream(is, fmt.c_str(), tp)`.
|
| 7685 |
|
| 7686 |
``` cpp
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7687 |
template<class charT, class traits, class Alloc, class Parsable>
|
| 7688 |
unspecified
|
| 7689 |
parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp,
|
| 7690 |
basic_string<charT, traits, Alloc>& abbrev);
|
| 7691 |
```
|
| 7692 |
|
|
|
|
|
|
|
|
|
|
| 7693 |
*Constraints:* The expression
|
| 7694 |
|
| 7695 |
``` cpp
|
| 7696 |
-
from_stream(declval<basic_istream<charT, traits>&>(),
|
| 7697 |
```
|
| 7698 |
|
| 7699 |
-
is well-formed when treated as an unevaluated
|
|
|
|
| 7700 |
|
| 7701 |
*Returns:* A manipulator such that the expression
|
| 7702 |
`is >> parse(fmt, tp, abbrev)` has type `I`, has value `is`, and calls
|
| 7703 |
-
`from_stream(is,
|
| 7704 |
|
| 7705 |
``` cpp
|
|
|
|
|
|
|
|
|
|
| 7706 |
template<class charT, class traits, class Alloc, class Parsable>
|
| 7707 |
unspecified
|
| 7708 |
parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp,
|
| 7709 |
minutes& offset);
|
| 7710 |
```
|
| 7711 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7712 |
*Constraints:* The expression
|
| 7713 |
|
| 7714 |
``` cpp
|
| 7715 |
from_stream(declval<basic_istream<charT, traits>&>(),
|
| 7716 |
-
|
| 7717 |
declval<basic_string<charT, traits, Alloc>*>(),
|
| 7718 |
&offset)
|
| 7719 |
```
|
| 7720 |
|
| 7721 |
-
is well-formed when treated as an unevaluated
|
|
|
|
| 7722 |
|
| 7723 |
*Returns:* A manipulator such that the expression
|
| 7724 |
`is >> parse(fmt, tp, offset)` has type `I`, has value `is`, and calls:
|
| 7725 |
|
| 7726 |
``` cpp
|
| 7727 |
from_stream(is,
|
| 7728 |
-
|
| 7729 |
static_cast<basic_string<charT, traits, Alloc>*>(nullptr),
|
| 7730 |
&offset)
|
| 7731 |
```
|
| 7732 |
|
| 7733 |
``` cpp
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7734 |
template<class charT, class traits, class Alloc, class Parsable>
|
| 7735 |
unspecified
|
| 7736 |
parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp,
|
| 7737 |
basic_string<charT, traits, Alloc>& abbrev, minutes& offset);
|
| 7738 |
```
|
| 7739 |
|
|
|
|
|
|
|
|
|
|
| 7740 |
*Constraints:* The expression
|
| 7741 |
|
| 7742 |
``` cpp
|
| 7743 |
from_stream(declval<basic_istream<charT, traits>&>(),
|
| 7744 |
-
|
| 7745 |
```
|
| 7746 |
|
| 7747 |
-
is well-formed when treated as an unevaluated
|
|
|
|
| 7748 |
|
| 7749 |
*Returns:* A manipulator such that the expression
|
| 7750 |
`is >> parse(fmt, tp, abbrev, offset)` has type `I`, has value `is`, and
|
| 7751 |
-
calls `from_stream(is,
|
| 7752 |
|
| 7753 |
All `from_stream` overloads behave as unformatted input functions,
|
| 7754 |
except that they have an unspecified effect on the value returned by
|
| 7755 |
subsequent calls to `basic_istream<>::gcount()`. Each overload takes a
|
| 7756 |
format string containing ordinary characters and flags which have
|
|
@@ -7759,33 +7822,70 @@ by `E` or `O`. During parsing each flag interprets characters as parts
|
|
| 7759 |
of date and time types according to [[time.parse.spec]]. Some flags can
|
| 7760 |
be modified by a width parameter given as a positive decimal integer
|
| 7761 |
called out as `N` below which governs how many characters are parsed
|
| 7762 |
from the stream in interpreting the flag. All characters in the format
|
| 7763 |
string that are not represented in [[time.parse.spec]], except for
|
| 7764 |
-
|
| 7765 |
-
|
| 7766 |
-
stream.
|
| 7767 |
|
| 7768 |
If the type being parsed cannot represent the information that the
|
| 7769 |
format flag refers to, `is.setstate(ios_base::failbit)` is called.
|
| 7770 |
|
| 7771 |
[*Example 1*: A `duration` cannot represent a
|
| 7772 |
`weekday`. — *end example*]
|
| 7773 |
|
| 7774 |
-
However, if a flag refers to a “time of day” (e.g. `%H`, `%I`, `%p`,
|
| 7775 |
etc.), then a specialization of `duration` is parsed as the time of day
|
| 7776 |
elapsed since midnight.
|
| 7777 |
|
| 7778 |
If the `from_stream` overload fails to parse everything specified by the
|
| 7779 |
format string, or if insufficient information is parsed to specify a
|
| 7780 |
complete duration, time point, or calendrical data structure,
|
| 7781 |
`setstate(ios_base::failbit)` is called on the `basic_istream`.
|
| 7782 |
|
| 7783 |
-
|
| 7784 |
-
|
| 7785 |
-
|
| 7786 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7787 |
|
| 7788 |
## Header `<ctime>` synopsis <a id="ctime.syn">[[ctime.syn]]</a>
|
| 7789 |
|
| 7790 |
``` cpp
|
| 7791 |
#define NULL see [support.types.nullptr]
|
|
@@ -7800,18 +7900,18 @@ namespace std {
|
|
| 7800 |
struct timespec;
|
| 7801 |
struct tm;
|
| 7802 |
|
| 7803 |
clock_t clock();
|
| 7804 |
double difftime(time_t time1, time_t time0);
|
| 7805 |
-
time_t mktime(
|
| 7806 |
time_t time(time_t* timer);
|
| 7807 |
int timespec_get(timespec* ts, int base);
|
| 7808 |
-
char* asctime(const
|
| 7809 |
char* ctime(const time_t* timer);
|
| 7810 |
-
|
| 7811 |
-
|
| 7812 |
-
size_t strftime(char* s, size_t maxsize, const char* format, const
|
| 7813 |
}
|
| 7814 |
```
|
| 7815 |
|
| 7816 |
The contents of the header `<ctime>` are the same as the C standard
|
| 7817 |
library header `<time.h>`.[^1]
|
|
@@ -7824,22 +7924,25 @@ See also: ISO C 7.27
|
|
| 7824 |
<!-- Link reference definitions -->
|
| 7825 |
[basic.lookup.argdep]: basic.md#basic.lookup.argdep
|
| 7826 |
[cpp17.equalitycomparable]: #cpp17.equalitycomparable
|
| 7827 |
[cpp17.lessthancomparable]: #cpp17.lessthancomparable
|
| 7828 |
[ctime.syn]: #ctime.syn
|
|
|
|
| 7829 |
[filesystems]: input.md#filesystems
|
| 7830 |
[format.formatter]: utilities.md#format.formatter
|
| 7831 |
[format.string]: utilities.md#format.string
|
| 7832 |
[formatter.requirements]: utilities.md#formatter.requirements
|
| 7833 |
[intro.multithread]: basic.md#intro.multithread
|
| 7834 |
-
[
|
|
|
|
| 7835 |
[numeric.requirements]: numerics.md#numeric.requirements
|
| 7836 |
[over.ics.rank]: over.md#over.ics.rank
|
| 7837 |
[over.match.class.deduct]: over.md#over.match.class.deduct
|
| 7838 |
[res.on.data.races]: library.md#res.on.data.races
|
| 7839 |
[swappable.requirements]: library.md#swappable.requirements
|
| 7840 |
[temp.deduct]: temp.md#temp.deduct
|
|
|
|
| 7841 |
[time]: #time
|
| 7842 |
[time.12]: #time.12
|
| 7843 |
[time.cal]: #time.cal
|
| 7844 |
[time.cal.day]: #time.cal.day
|
| 7845 |
[time.cal.day.members]: #time.cal.day.members
|
|
@@ -7911,10 +8014,11 @@ See also: ISO C 7.27
|
|
| 7911 |
[time.clock.conv]: #time.clock.conv
|
| 7912 |
[time.clock.file]: #time.clock.file
|
| 7913 |
[time.clock.file.members]: #time.clock.file.members
|
| 7914 |
[time.clock.file.nonmembers]: #time.clock.file.nonmembers
|
| 7915 |
[time.clock.file.overview]: #time.clock.file.overview
|
|
|
|
| 7916 |
[time.clock.gps]: #time.clock.gps
|
| 7917 |
[time.clock.gps.members]: #time.clock.gps.members
|
| 7918 |
[time.clock.gps.nonmembers]: #time.clock.gps.nonmembers
|
| 7919 |
[time.clock.gps.overview]: #time.clock.gps.overview
|
| 7920 |
[time.clock.hires]: #time.clock.hires
|
|
@@ -7937,10 +8041,11 @@ See also: ISO C 7.27
|
|
| 7937 |
[time.duration.alg]: #time.duration.alg
|
| 7938 |
[time.duration.arithmetic]: #time.duration.arithmetic
|
| 7939 |
[time.duration.cast]: #time.duration.cast
|
| 7940 |
[time.duration.comparisons]: #time.duration.comparisons
|
| 7941 |
[time.duration.cons]: #time.duration.cons
|
|
|
|
| 7942 |
[time.duration.io]: #time.duration.io
|
| 7943 |
[time.duration.literals]: #time.duration.literals
|
| 7944 |
[time.duration.nonmember]: #time.duration.nonmember
|
| 7945 |
[time.duration.observer]: #time.duration.observer
|
| 7946 |
[time.duration.special]: #time.duration.special
|
|
@@ -7957,10 +8062,11 @@ See also: ISO C 7.27
|
|
| 7957 |
[time.point]: #time.point
|
| 7958 |
[time.point.arithmetic]: #time.point.arithmetic
|
| 7959 |
[time.point.cast]: #time.point.cast
|
| 7960 |
[time.point.comparisons]: #time.point.comparisons
|
| 7961 |
[time.point.cons]: #time.point.cons
|
|
|
|
| 7962 |
[time.point.nonmember]: #time.point.nonmember
|
| 7963 |
[time.point.observer]: #time.point.observer
|
| 7964 |
[time.point.special]: #time.point.special
|
| 7965 |
[time.summary]: #time.summary
|
| 7966 |
[time.syn]: #time.syn
|
|
|
|
| 30 |
## Header `<chrono>` synopsis <a id="time.syn">[[time.syn]]</a>
|
| 31 |
|
| 32 |
``` cpp
|
| 33 |
#include <compare> // see [compare.syn]
|
| 34 |
|
| 35 |
+
namespace std::chrono {
|
|
|
|
| 36 |
// [time.duration], class template duration
|
| 37 |
template<class Rep, class Period = ratio<1>> class duration;
|
| 38 |
|
| 39 |
// [time.point], class template time_point
|
| 40 |
template<class Clock, class Duration = typename Clock::duration> class time_point;
|
| 41 |
}
|
| 42 |
|
| 43 |
+
namespace std {
|
| 44 |
// [time.traits.specializations], common_type specializations
|
| 45 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 46 |
struct common_type<chrono::duration<Rep1, Period1>,
|
| 47 |
chrono::duration<Rep2, Period2>>;
|
| 48 |
|
| 49 |
template<class Clock, class Duration1, class Duration2>
|
| 50 |
struct common_type<chrono::time_point<Clock, Duration1>,
|
| 51 |
chrono::time_point<Clock, Duration2>>;
|
| 52 |
+
}
|
| 53 |
|
| 54 |
+
namespace std::chrono {
|
| 55 |
// [time.traits], customization traits
|
| 56 |
template<class Rep> struct treat_as_floating_point;
|
| 57 |
template<class Rep>
|
| 58 |
+
constexpr bool treat_as_floating_point_v = treat_as_floating_point<Rep>::value;
|
| 59 |
|
| 60 |
template<class Rep> struct duration_values;
|
| 61 |
|
| 62 |
template<class T> struct is_clock;
|
| 63 |
+
template<class T> constexpr bool is_clock_v = is_clock<T>::value;
|
| 64 |
|
| 65 |
// [time.duration.nonmember], duration arithmetic
|
| 66 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 67 |
constexpr common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
|
| 68 |
operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
|
|
|
| 562 |
constexpr year_month_weekday
|
| 563 |
operator-(const year_month_weekday& ymwd, const years& dy) noexcept;
|
| 564 |
|
| 565 |
template<class charT, class traits>
|
| 566 |
basic_ostream<charT, traits>&
|
| 567 |
+
operator<<(basic_ostream<charT, traits>& os, const year_month_weekday& ymwd);
|
| 568 |
|
| 569 |
// [time.cal.ymwdlast], class year_month_weekday_last
|
| 570 |
class year_month_weekday_last;
|
| 571 |
|
| 572 |
constexpr bool operator==(const year_month_weekday_last& x,
|
|
|
|
| 738 |
const zoned_time<Duration, TimeZonePtr>& t);
|
| 739 |
|
| 740 |
// [time.zone.leap], leap second support
|
| 741 |
class leap_second;
|
| 742 |
|
| 743 |
+
constexpr bool operator==(const leap_second& x, const leap_second& y);
|
| 744 |
+
constexpr strong_ordering operator<=>(const leap_second& x, const leap_second& y);
|
| 745 |
|
| 746 |
template<class Duration>
|
| 747 |
+
constexpr bool operator==(const leap_second& x, const sys_time<Duration>& y);
|
| 748 |
template<class Duration>
|
| 749 |
+
constexpr bool operator< (const leap_second& x, const sys_time<Duration>& y);
|
| 750 |
template<class Duration>
|
| 751 |
+
constexpr bool operator< (const sys_time<Duration>& x, const leap_second& y);
|
| 752 |
template<class Duration>
|
| 753 |
+
constexpr bool operator> (const leap_second& x, const sys_time<Duration>& y);
|
| 754 |
template<class Duration>
|
| 755 |
+
constexpr bool operator> (const sys_time<Duration>& x, const leap_second& y);
|
| 756 |
template<class Duration>
|
| 757 |
+
constexpr bool operator<=(const leap_second& x, const sys_time<Duration>& y);
|
| 758 |
template<class Duration>
|
| 759 |
+
constexpr bool operator<=(const sys_time<Duration>& x, const leap_second& y);
|
| 760 |
template<class Duration>
|
| 761 |
+
constexpr bool operator>=(const leap_second& x, const sys_time<Duration>& y);
|
| 762 |
template<class Duration>
|
| 763 |
+
constexpr bool operator>=(const sys_time<Duration>& x, const leap_second& y);
|
| 764 |
template<class Duration>
|
| 765 |
requires three_way_comparable_with<sys_seconds, sys_time<Duration>>
|
| 766 |
constexpr auto operator<=>(const leap_second& x, const sys_time<Duration>& y);
|
| 767 |
|
| 768 |
// [time.zone.link], class time_zone_link
|
|
|
|
| 777 |
local-time-format-t<Duration>
|
| 778 |
local_time_format(local_time<Duration> time, const string* abbrev = nullptr,
|
| 779 |
const seconds* offset_sec = nullptr);
|
| 780 |
}
|
| 781 |
|
| 782 |
+
namespace std {
|
| 783 |
template<class Rep, class Period, class charT>
|
| 784 |
struct formatter<chrono::duration<Rep, Period>, charT>;
|
| 785 |
template<class Duration, class charT>
|
| 786 |
struct formatter<chrono::sys_time<Duration>, charT>;
|
| 787 |
template<class Duration, class charT>
|
|
|
|
| 815 |
struct formatter<chrono::hh_mm_ss<duration<Rep, Period>>, charT>;
|
| 816 |
template<class charT> struct formatter<chrono::sys_info, charT>;
|
| 817 |
template<class charT> struct formatter<chrono::local_info, charT>;
|
| 818 |
template<class Duration, class TimeZonePtr, class charT>
|
| 819 |
struct formatter<chrono::zoned_time<Duration, TimeZonePtr>, charT>;
|
| 820 |
+
}
|
| 821 |
|
| 822 |
+
namespace std::chrono {
|
| 823 |
// [time.parse], parsing
|
| 824 |
+
template<class charT, class Parsable>
|
| 825 |
+
unspecified
|
| 826 |
+
parse(const charT* fmt, Parsable& tp);
|
| 827 |
template<class charT, class traits, class Alloc, class Parsable>
|
| 828 |
unspecified
|
| 829 |
+
parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp);
|
| 830 |
|
| 831 |
template<class charT, class traits, class Alloc, class Parsable>
|
| 832 |
unspecified
|
| 833 |
+
parse(const charT* fmt, Parsable& tp,
|
| 834 |
+
basic_string<charT, traits, Alloc>& abbrev);
|
| 835 |
+
template<class charT, class traits, class Alloc, class Parsable>
|
| 836 |
+
unspecified
|
| 837 |
+
parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp,
|
| 838 |
basic_string<charT, traits, Alloc>& abbrev);
|
| 839 |
|
| 840 |
+
template<class charT, class Parsable>
|
| 841 |
+
unspecified
|
| 842 |
+
parse(const charT* fmt, Parsable& tp, minutes& offset);
|
| 843 |
template<class charT, class traits, class Alloc, class Parsable>
|
| 844 |
unspecified
|
| 845 |
+
parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp,
|
| 846 |
minutes& offset);
|
| 847 |
|
| 848 |
template<class charT, class traits, class Alloc, class Parsable>
|
| 849 |
unspecified
|
| 850 |
+
parse(const charT* fmt, Parsable& tp,
|
| 851 |
+
basic_string<charT, traits, Alloc>& abbrev, minutes& offset);
|
| 852 |
+
template<class charT, class traits, class Alloc, class Parsable>
|
| 853 |
+
unspecified
|
| 854 |
+
parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp,
|
| 855 |
basic_string<charT, traits, Alloc>& abbrev, minutes& offset);
|
| 856 |
|
| 857 |
// calendrical constants
|
| 858 |
inline constexpr last_spec last{};
|
| 859 |
|
|
|
|
| 877 |
inline constexpr month October{10};
|
| 878 |
inline constexpr month November{11};
|
| 879 |
inline constexpr month December{12};
|
| 880 |
}
|
| 881 |
|
| 882 |
+
namespace std::inline literals::inline chrono_literals {
|
|
|
|
| 883 |
// [time.duration.literals], suffixes for duration literals
|
| 884 |
constexpr chrono::hours operator""h(unsigned long long);
|
| 885 |
constexpr chrono::duration<unspecified, ratio<3600, 1>> operator""h(long double);
|
| 886 |
|
| 887 |
constexpr chrono::minutes operator""min(unsigned long long);
|
|
|
|
| 903 |
constexpr chrono::day operator""d(unsigned long long d) noexcept;
|
| 904 |
|
| 905 |
// [time.cal.year.nonmembers], non-member functions
|
| 906 |
constexpr chrono::year operator""y(unsigned long long y) noexcept;
|
| 907 |
}
|
|
|
|
| 908 |
|
| 909 |
+
namespace std::chrono {
|
| 910 |
using namespace literals::chrono_literals;
|
| 911 |
}
|
|
|
|
| 912 |
```
|
| 913 |
|
| 914 |
## *Cpp17Clock* requirements <a id="time.clock.req">[[time.clock.req]]</a>
|
| 915 |
|
| 916 |
A clock is a bundle consisting of a `duration`, a `time_point`, and a
|
|
|
|
| 930 |
by a given clock and the SI definition is a measure of the quality of
|
| 931 |
implementation. — *end note*]
|
| 932 |
|
| 933 |
A type `TC` meets the *Cpp17TrivialClock* requirements if:
|
| 934 |
|
| 935 |
+
- `TC` meets the *Cpp17Clock* requirements,
|
| 936 |
- the types `TC::rep`, `TC::duration`, and `TC::time_point` meet the
|
| 937 |
*Cpp17EqualityComparable* ([[cpp17.equalitycomparable]]) and
|
| 938 |
+
*Cpp17LessThanComparable* ([[cpp17.lessthancomparable]]) and
|
| 939 |
+
*Cpp17Swappable* [[swappable.requirements]] requirements and the
|
| 940 |
+
requirements of numeric types [[numeric.requirements]],
|
| 941 |
\[*Note 3*: This means, in particular, that operations on these types
|
| 942 |
will not throw exceptions. — *end note*]
|
|
|
|
|
|
|
| 943 |
- the function `TC::now()` does not throw exceptions, and
|
| 944 |
- the type `TC::time_point::clock` meets the *Cpp17TrivialClock*
|
| 945 |
requirements, recursively.
|
| 946 |
|
| 947 |
## Time-related traits <a id="time.traits">[[time.traits]]</a>
|
|
|
|
| 978 |
};
|
| 979 |
```
|
| 980 |
|
| 981 |
The `duration` template uses the `duration_values` trait to construct
|
| 982 |
special values of the duration’s representation (`Rep`). This is done
|
| 983 |
+
because the representation can be a class type with behavior that
|
| 984 |
requires some other implementation to return these special values. In
|
| 985 |
that case, the author of that class type should specialize
|
| 986 |
`duration_values` to return the indicated values.
|
| 987 |
|
| 988 |
``` cpp
|
| 989 |
static constexpr Rep zero() noexcept;
|
| 990 |
```
|
| 991 |
|
| 992 |
*Returns:* `Rep(0)`.
|
| 993 |
|
| 994 |
+
[*Note 1*: `Rep(0)` is specified instead of `Rep()` because `Rep()` can
|
| 995 |
have some other meaning, such as an uninitialized value. — *end note*]
|
| 996 |
|
| 997 |
*Remarks:* The value returned shall be the additive identity.
|
| 998 |
|
| 999 |
``` cpp
|
|
|
|
| 1032 |
[*Note 2*: The `typedef` name `type` is a synonym for the `duration`
|
| 1033 |
with the largest tick `period` possible where both `duration` arguments
|
| 1034 |
will convert to it without requiring a division operation. The
|
| 1035 |
representation of this type is intended to be able to hold any value
|
| 1036 |
resulting from this conversion with no truncation error, although
|
| 1037 |
+
floating-point durations can have round-off errors. — *end note*]
|
| 1038 |
|
| 1039 |
``` cpp
|
| 1040 |
template<class Clock, class Duration1, class Duration2>
|
| 1041 |
struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>> {
|
| 1042 |
using type = chrono::time_point<Clock, common_type_t<Duration1, Duration2>>;
|
|
|
|
| 1062 |
*Cpp17Clock* unless it meets all of the following conditions:
|
| 1063 |
|
| 1064 |
- the *qualified-id*s `T::rep`, `T::period`, `T::duration`, and
|
| 1065 |
`T::time_point` are valid and each denotes a type [[temp.deduct]],
|
| 1066 |
- the expression `T::is_steady` is well-formed when treated as an
|
| 1067 |
+
unevaluated operand [[term.unevaluated.operand]],
|
| 1068 |
- the expression `T::now()` is well-formed when treated as an
|
| 1069 |
unevaluated operand.
|
| 1070 |
|
| 1071 |
The behavior of a program that adds specializations for `is_clock` is
|
| 1072 |
undefined.
|
| 1073 |
|
| 1074 |
## Class template `duration` <a id="time.duration">[[time.duration]]</a>
|
| 1075 |
|
| 1076 |
+
### General <a id="time.duration.general">[[time.duration.general]]</a>
|
| 1077 |
+
|
| 1078 |
A `duration` type measures time between two points in time
|
| 1079 |
(`time_point`s). A `duration` has a representation which holds a count
|
| 1080 |
of ticks and a tick period. The tick period is the amount of time which
|
| 1081 |
occurs from one tick to the next, in units of seconds. It is expressed
|
| 1082 |
as a rational constant using the template `ratio`.
|
|
|
|
| 1140 |
Members of `duration` do not throw exceptions other than those thrown by
|
| 1141 |
the indicated operations on their representations.
|
| 1142 |
|
| 1143 |
The defaulted copy constructor of duration shall be a constexpr function
|
| 1144 |
if and only if the required initialization of the member `rep_` for copy
|
| 1145 |
+
and move, respectively, would be constexpr-suitable [[dcl.constexpr]].
|
|
|
|
| 1146 |
|
| 1147 |
[*Example 1*:
|
| 1148 |
|
| 1149 |
``` cpp
|
| 1150 |
duration<long, ratio<60>> d0; // holds a count of minutes using a long
|
|
|
|
| 1174 |
duration<int, milli> d(3.5); // error
|
| 1175 |
```
|
| 1176 |
|
| 1177 |
— *end example*]
|
| 1178 |
|
| 1179 |
+
*Effects:* Initializes `rep_` with `r`.
|
| 1180 |
|
| 1181 |
``` cpp
|
| 1182 |
template<class Rep2, class Period2>
|
| 1183 |
constexpr duration(const duration<Rep2, Period2>& d);
|
| 1184 |
```
|
|
|
|
| 1671 |
`"d"`.
|
| 1672 |
- Otherwise, if `Period::type::den == 1`, *`units-suffix`* is
|
| 1673 |
`"[`*`num`*`]s"`.
|
| 1674 |
- Otherwise, *`units-suffix`* is `"[`*`num`*`/`*`den`*`]s"`.
|
| 1675 |
|
| 1676 |
+
In the list above, the use of *`num`* and *`den`* refers to the static
|
| 1677 |
data members of `Period::type`, which are converted to arrays of `charT`
|
| 1678 |
using a decimal conversion with no leading zeroes.
|
| 1679 |
|
| 1680 |
*Returns:* `os`.
|
| 1681 |
|
|
|
|
| 1688 |
minutes* offset = nullptr);
|
| 1689 |
```
|
| 1690 |
|
| 1691 |
*Effects:* Attempts to parse the input stream `is` into the duration `d`
|
| 1692 |
using the format flags given in the NTCTS `fmt` as specified in
|
| 1693 |
+
[[time.parse]]. If the parse fails to decode a valid duration,
|
| 1694 |
+
`is.setstate(ios_base::failbit)` is called and `d` is not modified. If
|
| 1695 |
+
`%Z` is used and successfully parsed, that value will be assigned to
|
| 1696 |
+
`*abbrev` if `abbrev` is non-null. If `%z` (or a modified variant) is
|
| 1697 |
+
used and successfully parsed, that value will be assigned to `*offset`
|
| 1698 |
+
if `offset` is non-null.
|
|
|
|
| 1699 |
|
| 1700 |
*Returns:* `is`.
|
| 1701 |
|
| 1702 |
## Class template `time_point` <a id="time.point">[[time.point]]</a>
|
| 1703 |
|
| 1704 |
+
### General <a id="time.point.general">[[time.point.general]]</a>
|
| 1705 |
+
|
| 1706 |
``` cpp
|
| 1707 |
namespace std::chrono {
|
| 1708 |
template<class Clock, class Duration = typename Clock::duration>
|
| 1709 |
class time_point {
|
| 1710 |
public:
|
|
|
|
| 1739 |
static constexpr time_point max() noexcept;
|
| 1740 |
};
|
| 1741 |
}
|
| 1742 |
```
|
| 1743 |
|
| 1744 |
+
If `Duration` is not a specialization of `duration`, the program is
|
|
|
|
|
|
|
|
|
|
| 1745 |
ill-formed.
|
| 1746 |
|
| 1747 |
### Constructors <a id="time.point.cons">[[time.point.cons]]</a>
|
| 1748 |
|
| 1749 |
``` cpp
|
|
|
|
| 1970 |
*Returns:*
|
| 1971 |
`time_point<Clock, ToDuration>(round<ToDuration>(tp.time_since_epoch()))`.
|
| 1972 |
|
| 1973 |
## Clocks <a id="time.clock">[[time.clock]]</a>
|
| 1974 |
|
| 1975 |
+
### General <a id="time.clock.general">[[time.clock.general]]</a>
|
| 1976 |
+
|
| 1977 |
+
The types defined in [[time.clock]] meet the *Cpp17TrivialClock*
|
| 1978 |
requirements [[time.clock.req]] unless otherwise specified.
|
| 1979 |
|
| 1980 |
### Class `system_clock` <a id="time.clock.system">[[time.clock.system]]</a>
|
| 1981 |
|
| 1982 |
#### Overview <a id="time.clock.system.overview">[[time.clock.system.overview]]</a>
|
|
|
|
| 2054 |
`false`, and `Duration{1} < days{1}` is `true`.
|
| 2055 |
|
| 2056 |
*Effects:* Equivalent to:
|
| 2057 |
|
| 2058 |
``` cpp
|
| 2059 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:L%F %T}"), tp);
|
|
|
|
|
|
|
| 2060 |
```
|
| 2061 |
|
| 2062 |
[*Example 1*:
|
| 2063 |
|
| 2064 |
``` cpp
|
|
|
|
| 2137 |
|
| 2138 |
[*Example 1*:
|
| 2139 |
`clock_cast<utc_clock>(sys_seconds{sys_days{1970y/January/1}}).time_since_epoch()`
|
| 2140 |
is `0s`.
|
| 2141 |
`clock_cast<utc_clock>(sys_seconds{sys_days{2000y/January/1}}).time_since_epoch()`
|
| 2142 |
+
is `946'684'822s`,
|
| 2143 |
+
which is `10'957 * 86'400s + 22s`.
|
| 2144 |
— *end example*]
|
| 2145 |
|
| 2146 |
`utc_clock` is not a *Cpp17TrivialClock* unless the implementation can
|
| 2147 |
guarantee that `utc_clock::now()` does not propagate an exception.
|
| 2148 |
|
|
|
|
| 2210 |
```
|
| 2211 |
|
| 2212 |
*Effects:* Equivalent to:
|
| 2213 |
|
| 2214 |
``` cpp
|
| 2215 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:L%F %T}"), t);
|
| 2216 |
```
|
| 2217 |
|
| 2218 |
[*Example 1*:
|
| 2219 |
|
| 2220 |
``` cpp
|
|
|
|
| 2381 |
```
|
| 2382 |
|
| 2383 |
*Effects:* Equivalent to:
|
| 2384 |
|
| 2385 |
``` cpp
|
| 2386 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:L%F %T}"), t);
|
| 2387 |
```
|
| 2388 |
|
| 2389 |
[*Example 1*:
|
| 2390 |
|
| 2391 |
``` cpp
|
|
|
|
| 2479 |
```
|
| 2480 |
|
| 2481 |
*Returns:*
|
| 2482 |
|
| 2483 |
``` cpp
|
| 2484 |
+
utc_time<common_type_t<Duration, seconds>>{t.time_since_epoch()} + 315964809s
|
| 2485 |
```
|
| 2486 |
|
| 2487 |
[*Note 1*:
|
| 2488 |
|
| 2489 |
``` cpp
|
|
|
|
| 2521 |
```
|
| 2522 |
|
| 2523 |
*Effects:* Equivalent to:
|
| 2524 |
|
| 2525 |
``` cpp
|
| 2526 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:L%F %T}"), t);
|
| 2527 |
```
|
| 2528 |
|
| 2529 |
[*Example 1*:
|
| 2530 |
|
| 2531 |
``` cpp
|
|
|
|
| 2577 |
requirements [[time.clock.req]], and using a signed arithmetic type for
|
| 2578 |
`file_clock::rep`. `file_clock` is used to create the `time_point`
|
| 2579 |
system used for `file_time_type` [[filesystems]]. Its epoch is
|
| 2580 |
unspecified, and `noexcept(file_clock::now())` is `true`.
|
| 2581 |
|
| 2582 |
+
[*Note 1*: The type that `file_clock` denotes can be in a different
|
| 2583 |
namespace than `std::chrono`, such as `std::filesystem`. — *end note*]
|
| 2584 |
|
| 2585 |
#### Member functions <a id="time.clock.file.members">[[time.clock.file.members]]</a>
|
| 2586 |
|
| 2587 |
The type denoted by `file_clock` provides precisely one of the following
|
|
|
|
| 2621 |
```
|
| 2622 |
|
| 2623 |
*Effects:* Equivalent to:
|
| 2624 |
|
| 2625 |
``` cpp
|
| 2626 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:L%F %T}"), t);
|
| 2627 |
```
|
| 2628 |
|
| 2629 |
``` cpp
|
| 2630 |
template<class charT, class traits, class Duration, class Alloc = allocator<charT>>
|
| 2631 |
basic_istream<charT, traits>&
|
|
|
|
| 2869 |
-> decltype(SourceClock::to_sys(t));
|
| 2870 |
```
|
| 2871 |
|
| 2872 |
*Constraints:* `SourceClock::to_sys(t)` is well-formed.
|
| 2873 |
|
| 2874 |
+
*Mandates:* `SourceClock::to_sys(t)` returns a `sys_time<Duration2>` for
|
| 2875 |
+
some type `Duration2` [[time.point.general]].
|
| 2876 |
|
| 2877 |
*Returns:* `SourceClock::to_sys(t)`.
|
| 2878 |
|
| 2879 |
``` cpp
|
| 2880 |
template<class DestClock>
|
|
|
|
| 2892 |
```
|
| 2893 |
|
| 2894 |
*Constraints:* `DestClock::from_sys(t)` is well-formed.
|
| 2895 |
|
| 2896 |
*Mandates:* `DestClock::from_sys(t)` returns a
|
| 2897 |
+
`time_point<DestClock, Duration2>` for some type `Duration2`
|
| 2898 |
+
[[time.point.general]].
|
| 2899 |
|
| 2900 |
*Returns:* `DestClock::from_sys(t)`.
|
| 2901 |
|
| 2902 |
#### Conversions between `utc_clock` and other clocks <a id="time.clock.cast.utc">[[time.clock.cast.utc]]</a>
|
| 2903 |
|
|
|
|
| 2916 |
-> decltype(SourceClock::to_utc(t));
|
| 2917 |
```
|
| 2918 |
|
| 2919 |
*Constraints:* `SourceClock::to_utc(t)` is well-formed.
|
| 2920 |
|
| 2921 |
+
*Mandates:* `SourceClock::to_utc(t)` returns a `utc_time<Duration2>` for
|
| 2922 |
+
some type `Duration2` [[time.point.general]].
|
| 2923 |
|
| 2924 |
*Returns:* `SourceClock::to_utc(t)`.
|
| 2925 |
|
| 2926 |
``` cpp
|
| 2927 |
template<class DestClock>
|
|
|
|
| 2939 |
```
|
| 2940 |
|
| 2941 |
*Constraints:* `DestClock::from_utc(t)` is well-formed.
|
| 2942 |
|
| 2943 |
*Mandates:* `DestClock::from_utc(t)` returns a
|
| 2944 |
+
`time_point<DestClock, Duration2>` for some type `Duration2`
|
| 2945 |
+
[[time.point.general]].
|
| 2946 |
|
| 2947 |
*Returns:* `DestClock::from_utc(t)`.
|
| 2948 |
|
| 2949 |
#### Function template `clock_cast` <a id="time.clock.cast.fn">[[time.clock.cast.fn]]</a>
|
| 2950 |
|
|
|
|
| 3372 |
|
| 3373 |
*Effects:* Equivalent to:
|
| 3374 |
|
| 3375 |
``` cpp
|
| 3376 |
return os << (m.ok() ?
|
| 3377 |
+
format(os.getloc(), STATICALLY-WIDEN<charT>("{:L%b}"), m) :
|
| 3378 |
format(os.getloc(), STATICALLY-WIDEN<charT>("{} is not a valid month"),
|
| 3379 |
static_cast<unsigned>(m)));
|
| 3380 |
```
|
| 3381 |
|
| 3382 |
``` cpp
|
|
|
|
| 3507 |
```
|
| 3508 |
|
| 3509 |
*Returns:* `*this`.
|
| 3510 |
|
| 3511 |
``` cpp
|
| 3512 |
+
constexpr year operator-() const noexcept;
|
| 3513 |
```
|
| 3514 |
|
| 3515 |
*Returns:* `year{-y_}`.
|
| 3516 |
|
| 3517 |
``` cpp
|
|
|
|
| 3560 |
|
| 3561 |
``` cpp
|
| 3562 |
constexpr year operator+(const year& x, const years& y) noexcept;
|
| 3563 |
```
|
| 3564 |
|
| 3565 |
+
*Returns:* `year{int{x} + static_cast<int>(y.count())}`.
|
| 3566 |
|
| 3567 |
``` cpp
|
| 3568 |
constexpr year operator+(const years& x, const year& y) noexcept;
|
| 3569 |
```
|
| 3570 |
|
|
|
|
| 3836 |
|
| 3837 |
*Effects:* Equivalent to:
|
| 3838 |
|
| 3839 |
``` cpp
|
| 3840 |
return os << (wd.ok() ?
|
| 3841 |
+
format(os.getloc(), STATICALLY-WIDEN<charT>("{:L%a}"), wd) :
|
| 3842 |
format(os.getloc(), STATICALLY-WIDEN<charT>("{} is not a valid weekday"),
|
| 3843 |
static_cast<unsigned>(wd.wd_)));
|
| 3844 |
```
|
| 3845 |
|
| 3846 |
``` cpp
|
|
|
|
| 3948 |
*Effects:* Equivalent to:
|
| 3949 |
|
| 3950 |
``` cpp
|
| 3951 |
auto i = wdi.index();
|
| 3952 |
return os << (i >= 1 && i <= 5 ?
|
| 3953 |
+
format(os.getloc(), STATICALLY-WIDEN<charT>("{:L}[{}]"), wdi.weekday(), i) :
|
| 3954 |
+
format(os.getloc(), STATICALLY-WIDEN<charT>("{:L}[{} is not a valid index]"),
|
| 3955 |
wdi.weekday(), i));
|
| 3956 |
```
|
| 3957 |
|
| 3958 |
### Class `weekday_last` <a id="time.cal.wdlast">[[time.cal.wdlast]]</a>
|
| 3959 |
|
|
|
|
| 4024 |
```
|
| 4025 |
|
| 4026 |
*Effects:* Equivalent to:
|
| 4027 |
|
| 4028 |
``` cpp
|
| 4029 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:L}[last]"), wdl.weekday());
|
| 4030 |
```
|
| 4031 |
|
| 4032 |
### Class `month_day` <a id="time.cal.md">[[time.cal.md]]</a>
|
| 4033 |
|
| 4034 |
#### Overview <a id="time.cal.md.overview">[[time.cal.md.overview]]</a>
|
|
|
|
| 4112 |
```
|
| 4113 |
|
| 4114 |
*Effects:* Equivalent to:
|
| 4115 |
|
| 4116 |
``` cpp
|
| 4117 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:L}/{}"),
|
| 4118 |
md.month(), md.day());
|
| 4119 |
```
|
| 4120 |
|
| 4121 |
``` cpp
|
| 4122 |
template<class charT, class traits, class Alloc = allocator<charT>>
|
|
|
|
| 4207 |
```
|
| 4208 |
|
| 4209 |
*Effects:* Equivalent to:
|
| 4210 |
|
| 4211 |
``` cpp
|
| 4212 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:L}/last"), mdl.month());
|
| 4213 |
```
|
| 4214 |
|
| 4215 |
### Class `month_weekday` <a id="time.cal.mwd">[[time.cal.mwd]]</a>
|
| 4216 |
|
| 4217 |
#### Overview <a id="time.cal.mwd.overview">[[time.cal.mwd.overview]]</a>
|
|
|
|
| 4290 |
```
|
| 4291 |
|
| 4292 |
*Effects:* Equivalent to:
|
| 4293 |
|
| 4294 |
``` cpp
|
| 4295 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:L}/{:L}"),
|
| 4296 |
mwd.month(), mwd.weekday_indexed());
|
| 4297 |
```
|
| 4298 |
|
| 4299 |
### Class `month_weekday_last` <a id="time.cal.mwdlast">[[time.cal.mwdlast]]</a>
|
| 4300 |
|
|
|
|
| 4377 |
```
|
| 4378 |
|
| 4379 |
*Effects:* Equivalent to:
|
| 4380 |
|
| 4381 |
``` cpp
|
| 4382 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:L}/{:L}"),
|
| 4383 |
mwdl.month(), mwdl.weekday_last());
|
| 4384 |
```
|
| 4385 |
|
| 4386 |
### Class `year_month` <a id="time.cal.ym">[[time.cal.ym]]</a>
|
| 4387 |
|
|
|
|
| 4577 |
```
|
| 4578 |
|
| 4579 |
*Effects:* Equivalent to:
|
| 4580 |
|
| 4581 |
``` cpp
|
| 4582 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{:L}"),
|
| 4583 |
ym.year(), ym.month());
|
| 4584 |
```
|
| 4585 |
|
| 4586 |
``` cpp
|
| 4587 |
template<class charT, class traits, class Alloc = allocator<charT>>
|
|
|
|
| 4667 |
|
| 4668 |
*Effects:* Initializes `y_` with `ymdl.year()`, `m_` with
|
| 4669 |
`ymdl.month()`, and `d_` with `ymdl.day()`.
|
| 4670 |
|
| 4671 |
[*Note 1*: This conversion from `year_month_day_last` to
|
| 4672 |
+
`year_month_day` can be more efficient than converting a
|
| 4673 |
`year_month_day_last` to a `sys_days`, and then converting that
|
| 4674 |
`sys_days` to a `year_month_day`. — *end note*]
|
| 4675 |
|
| 4676 |
``` cpp
|
| 4677 |
constexpr year_month_day(const sys_days& dp) noexcept;
|
|
|
|
| 4851 |
```
|
| 4852 |
|
| 4853 |
*Returns:* `(ymd.year() + dy) / ymd.month() / ymd.day()`.
|
| 4854 |
|
| 4855 |
[*Note 2*: If `ymd.month()` is February and `ymd.day()` is not in the
|
| 4856 |
+
range \[`1d`, `28d`\], `ok()` can return `false` for the resultant
|
| 4857 |
`year_month_day`. — *end note*]
|
| 4858 |
|
| 4859 |
``` cpp
|
| 4860 |
constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept;
|
| 4861 |
```
|
|
|
|
| 5024 |
|
| 5025 |
*Returns:* If `ok()` is `true`, returns a `day` representing the last
|
| 5026 |
day of the (`year`, `month`) pair represented by `*this`. Otherwise, the
|
| 5027 |
returned value is unspecified.
|
| 5028 |
|
| 5029 |
+
[*Note 1*: This value might be computed on demand. — *end note*]
|
| 5030 |
|
| 5031 |
``` cpp
|
| 5032 |
constexpr operator sys_days() const noexcept;
|
| 5033 |
```
|
| 5034 |
|
|
|
|
| 5131 |
```
|
| 5132 |
|
| 5133 |
*Effects:* Equivalent to:
|
| 5134 |
|
| 5135 |
``` cpp
|
| 5136 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{:L}"),
|
| 5137 |
ymdl.year(), ymdl.month_day_last());
|
| 5138 |
```
|
| 5139 |
|
| 5140 |
### Class `year_month_weekday` <a id="time.cal.ymwd">[[time.cal.ymwd]]</a>
|
| 5141 |
|
|
|
|
| 5203 |
```
|
| 5204 |
|
| 5205 |
*Effects:* Constructs an object of type `year_month_weekday` which
|
| 5206 |
corresponds to the date represented by `dp`.
|
| 5207 |
|
| 5208 |
+
*Remarks:* For any value `ymwd` of type `year_month_weekday` for which
|
| 5209 |
+
`ymwd.ok()` is `true`, `ymwd == year_month_weekday{sys_days{ymwd}}` is
|
| 5210 |
`true`.
|
| 5211 |
|
| 5212 |
``` cpp
|
| 5213 |
constexpr explicit year_month_weekday(const local_days& dp) noexcept;
|
| 5214 |
```
|
|
|
|
| 5382 |
```
|
| 5383 |
|
| 5384 |
*Effects:* Equivalent to:
|
| 5385 |
|
| 5386 |
``` cpp
|
| 5387 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{:L}/{:L}"),
|
| 5388 |
ymwd.year(), ymwd.month(), ymwd.weekday_indexed());
|
| 5389 |
```
|
| 5390 |
|
| 5391 |
### Class `year_month_weekday_last` <a id="time.cal.ymwdlast">[[time.cal.ymwdlast]]</a>
|
| 5392 |
|
|
|
|
| 5609 |
```
|
| 5610 |
|
| 5611 |
*Effects:* Equivalent to:
|
| 5612 |
|
| 5613 |
``` cpp
|
| 5614 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{:L}/{:L}"),
|
| 5615 |
ymwdl.year(), ymwdl.month(), ymwdl.weekday_last());
|
| 5616 |
```
|
| 5617 |
|
| 5618 |
### Conventional syntax operators <a id="time.cal.operators">[[time.cal.operators]]</a>
|
| 5619 |
|
|
|
|
| 5987 |
distinct `is_negative` getter that returns `true` when the input
|
| 5988 |
duration is negative. The individual duration fields always return
|
| 5989 |
non-negative durations even when `is_negative()` indicates the structure
|
| 5990 |
is representing a negative duration.
|
| 5991 |
|
| 5992 |
+
If `Duration` is not a specialization of `duration`, the program is
|
| 5993 |
ill-formed.
|
| 5994 |
|
| 5995 |
### Members <a id="time.hms.members">[[time.hms.members]]</a>
|
| 5996 |
|
| 5997 |
``` cpp
|
|
|
|
| 6120 |
```
|
| 6121 |
|
| 6122 |
*Effects:* Equivalent to:
|
| 6123 |
|
| 6124 |
``` cpp
|
| 6125 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:L%T}"), hms);
|
| 6126 |
```
|
| 6127 |
|
| 6128 |
[*Example 1*:
|
| 6129 |
|
| 6130 |
``` cpp
|
|
|
|
| 6224 |
|
| 6225 |
[*Note 1*: A `time_zone_link` specifies an alternative name for a
|
| 6226 |
`time_zone`. — *end note*]
|
| 6227 |
|
| 6228 |
*Throws:* If a `const time_zone*` cannot be found as described in the
|
| 6229 |
+
*Returns:* element, throws a `runtime_error`.
|
| 6230 |
|
| 6231 |
[*Note 2*: On non-exceptional return, the return value is always a
|
| 6232 |
pointer to a valid `time_zone`. — *end note*]
|
| 6233 |
|
| 6234 |
``` cpp
|
|
|
|
| 6296 |
|
| 6297 |
*Preconditions:* The iterator following `p` is dereferenceable.
|
| 6298 |
|
| 6299 |
*Effects:* Erases the `tzdb` referred to by the iterator following `p`.
|
| 6300 |
|
|
|
|
|
|
|
|
|
|
| 6301 |
*Ensures:* No pointers, references, or iterators are invalidated except
|
| 6302 |
those referring to the erased `tzdb`.
|
| 6303 |
|
| 6304 |
[*Note 2*: It is not possible to erase the `tzdb` referred to by
|
| 6305 |
`begin()`. — *end note*]
|
| 6306 |
|
| 6307 |
+
*Returns:* An iterator pointing to the element following the one that
|
| 6308 |
+
was erased, or `end()` if no such element exists.
|
| 6309 |
+
|
| 6310 |
*Throws:* Nothing.
|
| 6311 |
|
| 6312 |
``` cpp
|
| 6313 |
const_iterator begin() const noexcept;
|
| 6314 |
```
|
|
|
|
| 6829 |
zoned_time(const sys_time<Duration>& st);
|
| 6830 |
explicit zoned_time(TimeZonePtr z);
|
| 6831 |
explicit zoned_time(string_view name);
|
| 6832 |
|
| 6833 |
template<class Duration2>
|
| 6834 |
+
zoned_time(const zoned_time<Duration2, TimeZonePtr>& y);
|
| 6835 |
|
| 6836 |
zoned_time(TimeZonePtr z, const sys_time<Duration>& st);
|
| 6837 |
zoned_time(string_view name, const sys_time<Duration>& st);
|
| 6838 |
|
| 6839 |
zoned_time(TimeZonePtr z, const local_time<Duration>& tp);
|
| 6840 |
zoned_time(string_view name, const local_time<Duration>& tp);
|
| 6841 |
zoned_time(TimeZonePtr z, const local_time<Duration>& tp, choose c);
|
| 6842 |
zoned_time(string_view name, const local_time<Duration>& tp, choose c);
|
| 6843 |
|
| 6844 |
template<class Duration2, class TimeZonePtr2>
|
| 6845 |
+
zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& y);
|
| 6846 |
template<class Duration2, class TimeZonePtr2>
|
| 6847 |
+
zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& y, choose);
|
| 6848 |
|
| 6849 |
template<class Duration2, class TimeZonePtr2>
|
| 6850 |
+
zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& y);
|
| 6851 |
template<class Duration2, class TimeZonePtr2>
|
| 6852 |
+
zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& y, choose c);
|
| 6853 |
|
| 6854 |
zoned_time& operator=(const sys_time<Duration>& st);
|
| 6855 |
+
zoned_time& operator=(const local_time<Duration>& lt);
|
| 6856 |
|
| 6857 |
operator sys_time<duration>() const;
|
| 6858 |
explicit operator local_time<duration>() const;
|
| 6859 |
|
| 6860 |
TimeZonePtr get_time_zone() const;
|
|
|
|
| 6980 |
|
| 6981 |
``` cpp
|
| 6982 |
zoned_time(TimeZonePtr z, const local_time<Duration>& tp);
|
| 6983 |
```
|
| 6984 |
|
|
|
|
|
|
|
| 6985 |
*Constraints:*
|
| 6986 |
|
| 6987 |
``` cpp
|
| 6988 |
is_convertible_v<
|
| 6989 |
decltype(declval<TimeZonePtr&>()->to_sys(local_time<Duration>{})),
|
| 6990 |
sys_time<duration>>
|
| 6991 |
```
|
| 6992 |
|
| 6993 |
is `true`.
|
| 6994 |
|
| 6995 |
+
*Preconditions:* `z` refers to a time zone.
|
| 6996 |
+
|
| 6997 |
*Effects:* Initializes `zone_` with `std::move(z)` and `tp_` with
|
| 6998 |
`zone_->to_sys(tp)`.
|
| 6999 |
|
| 7000 |
``` cpp
|
| 7001 |
zoned_time(string_view name, const local_time<Duration>& tp);
|
|
|
|
| 7009 |
|
| 7010 |
``` cpp
|
| 7011 |
zoned_time(TimeZonePtr z, const local_time<Duration>& tp, choose c);
|
| 7012 |
```
|
| 7013 |
|
|
|
|
|
|
|
| 7014 |
*Constraints:*
|
| 7015 |
|
| 7016 |
``` cpp
|
| 7017 |
is_convertible_v<
|
| 7018 |
decltype(declval<TimeZonePtr&>()->to_sys(local_time<Duration>{}, choose::earliest)),
|
| 7019 |
sys_time<duration>>
|
| 7020 |
```
|
| 7021 |
|
| 7022 |
is `true`.
|
| 7023 |
|
| 7024 |
+
*Preconditions:* `z` refers to a time zone.
|
| 7025 |
+
|
| 7026 |
*Effects:* Initializes `zone_` with `std::move(z)` and `tp_` with
|
| 7027 |
`zone_->to_sys(tp, c)`.
|
| 7028 |
|
| 7029 |
``` cpp
|
| 7030 |
zoned_time(string_view name, const local_time<Duration>& tp, choose c);
|
|
|
|
| 7160 |
basic_ostream<charT, traits>&
|
| 7161 |
operator<<(basic_ostream<charT, traits>& os,
|
| 7162 |
const zoned_time<Duration, TimeZonePtr>& t);
|
| 7163 |
```
|
| 7164 |
|
| 7165 |
+
*Effects:* Equivalent to:
|
|
|
|
| 7166 |
|
| 7167 |
+
``` cpp
|
| 7168 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:L%F %T %Z}"), t);
|
| 7169 |
+
```
|
| 7170 |
|
| 7171 |
### Class `leap_second` <a id="time.zone.leap">[[time.zone.leap]]</a>
|
| 7172 |
|
| 7173 |
#### Overview <a id="time.zone.leap.overview">[[time.zone.leap.overview]]</a>
|
| 7174 |
|
|
|
|
| 7246 |
```
|
| 7247 |
|
| 7248 |
*Returns:* `+1s` to indicate a positive leap second or `-1s` to indicate
|
| 7249 |
a negative leap second.
|
| 7250 |
|
| 7251 |
+
[*Note 1*: All leap seconds inserted up through 2022 were positive leap
|
| 7252 |
seconds. — *end note*]
|
| 7253 |
|
| 7254 |
#### Non-member functions <a id="time.zone.leap.nonmembers">[[time.zone.leap.nonmembers]]</a>
|
| 7255 |
|
| 7256 |
``` cpp
|
|
|
|
| 7396 |
specification as a *chrono-format-spec* according to the following
|
| 7397 |
syntax:
|
| 7398 |
|
| 7399 |
``` bnf
|
| 7400 |
chrono-format-spec
|
| 7401 |
+
fill-and-alignₒₚₜ widthₒₚₜ precisionₒₚₜ 'L'ₒₚₜ chrono-specsₒₚₜ
|
| 7402 |
```
|
| 7403 |
|
| 7404 |
``` bnf
|
| 7405 |
chrono-specs
|
| 7406 |
conversion-spec
|
|
|
|
| 7429 |
'p q Q r R S t T u U V w W x X y Y z Z %'
|
| 7430 |
```
|
| 7431 |
|
| 7432 |
The productions *fill-and-align*, *width*, and *precision* are described
|
| 7433 |
in [[format.string]]. Giving a *precision* specification in the
|
| 7434 |
+
*chrono-format-spec* is valid only for types that are specializations of
|
| 7435 |
+
`std::chrono::duration` for which the nested *typedef-name* `rep`
|
| 7436 |
+
denotes a floating-point type. For all other types, an exception of type
|
| 7437 |
+
`format_error` is thrown if the *chrono-format-spec* contains a
|
| 7438 |
+
*precision* specification. All ordinary multibyte characters represented
|
| 7439 |
+
by *literal-char* are copied unchanged to the output.
|
| 7440 |
+
|
| 7441 |
+
A *formatting locale* is an instance of `locale` used by a formatting
|
| 7442 |
+
function, defined as
|
| 7443 |
+
|
| 7444 |
+
- the `"C"` locale if the `L` option is not present in
|
| 7445 |
+
*chrono-format-spec*, otherwise
|
| 7446 |
+
- the locale passed to the formatting function if any, otherwise
|
| 7447 |
+
- the global locale.
|
| 7448 |
|
| 7449 |
Each conversion specifier *conversion-spec* is replaced by appropriate
|
| 7450 |
+
characters as described in [[time.format.spec]]; the formats specified
|
| 7451 |
+
in ISO 8601:2004 shall be used where so described. Some of the
|
| 7452 |
+
conversion specifiers depend on the formatting locale. If the string
|
| 7453 |
+
literal encoding is a Unicode encoding form and the locale is among an
|
| 7454 |
+
*implementation-defined* set of locales, each replacement that depends
|
| 7455 |
+
on the locale is performed as if the replacement character sequence is
|
| 7456 |
+
converted to the string literal encoding. If the formatted object does
|
| 7457 |
+
not contain the information the conversion specifier refers to, an
|
| 7458 |
+
exception of type `format_error` is thrown.
|
| 7459 |
|
| 7460 |
The result of formatting a `std::chrono::duration` instance holding a
|
| 7461 |
negative value, or an `hh_mm_ss` object `h` for which `h.is_negative()`
|
| 7462 |
is `true`, is equivalent to the output of the corresponding positive
|
| 7463 |
value, with a `STATICALLY-WIDEN<charT>("-")` character sequence placed
|
|
|
|
| 7487 |
format flag needs, an exception of type `format_error` is thrown.
|
| 7488 |
|
| 7489 |
[*Example 2*: A `duration` does not contain enough information to
|
| 7490 |
format as a `weekday`. — *end example*]
|
| 7491 |
|
| 7492 |
+
However, if a flag refers to a “time of day” (e.g., `%H`, `%I`, `%p`,
|
| 7493 |
etc.), then a specialization of `duration` is interpreted as the time of
|
| 7494 |
day elapsed since midnight.
|
| 7495 |
|
| 7496 |
**Table: Meaning of conversion specifiers** <a id="time.format.spec">[time.format.spec]</a>
|
| 7497 |
|
|
|
|
| 7531 |
| `%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 with `0`. The modified command `%OW` produces the locale's alternative representation. |
|
| 7532 |
| `%x` | The locale's date representation. The modified command `%Ex` produces the locale's alternate date representation. |
|
| 7533 |
| `%X` | The locale's time representation. The modified command `%EX` produces the locale's alternate time representation. |
|
| 7534 |
| `%y` | The last two decimal digits of the year. If the result is a single digit it is prefixed by `0`. The modified command `%Oy` produces the locale's alternative representation. The modified command `%Ey` produces the locale's alternative representation of offset from `%EC` (year only). |
|
| 7535 |
| `%Y` | The year as a decimal number. If the result is less than four digits it is left-padded with `0` to four digits. The modified command `%EY` produces the locale's alternative full year representation. |
|
| 7536 |
+
| `%z` | The offset from UTC in the ISO 8601:2004 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 `%Oz` insert a `:` between the hours and minutes: `-04:30`. If the offset information is not available, an exception of type `format_error` is thrown. |
|
| 7537 |
| `%Z` | The time zone abbreviation. If the time zone abbreviation is not available, an exception of type `format_error` is thrown. |
|
| 7538 |
| `%%` | A `%` character. |
|
| 7539 |
|
| 7540 |
|
| 7541 |
If the *chrono-specs* is omitted, the chrono object is formatted as if
|
| 7542 |
+
by streaming it to `basic_ostringstream<charT> os` with the formatting
|
| 7543 |
+
locale imbued and copying `os.str()` through the output iterator of the
|
| 7544 |
+
context with additional padding and adjustments as specified by the
|
| 7545 |
+
format specifiers.
|
| 7546 |
|
| 7547 |
[*Example 3*:
|
| 7548 |
|
| 7549 |
``` cpp
|
| 7550 |
string s = format("{:=>8}", 42ms); // value of s is "====42ms"
|
|
|
|
| 7663 |
template<class Duration, class TimeZonePtr, class charT>
|
| 7664 |
struct formatter<chrono::zoned_time<Duration, TimeZonePtr>, charT>
|
| 7665 |
: formatter<chrono::local-time-format-t<Duration>, charT> {
|
| 7666 |
template<class FormatContext>
|
| 7667 |
typename FormatContext::iterator
|
| 7668 |
+
format(const chrono::zoned_time<Duration, TimeZonePtr>& tp, FormatContext& ctx) const;
|
| 7669 |
};
|
| 7670 |
```
|
| 7671 |
|
| 7672 |
``` cpp
|
| 7673 |
template<class FormatContext>
|
| 7674 |
typename FormatContext::iterator
|
| 7675 |
+
format(const chrono::zoned_time<Duration, TimeZonePtr>& tp, FormatContext& ctx) const;
|
| 7676 |
```
|
| 7677 |
|
| 7678 |
*Effects:* Equivalent to:
|
| 7679 |
|
| 7680 |
``` cpp
|
|
|
|
| 7690 |
[[basic.lookup.argdep]]. In the following paragraphs, let `is` denote an
|
| 7691 |
object of type `basic_istream<charT, traits>` and let `I` be
|
| 7692 |
`basic_istream<charT, traits>&`, where `charT` and `traits` are template
|
| 7693 |
parameters in that context.
|
| 7694 |
|
| 7695 |
+
*Recommended practice:* Implementations should make it difficult to
|
| 7696 |
+
accidentally store or use a manipulator that may contain a dangling
|
| 7697 |
+
reference to a format string, for example by making the manipulators
|
| 7698 |
+
produced by `parse` immovable and preventing stream extraction into an
|
| 7699 |
+
lvalue of such a manipulator type.
|
| 7700 |
+
|
| 7701 |
``` cpp
|
| 7702 |
+
template<class charT, class Parsable>
|
| 7703 |
+
unspecified
|
| 7704 |
+
parse(const charT* fmt, Parsable& tp);
|
| 7705 |
template<class charT, class traits, class Alloc, class Parsable>
|
| 7706 |
unspecified
|
| 7707 |
parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp);
|
| 7708 |
```
|
| 7709 |
|
| 7710 |
+
Let F be `fmt` for the first overload and `fmt.c_str()` for the second
|
| 7711 |
+
overload. Let `traits` be `char_traits<charT>` for the first overload.
|
| 7712 |
+
|
| 7713 |
*Constraints:* The expression
|
| 7714 |
|
| 7715 |
``` cpp
|
| 7716 |
+
from_stream(declval<basic_istream<charT, traits>&>(), F, tp)
|
| 7717 |
```
|
| 7718 |
|
| 7719 |
+
is well-formed when treated as an unevaluated
|
| 7720 |
+
operand [[term.unevaluated.operand]].
|
| 7721 |
|
| 7722 |
*Returns:* A manipulator such that the expression `is >> parse(fmt, tp)`
|
| 7723 |
+
has type `I`, has value `is`, and calls `from_stream(is, `F`, tp)`.
|
|
|
|
| 7724 |
|
| 7725 |
``` cpp
|
| 7726 |
+
template<class charT, class traits, class Alloc, class Parsable>
|
| 7727 |
+
unspecified
|
| 7728 |
+
parse(const charT* fmt, Parsable& tp,
|
| 7729 |
+
basic_string<charT, traits, Alloc>& abbrev);
|
| 7730 |
template<class charT, class traits, class Alloc, class Parsable>
|
| 7731 |
unspecified
|
| 7732 |
parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp,
|
| 7733 |
basic_string<charT, traits, Alloc>& abbrev);
|
| 7734 |
```
|
| 7735 |
|
| 7736 |
+
Let F be `fmt` for the first overload and `fmt.c_str()` for the second
|
| 7737 |
+
overload.
|
| 7738 |
+
|
| 7739 |
*Constraints:* The expression
|
| 7740 |
|
| 7741 |
``` cpp
|
| 7742 |
+
from_stream(declval<basic_istream<charT, traits>&>(), F, tp, addressof(abbrev))
|
| 7743 |
```
|
| 7744 |
|
| 7745 |
+
is well-formed when treated as an unevaluated
|
| 7746 |
+
operand [[term.unevaluated.operand]].
|
| 7747 |
|
| 7748 |
*Returns:* A manipulator such that the expression
|
| 7749 |
`is >> parse(fmt, tp, abbrev)` has type `I`, has value `is`, and calls
|
| 7750 |
+
`from_stream(is, `F`, tp, addressof(abbrev))`.
|
| 7751 |
|
| 7752 |
``` cpp
|
| 7753 |
+
template<class charT, class Parsable>
|
| 7754 |
+
unspecified
|
| 7755 |
+
parse(const charT* fmt, Parsable& tp, minutes& offset);
|
| 7756 |
template<class charT, class traits, class Alloc, class Parsable>
|
| 7757 |
unspecified
|
| 7758 |
parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp,
|
| 7759 |
minutes& offset);
|
| 7760 |
```
|
| 7761 |
|
| 7762 |
+
Let F be `fmt` for the first overload and `fmt.c_str()` for the second
|
| 7763 |
+
overload. Let `traits` be `char_traits<charT>` and `Alloc` be
|
| 7764 |
+
`allocator<charT>` for the first overload.
|
| 7765 |
+
|
| 7766 |
*Constraints:* The expression
|
| 7767 |
|
| 7768 |
``` cpp
|
| 7769 |
from_stream(declval<basic_istream<charT, traits>&>(),
|
| 7770 |
+
F, tp,
|
| 7771 |
declval<basic_string<charT, traits, Alloc>*>(),
|
| 7772 |
&offset)
|
| 7773 |
```
|
| 7774 |
|
| 7775 |
+
is well-formed when treated as an unevaluated
|
| 7776 |
+
operand [[term.unevaluated.operand]].
|
| 7777 |
|
| 7778 |
*Returns:* A manipulator such that the expression
|
| 7779 |
`is >> parse(fmt, tp, offset)` has type `I`, has value `is`, and calls:
|
| 7780 |
|
| 7781 |
``` cpp
|
| 7782 |
from_stream(is,
|
| 7783 |
+
F, tp,
|
| 7784 |
static_cast<basic_string<charT, traits, Alloc>*>(nullptr),
|
| 7785 |
&offset)
|
| 7786 |
```
|
| 7787 |
|
| 7788 |
``` cpp
|
| 7789 |
+
template<class charT, class traits, class Alloc, class Parsable>
|
| 7790 |
+
unspecified
|
| 7791 |
+
parse(const charT* fmt, Parsable& tp,
|
| 7792 |
+
basic_string<charT, traits, Alloc>& abbrev, minutes& offset);
|
| 7793 |
template<class charT, class traits, class Alloc, class Parsable>
|
| 7794 |
unspecified
|
| 7795 |
parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp,
|
| 7796 |
basic_string<charT, traits, Alloc>& abbrev, minutes& offset);
|
| 7797 |
```
|
| 7798 |
|
| 7799 |
+
Let F be `fmt` for the first overload and `fmt.c_str()` for the second
|
| 7800 |
+
overload.
|
| 7801 |
+
|
| 7802 |
*Constraints:* The expression
|
| 7803 |
|
| 7804 |
``` cpp
|
| 7805 |
from_stream(declval<basic_istream<charT, traits>&>(),
|
| 7806 |
+
F, tp, addressof(abbrev), &offset)
|
| 7807 |
```
|
| 7808 |
|
| 7809 |
+
is well-formed when treated as an unevaluated
|
| 7810 |
+
operand [[term.unevaluated.operand]].
|
| 7811 |
|
| 7812 |
*Returns:* A manipulator such that the expression
|
| 7813 |
`is >> parse(fmt, tp, abbrev, offset)` has type `I`, has value `is`, and
|
| 7814 |
+
calls `from_stream(is, `F`, tp, addressof(abbrev), &offset)`.
|
| 7815 |
|
| 7816 |
All `from_stream` overloads behave as unformatted input functions,
|
| 7817 |
except that they have an unspecified effect on the value returned by
|
| 7818 |
subsequent calls to `basic_istream<>::gcount()`. Each overload takes a
|
| 7819 |
format string containing ordinary characters and flags which have
|
|
|
|
| 7822 |
of date and time types according to [[time.parse.spec]]. Some flags can
|
| 7823 |
be modified by a width parameter given as a positive decimal integer
|
| 7824 |
called out as `N` below which governs how many characters are parsed
|
| 7825 |
from the stream in interpreting the flag. All characters in the format
|
| 7826 |
string that are not represented in [[time.parse.spec]], except for
|
| 7827 |
+
whitespace, are parsed unchanged from the stream. A whitespace character
|
| 7828 |
+
matches zero or more whitespace characters in the input stream.
|
|
|
|
| 7829 |
|
| 7830 |
If the type being parsed cannot represent the information that the
|
| 7831 |
format flag refers to, `is.setstate(ios_base::failbit)` is called.
|
| 7832 |
|
| 7833 |
[*Example 1*: A `duration` cannot represent a
|
| 7834 |
`weekday`. — *end example*]
|
| 7835 |
|
| 7836 |
+
However, if a flag refers to a “time of day” (e.g., `%H`, `%I`, `%p`,
|
| 7837 |
etc.), then a specialization of `duration` is parsed as the time of day
|
| 7838 |
elapsed since midnight.
|
| 7839 |
|
| 7840 |
If the `from_stream` overload fails to parse everything specified by the
|
| 7841 |
format string, or if insufficient information is parsed to specify a
|
| 7842 |
complete duration, time point, or calendrical data structure,
|
| 7843 |
`setstate(ios_base::failbit)` is called on the `basic_istream`.
|
| 7844 |
|
| 7845 |
+
**Table: Meaning of `parse` flags** <a id="time.parse.spec">[time.parse.spec]</a>
|
| 7846 |
+
|
| 7847 |
+
| Flag | Parsed value |
|
| 7848 |
+
| ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| 7849 |
+
| `%a` | The locale's full or abbreviated case-insensitive weekday name. |
|
| 7850 |
+
| `%A` | Equivalent to `%a`. |
|
| 7851 |
+
| `%b` | The locale's full or abbreviated case-insensitive month name. |
|
| 7852 |
+
| `%B` | Equivalent to `%b`. |
|
| 7853 |
+
| `%c` | The locale's date and time representation. The modified command `%Ec` interprets the locale's alternate date and time representation. |
|
| 7854 |
+
| `%C` | The century as a decimal number. The modified command `%*N*C` specifies the maximum number of characters to read. If `*N*` is 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 century. |
|
| 7855 |
+
| `%d` | The day of the month as a decimal number. The modified command `%*N*d` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. The modified command `%Od` interprets the locale's alternative representation of the day of the month. |
|
| 7856 |
+
| `%D` | Equivalent to `%m/%d/%y`. |
|
| 7857 |
+
| `%e` | Equivalent to `%d` and can be modified like `%d`. |
|
| 7858 |
+
| `%F` | Equivalent to `%Y-%m-%d`. If modified with a width `*N*`, the width is applied to only `%Y`. |
|
| 7859 |
+
| `%g` | The last two decimal digits of the ISO week-based year. The modified command `%*N*g` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. |
|
| 7860 |
+
| `%G` | The ISO week-based year as a decimal number. The modified command `%*N*G` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 4. Leading zeroes are permitted but not required. |
|
| 7861 |
+
| `%h` | Equivalent to `%b`. |
|
| 7862 |
+
| `%H` | The hour (24-hour clock) as a decimal number. The modified command `%*N*H` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. The modified command `%OH` interprets the locale's alternative representation. |
|
| 7863 |
+
| `%I` | The hour (12-hour clock) as a decimal number. The modified command `%*N*I` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. The modified command `%OI` interprets the locale's alternative representation. |
|
| 7864 |
+
| `%j` | If the type being parsed is a specialization of `duration`, a decimal number of `days`. Otherwise, the day of the year as a decimal number. Jan 1 is `1`. In either case, the modified command `%*N*j` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 3. Leading zeroes are permitted but not required. |
|
| 7865 |
+
| `%m` | The month as a decimal number. Jan is `1`. The modified command `%*N*m` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. The modified command `%Om` interprets the locale's alternative representation. |
|
| 7866 |
+
| `%M` | The minutes as a decimal number. The modified command `%*N*M` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. The modified command `%OM` interprets the locale's alternative representation. |
|
| 7867 |
+
| `%n` | Matches one whitespace character. *`%n`, `%t`, and a space can be combined to match a wide range of whitespace patterns. For example, `"%n "` matches one or more whitespace characters, and `"%n%t%t"` matches one to three whitespace characters.* |
|
| 7868 |
+
| `%p` | The locale's equivalent of the AM/PM designations associated with a 12-hour clock. |
|
| 7869 |
+
| `%r` | The locale's 12-hour clock time. |
|
| 7870 |
+
| `%R` | Equivalent to `%H:%M`. |
|
| 7871 |
+
| `%S` | The seconds as a decimal number. The modified command `%*N*S` specifies the maximum number of characters to read. If `*N*` is 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. |
|
| 7872 |
+
| `%t` | Matches zero or one whitespace characters. |
|
| 7873 |
+
| `%T` | Equivalent to `%H:%M:%S`. |
|
| 7874 |
+
| `%u` | The ISO weekday as a decimal number (`1`-`7`), where Monday is `1`. The modified command `%*N*u` specifies the maximum number of characters to read. If `*N*` is not specified, the default is `1`. Leading zeroes are permitted but not required. |
|
| 7875 |
+
| `%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 `%*N*U` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. The modified command `%OU` interprets the locale's alternative representation. |
|
| 7876 |
+
| `%V` | The ISO week-based week number as a decimal number. The modified command `%*N*V` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. |
|
| 7877 |
+
| `%w` | The weekday as a decimal number (`0`-`6`), where Sunday is `0`. The modified command `%*N*w` specifies the maximum number of characters to read. If `*N*` is not specified, the default is `1`. Leading zeroes are permitted but not required. The modified command `%Ow` interprets the locale's alternative representation. |
|
| 7878 |
+
| `%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 `%*N*W` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 2. Leading zeroes are permitted but not required. The modified command `%OW` interprets the locale's alternative representation. |
|
| 7879 |
+
| `%x` | The locale's date representation. The modified command `%Ex` interprets the locale's alternate date representation. |
|
| 7880 |
+
| `%X` | The locale's time representation. The modified command `%EX` interprets the locale's alternate time representation. |
|
| 7881 |
+
| `%y` | The last two decimal digits of the year. If the century is not otherwise specified (e.g., with `%C`), values in the range {[}`69`, `99`{]} are presumed to refer to the years 1969 to 1999, and values in the range {[}`00`, `68`{]} are presumed to refer to the years 2000 to 2068. The modified command `%*N*y` specifies the maximum number of characters to read. If `*N*` is 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. |
|
| 7882 |
+
| `%Y` | The year as a decimal number. The modified command `%*N*Y` specifies the maximum number of characters to read. If `*N*` is not specified, the default is 4. Leading zeroes are permitted but not required. The modified command `%EY` interprets the locale's alternative representation. |
|
| 7883 |
+
| `%z` | The offset from UTC in the format `[+|-]hh[mm]`. For example `-0430` refers to 4 hours 30 minutes behind UTC, and `04` refers to 4 hours ahead of UTC. The modified commands `%Ez` and `%Oz` parse a `:` between the hours and minutes and render leading zeroes on the hour field optional: `[+|-]h[h][:mm]`. For example `-04:30` refers to 4 hours 30 minutes behind UTC, and `4` refers to 4 hours ahead of UTC. |
|
| 7884 |
+
| `%Z` | The time zone abbreviation or name. A single word is parsed. This word can only contain characters from the basic character set [[lex.charset]] that are alphanumeric, or one of `'_'`, `'/'`, `'-'`, or `'+'`. |
|
| 7885 |
+
| `%%` | A `%` character is extracted. |
|
| 7886 |
+
|
| 7887 |
|
| 7888 |
## Header `<ctime>` synopsis <a id="ctime.syn">[[ctime.syn]]</a>
|
| 7889 |
|
| 7890 |
``` cpp
|
| 7891 |
#define NULL see [support.types.nullptr]
|
|
|
|
| 7900 |
struct timespec;
|
| 7901 |
struct tm;
|
| 7902 |
|
| 7903 |
clock_t clock();
|
| 7904 |
double difftime(time_t time1, time_t time0);
|
| 7905 |
+
time_t mktime(tm* timeptr);
|
| 7906 |
time_t time(time_t* timer);
|
| 7907 |
int timespec_get(timespec* ts, int base);
|
| 7908 |
+
char* asctime(const tm* timeptr);
|
| 7909 |
char* ctime(const time_t* timer);
|
| 7910 |
+
tm* gmtime(const time_t* timer);
|
| 7911 |
+
tm* localtime(const time_t* timer);
|
| 7912 |
+
size_t strftime(char* s, size_t maxsize, const char* format, const tm* timeptr);
|
| 7913 |
}
|
| 7914 |
```
|
| 7915 |
|
| 7916 |
The contents of the header `<ctime>` are the same as the C standard
|
| 7917 |
library header `<time.h>`.[^1]
|
|
|
|
| 7924 |
<!-- Link reference definitions -->
|
| 7925 |
[basic.lookup.argdep]: basic.md#basic.lookup.argdep
|
| 7926 |
[cpp17.equalitycomparable]: #cpp17.equalitycomparable
|
| 7927 |
[cpp17.lessthancomparable]: #cpp17.lessthancomparable
|
| 7928 |
[ctime.syn]: #ctime.syn
|
| 7929 |
+
[dcl.constexpr]: dcl.md#dcl.constexpr
|
| 7930 |
[filesystems]: input.md#filesystems
|
| 7931 |
[format.formatter]: utilities.md#format.formatter
|
| 7932 |
[format.string]: utilities.md#format.string
|
| 7933 |
[formatter.requirements]: utilities.md#formatter.requirements
|
| 7934 |
[intro.multithread]: basic.md#intro.multithread
|
| 7935 |
+
[lex.charset]: lex.md#lex.charset
|
| 7936 |
+
[meta.rqmts]: meta.md#meta.rqmts
|
| 7937 |
[numeric.requirements]: numerics.md#numeric.requirements
|
| 7938 |
[over.ics.rank]: over.md#over.ics.rank
|
| 7939 |
[over.match.class.deduct]: over.md#over.match.class.deduct
|
| 7940 |
[res.on.data.races]: library.md#res.on.data.races
|
| 7941 |
[swappable.requirements]: library.md#swappable.requirements
|
| 7942 |
[temp.deduct]: temp.md#temp.deduct
|
| 7943 |
+
[term.unevaluated.operand]: expr.md#term.unevaluated.operand
|
| 7944 |
[time]: #time
|
| 7945 |
[time.12]: #time.12
|
| 7946 |
[time.cal]: #time.cal
|
| 7947 |
[time.cal.day]: #time.cal.day
|
| 7948 |
[time.cal.day.members]: #time.cal.day.members
|
|
|
|
| 8014 |
[time.clock.conv]: #time.clock.conv
|
| 8015 |
[time.clock.file]: #time.clock.file
|
| 8016 |
[time.clock.file.members]: #time.clock.file.members
|
| 8017 |
[time.clock.file.nonmembers]: #time.clock.file.nonmembers
|
| 8018 |
[time.clock.file.overview]: #time.clock.file.overview
|
| 8019 |
+
[time.clock.general]: #time.clock.general
|
| 8020 |
[time.clock.gps]: #time.clock.gps
|
| 8021 |
[time.clock.gps.members]: #time.clock.gps.members
|
| 8022 |
[time.clock.gps.nonmembers]: #time.clock.gps.nonmembers
|
| 8023 |
[time.clock.gps.overview]: #time.clock.gps.overview
|
| 8024 |
[time.clock.hires]: #time.clock.hires
|
|
|
|
| 8041 |
[time.duration.alg]: #time.duration.alg
|
| 8042 |
[time.duration.arithmetic]: #time.duration.arithmetic
|
| 8043 |
[time.duration.cast]: #time.duration.cast
|
| 8044 |
[time.duration.comparisons]: #time.duration.comparisons
|
| 8045 |
[time.duration.cons]: #time.duration.cons
|
| 8046 |
+
[time.duration.general]: #time.duration.general
|
| 8047 |
[time.duration.io]: #time.duration.io
|
| 8048 |
[time.duration.literals]: #time.duration.literals
|
| 8049 |
[time.duration.nonmember]: #time.duration.nonmember
|
| 8050 |
[time.duration.observer]: #time.duration.observer
|
| 8051 |
[time.duration.special]: #time.duration.special
|
|
|
|
| 8062 |
[time.point]: #time.point
|
| 8063 |
[time.point.arithmetic]: #time.point.arithmetic
|
| 8064 |
[time.point.cast]: #time.point.cast
|
| 8065 |
[time.point.comparisons]: #time.point.comparisons
|
| 8066 |
[time.point.cons]: #time.point.cons
|
| 8067 |
+
[time.point.general]: #time.point.general
|
| 8068 |
[time.point.nonmember]: #time.point.nonmember
|
| 8069 |
[time.point.observer]: #time.point.observer
|
| 8070 |
[time.point.special]: #time.point.special
|
| 8071 |
[time.summary]: #time.summary
|
| 8072 |
[time.syn]: #time.syn
|