From Jason Turner

[time.cal.month]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp2_ifewuk/{from.md → to.md} +199 -0
tmp/tmp2_ifewuk/{from.md → to.md} RENAMED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Class `month` <a id="time.cal.month">[[time.cal.month]]</a>
2
+
3
+ #### Overview <a id="time.cal.month.overview">[[time.cal.month.overview]]</a>
4
+
5
+ ``` cpp
6
+ namespace std::chrono {
7
+ class month {
8
+ unsigned char m_; // exposition only
9
+ public:
10
+ month() = default;
11
+ constexpr explicit month(unsigned m) noexcept;
12
+
13
+ constexpr month& operator++() noexcept;
14
+ constexpr month operator++(int) noexcept;
15
+ constexpr month& operator--() noexcept;
16
+ constexpr month operator--(int) noexcept;
17
+
18
+ constexpr month& operator+=(const months& m) noexcept;
19
+ constexpr month& operator-=(const months& m) noexcept;
20
+
21
+ constexpr explicit operator unsigned() const noexcept;
22
+ constexpr bool ok() const noexcept;
23
+ };
24
+ }
25
+ ```
26
+
27
+ `month` represents a month of a year. It normally holds values in the
28
+ range 1 to 12, but may hold non-negative values outside this range. It
29
+ can be constructed with any `unsigned` value, which will be subsequently
30
+ truncated to fit into `month`’s unspecified internal storage. `month`
31
+ meets the *Cpp17EqualityComparable* ([[cpp17.equalitycomparable]]) and
32
+ *Cpp17LessThanComparable* ([[cpp17.lessthancomparable]]) requirements,
33
+ and participates in basic arithmetic with `months` objects, which
34
+ represent a difference between two `month` objects.
35
+
36
+ `month` is a trivially copyable and standard-layout class type.
37
+
38
+ #### Member functions <a id="time.cal.month.members">[[time.cal.month.members]]</a>
39
+
40
+ ``` cpp
41
+ constexpr explicit month(unsigned m) noexcept;
42
+ ```
43
+
44
+ *Effects:* Initializes `m_` with `m`. The value held is unspecified if
45
+ `m` is not in the range \[`0`, `255`\].
46
+
47
+ ``` cpp
48
+ constexpr month& operator++() noexcept;
49
+ ```
50
+
51
+ *Effects:* `*this += months{1}`.
52
+
53
+ *Returns:* `*this`.
54
+
55
+ ``` cpp
56
+ constexpr month operator++(int) noexcept;
57
+ ```
58
+
59
+ *Effects:* `++(*this)`.
60
+
61
+ *Returns:* A copy of `*this` as it existed on entry to this member
62
+ function.
63
+
64
+ ``` cpp
65
+ constexpr month& operator--() noexcept;
66
+ ```
67
+
68
+ *Effects:* `*this -= months{1}`.
69
+
70
+ *Returns:* `*this`.
71
+
72
+ ``` cpp
73
+ constexpr month operator--(int) noexcept;
74
+ ```
75
+
76
+ *Effects:* `–(*this)`.
77
+
78
+ *Returns:* A copy of `*this` as it existed on entry to this member
79
+ function.
80
+
81
+ ``` cpp
82
+ constexpr month& operator+=(const months& m) noexcept;
83
+ ```
84
+
85
+ *Effects:* `*this = *this + m`.
86
+
87
+ *Returns:* `*this`.
88
+
89
+ ``` cpp
90
+ constexpr month& operator-=(const months& m) noexcept;
91
+ ```
92
+
93
+ *Effects:* `*this = *this - m`.
94
+
95
+ *Returns:* `*this`.
96
+
97
+ ``` cpp
98
+ constexpr explicit operator unsigned() const noexcept;
99
+ ```
100
+
101
+ *Returns:* `m_`.
102
+
103
+ ``` cpp
104
+ constexpr bool ok() const noexcept;
105
+ ```
106
+
107
+ *Returns:* `1 <= m_ && m_ <= 12`.
108
+
109
+ #### Non-member functions <a id="time.cal.month.nonmembers">[[time.cal.month.nonmembers]]</a>
110
+
111
+ ``` cpp
112
+ constexpr bool operator==(const month& x, const month& y) noexcept;
113
+ ```
114
+
115
+ *Returns:* `unsigned{x} == unsigned{y}`.
116
+
117
+ ``` cpp
118
+ constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept;
119
+ ```
120
+
121
+ *Returns:* `unsigned{x} <=> unsigned{y}`.
122
+
123
+ ``` cpp
124
+ constexpr month operator+(const month& x, const months& y) noexcept;
125
+ ```
126
+
127
+ *Returns:*
128
+
129
+ ``` cpp
130
+ month{modulo(static_cast<long long>(unsigned{x}) + (y.count() - 1), 12) + 1}
131
+ ```
132
+
133
+ where `modulo(n, 12)` computes the remainder of `n` divided by 12 using
134
+ Euclidean division.
135
+
136
+ [*Note 1*: Given a divisor of 12, Euclidean division truncates towards
137
+ negative infinity and always produces a remainder in the range of \[`0`,
138
+ `11`\]. Assuming no overflow in the signed summation, this operation
139
+ results in a `month` holding a value in the range \[`1`, `12`\] even if
140
+ `!x.ok()`. — *end note*]
141
+
142
+ [*Example 1*: `February + months{11} == January`. — *end example*]
143
+
144
+ ``` cpp
145
+ constexpr month operator+(const months& x, const month& y) noexcept;
146
+ ```
147
+
148
+ *Returns:* `y + x`.
149
+
150
+ ``` cpp
151
+ constexpr month operator-(const month& x, const months& y) noexcept;
152
+ ```
153
+
154
+ *Returns:* `x + -y`.
155
+
156
+ ``` cpp
157
+ constexpr months operator-(const month& x, const month& y) noexcept;
158
+ ```
159
+
160
+ *Returns:* If `x.ok() == true` and `y.ok() == true`, returns a value `m`
161
+ in the range \[`months{0}`, `months{11}`\] satisfying `y + m == x`.
162
+ Otherwise the value returned is unspecified.
163
+
164
+ [*Example 2*: `January - February == months{11}`. — *end example*]
165
+
166
+ ``` cpp
167
+ template<class charT, class traits>
168
+ basic_ostream<charT, traits>&
169
+ operator<<(basic_ostream<charT, traits>& os, const month& m);
170
+ ```
171
+
172
+ *Effects:* Equivalent to:
173
+
174
+ ``` cpp
175
+ return os << (m.ok() ?
176
+ format(os.getloc(), STATICALLY-WIDEN<charT>("{:%b}"), m) :
177
+ format(os.getloc(), STATICALLY-WIDEN<charT>("{} is not a valid month"),
178
+ static_cast<unsigned>(m)));
179
+ ```
180
+
181
+ ``` cpp
182
+ template<class charT, class traits, class Alloc = allocator<charT>>
183
+ basic_istream<charT, traits>&
184
+ from_stream(basic_istream<charT, traits>& is, const charT* fmt,
185
+ month& m, basic_string<charT, traits, Alloc>* abbrev = nullptr,
186
+ minutes* offset = nullptr);
187
+ ```
188
+
189
+ *Effects:* Attempts to parse the input stream `is` into the `month` `m`
190
+ using the format flags given in the NTCTS `fmt` as specified in
191
+ [[time.parse]]. If the parse fails to decode a valid month,
192
+ `is.setstate(ios_base::failbit)` is called and `m` is not modified. If
193
+ `%Z` is used and successfully parsed, that value will be assigned to
194
+ `*abbrev` if `abbrev` is non-null. If `%z` (or a modified variant) is
195
+ used and successfully parsed, that value will be assigned to `*offset`
196
+ if `offset` is non-null.
197
+
198
+ *Returns:* `is`.
199
+