|
0 |
Index: time/src/date.rs
|
|
1 |
===================================================================
|
|
2 |
--- time.orig/src/date.rs
|
|
3 |
+++ time/src/date.rs
|
|
4 |
@@ -175,7 +175,7 @@ impl Date {
|
|
5 |
/// The algorithm to perform this conversion is derived from one provided by Peter Baum; it is
|
|
6 |
/// freely available [here](https://www.researchgate.net/publication/316558298_Date_Algorithms).
|
|
7 |
///
|
|
8 |
- /// ```rust
|
|
9 |
+ /// ```ignore
|
|
10 |
/// # use time::{Date, macros::date};
|
|
11 |
/// assert_eq!(Date::from_julian_day(0), Ok(date!(-4713 - 11 - 24)));
|
|
12 |
/// assert_eq!(Date::from_julian_day(2_451_545), Ok(date!(2000 - 01 - 01)));
|
|
13 |
@@ -230,7 +230,7 @@ impl Date {
|
|
14 |
// region: getters
|
|
15 |
/// Get the year of the date.
|
|
16 |
///
|
|
17 |
- /// ```rust
|
|
18 |
+ /// ```ignore
|
|
19 |
/// # use time::macros::date;
|
|
20 |
/// assert_eq!(date!(2019 - 01 - 01).year(), 2019);
|
|
21 |
/// assert_eq!(date!(2019 - 12 - 31).year(), 2019);
|
|
22 |
@@ -242,7 +242,7 @@ impl Date {
|
|
23 |
|
|
24 |
/// Get the month.
|
|
25 |
///
|
|
26 |
- /// ```rust
|
|
27 |
+ /// ```ignore
|
|
28 |
/// # use time::{macros::date, Month};
|
|
29 |
/// assert_eq!(date!(2019 - 01 - 01).month(), Month::January);
|
|
30 |
/// assert_eq!(date!(2019 - 12 - 31).month(), Month::December);
|
|
31 |
@@ -255,7 +255,7 @@ impl Date {
|
|
32 |
///
|
|
33 |
/// The returned value will always be in the range `1..=31`.
|
|
34 |
///
|
|
35 |
- /// ```rust
|
|
36 |
+ /// ```ignore
|
|
37 |
/// # use time::macros::date;
|
|
38 |
/// assert_eq!(date!(2019 - 01 - 01).day(), 1);
|
|
39 |
/// assert_eq!(date!(2019 - 12 - 31).day(), 31);
|
|
40 |
@@ -309,7 +309,7 @@ impl Date {
|
|
41 |
///
|
|
42 |
/// The returned value will always be in the range `1..=366` (`1..=365` for common years).
|
|
43 |
///
|
|
44 |
- /// ```rust
|
|
45 |
+ /// ```ignore
|
|
46 |
/// # use time::macros::date;
|
|
47 |
/// assert_eq!(date!(2019 - 01 - 01).ordinal(), 1);
|
|
48 |
/// assert_eq!(date!(2019 - 12 - 31).ordinal(), 365);
|
|
49 |
@@ -333,7 +333,7 @@ impl Date {
|
|
50 |
///
|
|
51 |
/// The returned value will always be in the range `1..=53`.
|
|
52 |
///
|
|
53 |
- /// ```rust
|
|
54 |
+ /// ```ignore
|
|
55 |
/// # use time::macros::date;
|
|
56 |
/// assert_eq!(date!(2019 - 01 - 01).iso_week(), 1);
|
|
57 |
/// assert_eq!(date!(2019 - 10 - 04).iso_week(), 40);
|
|
58 |
@@ -349,7 +349,7 @@ impl Date {
|
|
59 |
///
|
|
60 |
/// The returned value will always be in the range `0..=53`.
|
|
61 |
///
|
|
62 |
- /// ```rust
|
|
63 |
+ /// ```ignore
|
|
64 |
/// # use time::macros::date;
|
|
65 |
/// assert_eq!(date!(2019 - 01 - 01).sunday_based_week(), 0);
|
|
66 |
/// assert_eq!(date!(2020 - 01 - 01).sunday_based_week(), 0);
|
|
67 |
@@ -364,7 +364,7 @@ impl Date {
|
|
68 |
///
|
|
69 |
/// The returned value will always be in the range `0..=53`.
|
|
70 |
///
|
|
71 |
- /// ```rust
|
|
72 |
+ /// ```ignore
|
|
73 |
/// # use time::macros::date;
|
|
74 |
/// assert_eq!(date!(2019 - 01 - 01).monday_based_week(), 0);
|
|
75 |
/// assert_eq!(date!(2020 - 01 - 01).monday_based_week(), 0);
|
|
76 |
@@ -377,7 +377,7 @@ impl Date {
|
|
77 |
|
|
78 |
/// Get the year, month, and day.
|
|
79 |
///
|
|
80 |
- /// ```rust
|
|
81 |
+ /// ```ignore
|
|
82 |
/// # use time::{macros::date, Month};
|
|
83 |
/// assert_eq!(
|
|
84 |
/// date!(2019 - 01 - 01).to_calendar_date(),
|
|
85 |
@@ -391,7 +391,7 @@ impl Date {
|
|
86 |
|
|
87 |
/// Get the year and ordinal day number.
|
|
88 |
///
|
|
89 |
- /// ```rust
|
|
90 |
+ /// ```ignore
|
|
91 |
/// # use time::macros::date;
|
|
92 |
/// assert_eq!(date!(2019 - 01 - 01).to_ordinal_date(), (2019, 1));
|
|
93 |
/// ```
|
|
94 |
@@ -401,7 +401,7 @@ impl Date {
|
|
95 |
|
|
96 |
/// Get the ISO 8601 year, week number, and weekday.
|
|
97 |
///
|
|
98 |
- /// ```rust
|
|
99 |
+ /// ```ignore
|
|
100 |
/// # use time::{Weekday::*, macros::date};
|
|
101 |
/// assert_eq!(date!(2019 - 01 - 01).to_iso_week_date(), (2019, 1, Tuesday));
|
|
102 |
/// assert_eq!(date!(2019 - 10 - 04).to_iso_week_date(), (2019, 40, Friday));
|
|
103 |
@@ -428,7 +428,7 @@ impl Date {
|
|
104 |
|
|
105 |
/// Get the weekday.
|
|
106 |
///
|
|
107 |
- /// ```rust
|
|
108 |
+ /// ```ignore
|
|
109 |
/// # use time::{Weekday::*, macros::date};
|
|
110 |
/// assert_eq!(date!(2019 - 01 - 01).weekday(), Tuesday);
|
|
111 |
/// assert_eq!(date!(2019 - 02 - 01).weekday(), Friday);
|
|
112 |
@@ -457,7 +457,7 @@ impl Date {
|
|
113 |
|
|
114 |
/// Get the next calendar date.
|
|
115 |
///
|
|
116 |
- /// ```rust
|
|
117 |
+ /// ```ignore
|
|
118 |
/// # use time::{Date, macros::date};
|
|
119 |
/// assert_eq!(
|
|
120 |
/// date!(2019 - 01 - 01).next_day(),
|
|
121 |
@@ -489,7 +489,7 @@ impl Date {
|
|
122 |
|
|
123 |
/// Get the previous calendar date.
|
|
124 |
///
|
|
125 |
- /// ```rust
|
|
126 |
+ /// ```ignore
|
|
127 |
/// # use time::{Date, macros::date};
|
|
128 |
/// assert_eq!(
|
|
129 |
/// date!(2019 - 01 - 02).previous_day(),
|
|
130 |
@@ -525,7 +525,7 @@ impl Date {
|
|
131 |
/// The algorithm to perform this conversion is derived from one provided by Peter Baum; it is
|
|
132 |
/// freely available [here](https://www.researchgate.net/publication/316558298_Date_Algorithms).
|
|
133 |
///
|
|
134 |
- /// ```rust
|
|
135 |
+ /// ```ignore
|
|
136 |
/// # use time::macros::date;
|
|
137 |
/// assert_eq!(date!(-4713 - 11 - 24).to_julian_day(), 0);
|
|
138 |
/// assert_eq!(date!(2000 - 01 - 01).to_julian_day(), 2_451_545);
|
|
139 |
@@ -545,7 +545,7 @@ impl Date {
|
|
140 |
// region: checked arithmetic
|
|
141 |
/// Computes `self + duration`, returning `None` if an overflow occurred.
|
|
142 |
///
|
|
143 |
- /// ```rust
|
|
144 |
+ /// ```ignore
|
|
145 |
/// # use time::{Date, ext::NumericalDuration, macros::date};
|
|
146 |
/// assert_eq!(Date::MAX.checked_add(1.days()), None);
|
|
147 |
/// assert_eq!(Date::MIN.checked_add((-2).days()), None);
|
|
148 |
@@ -559,7 +559,7 @@ impl Date {
|
|
149 |
///
|
|
150 |
/// This function only takes whole days into account.
|
|
151 |
///
|
|
152 |
- /// ```rust
|
|
153 |
+ /// ```ignore
|
|
154 |
/// # use time::{Date, ext::NumericalDuration, macros::date};
|
|
155 |
/// assert_eq!(Date::MAX.checked_add(23.hours()), Some(Date::MAX));
|
|
156 |
/// assert_eq!(Date::MIN.checked_add((-23).hours()), Some(Date::MIN));
|
|
157 |
@@ -588,7 +588,7 @@ impl Date {
|
|
158 |
|
|
159 |
/// Computes `self - duration`, returning `None` if an overflow occurred.
|
|
160 |
///
|
|
161 |
- /// ```
|
|
162 |
+ /// ```ignore
|
|
163 |
/// # use time::{Date, ext::NumericalDuration, macros::date};
|
|
164 |
/// assert_eq!(Date::MAX.checked_sub((-2).days()), None);
|
|
165 |
/// assert_eq!(Date::MIN.checked_sub(1.days()), None);
|
|
166 |
@@ -602,7 +602,7 @@ impl Date {
|
|
167 |
///
|
|
168 |
/// This function only takes whole days into account.
|
|
169 |
///
|
|
170 |
- /// ```
|
|
171 |
+ /// ```ignore
|
|
172 |
/// # use time::{Date, ext::NumericalDuration, macros::date};
|
|
173 |
/// assert_eq!(Date::MAX.checked_sub((-23).hours()), Some(Date::MAX));
|
|
174 |
/// assert_eq!(Date::MIN.checked_sub(23.hours()), Some(Date::MIN));
|
|
175 |
@@ -637,7 +637,7 @@ impl Date {
|
|
176 |
/// Create a [`PrimitiveDateTime`] using the existing date. The [`Time`] component will be set
|
|
177 |
/// to midnight.
|
|
178 |
///
|
|
179 |
- /// ```rust
|
|
180 |
+ /// ```ignore
|
|
181 |
/// # use time::macros::{date, datetime};
|
|
182 |
/// assert_eq!(date!(1970-01-01).midnight(), datetime!(1970-01-01 0:00));
|
|
183 |
/// ```
|
|
184 |
@@ -647,7 +647,7 @@ impl Date {
|
|
185 |
|
|
186 |
/// Create a [`PrimitiveDateTime`] using the existing date and the provided [`Time`].
|
|
187 |
///
|
|
188 |
- /// ```rust
|
|
189 |
+ /// ```ignore
|
|
190 |
/// # use time::macros::{date, datetime, time};
|
|
191 |
/// assert_eq!(
|
|
192 |
/// date!(1970-01-01).with_time(time!(0:00)),
|
|
193 |
@@ -660,7 +660,7 @@ impl Date {
|
|
194 |
|
|
195 |
/// Attempt to create a [`PrimitiveDateTime`] using the existing date and the provided time.
|
|
196 |
///
|
|
197 |
- /// ```rust
|
|
198 |
+ /// ```ignore
|
|
199 |
/// # use time::macros::date;
|
|
200 |
/// assert!(date!(1970 - 01 - 01).with_hms(0, 0, 0).is_ok());
|
|
201 |
/// assert!(date!(1970 - 01 - 01).with_hms(24, 0, 0).is_err());
|
|
202 |
@@ -679,7 +679,7 @@ impl Date {
|
|
203 |
|
|
204 |
/// Attempt to create a [`PrimitiveDateTime`] using the existing date and the provided time.
|
|
205 |
///
|
|
206 |
- /// ```rust
|
|
207 |
+ /// ```ignore
|
|
208 |
/// # use time::macros::date;
|
|
209 |
/// assert!(date!(1970 - 01 - 01).with_hms_milli(0, 0, 0, 0).is_ok());
|
|
210 |
/// assert!(date!(1970 - 01 - 01).with_hms_milli(24, 0, 0, 0).is_err());
|
|
211 |
@@ -699,7 +699,7 @@ impl Date {
|
|
212 |
|
|
213 |
/// Attempt to create a [`PrimitiveDateTime`] using the existing date and the provided time.
|
|
214 |
///
|
|
215 |
- /// ```rust
|
|
216 |
+ /// ```ignore
|
|
217 |
/// # use time::macros::date;
|
|
218 |
/// assert!(date!(1970 - 01 - 01).with_hms_micro(0, 0, 0, 0).is_ok());
|
|
219 |
/// assert!(date!(1970 - 01 - 01).with_hms_micro(24, 0, 0, 0).is_err());
|
|
220 |
@@ -719,7 +719,7 @@ impl Date {
|
|
221 |
|
|
222 |
/// Attempt to create a [`PrimitiveDateTime`] using the existing date and the provided time.
|
|
223 |
///
|
|
224 |
- /// ```rust
|
|
225 |
+ /// ```ignore
|
|
226 |
/// # use time::macros::date;
|
|
227 |
/// assert!(date!(1970 - 01 - 01).with_hms_nano(0, 0, 0, 0).is_ok());
|
|
228 |
/// assert!(date!(1970 - 01 - 01).with_hms_nano(24, 0, 0, 0).is_err());
|
|
229 |
@@ -753,7 +753,7 @@ impl Date {
|
|
230 |
|
|
231 |
/// Format the `Date` using the provided [format description](crate::format_description).
|
|
232 |
///
|
|
233 |
- /// ```rust
|
|
234 |
+ /// ```ignore
|
|
235 |
/// # use time::{format_description, macros::date};
|
|
236 |
/// let format = format_description::parse("[year]-[month]-[day]")?;
|
|
237 |
/// assert_eq!(date!(2020 - 01 - 02).format(&format)?, "2020-01-02");
|
|
238 |
@@ -769,7 +769,7 @@ impl Date {
|
|
239 |
/// Parse a `Date` from the input using the provided [format
|
|
240 |
/// description](crate::format_description).
|
|
241 |
///
|
|
242 |
- /// ```rust
|
|
243 |
+ /// ```ignore
|
|
244 |
/// # use time::{format_description, macros::date, Date};
|
|
245 |
/// let format = format_description::parse("[year]-[month]-[day]")?;
|
|
246 |
/// assert_eq!(Date::parse("2020-01-02", &format)?, date!(2020 - 01 - 02));
|
|
247 |
Index: time/src/offset_date_time.rs
|
|
248 |
===================================================================
|
|
249 |
--- time.orig/src/offset_date_time.rs
|
|
250 |
+++ time/src/offset_date_time.rs
|
|
251 |
@@ -38,7 +38,7 @@ pub struct OffsetDateTime {
|
|
252 |
impl OffsetDateTime {
|
|
253 |
/// Midnight, 1 January, 1970 (UTC).
|
|
254 |
///
|
|
255 |
- /// ```rust
|
|
256 |
+ /// ```ignore
|
|
257 |
/// # use time::{OffsetDateTime, macros::datetime};
|
|
258 |
/// assert_eq!(OffsetDateTime::UNIX_EPOCH, datetime!(1970-01-01 0:00 UTC),);
|
|
259 |
/// ```
|
|
260 |
@@ -49,7 +49,7 @@ impl OffsetDateTime {
|
|
261 |
// region: now
|
|
262 |
/// Create a new `OffsetDateTime` with the current date and time in UTC.
|
|
263 |
///
|
|
264 |
- /// ```rust
|
|
265 |
+ /// ```ignore
|
|
266 |
/// # use time::{OffsetDateTime, macros::offset};
|
|
267 |
/// assert!(OffsetDateTime::now_utc().year() >= 2019);
|
|
268 |
/// assert_eq!(OffsetDateTime::now_utc().offset(), offset!(UTC));
|
|
269 |
@@ -79,7 +79,7 @@ impl OffsetDateTime {
|
|
270 |
|
|
271 |
/// Convert the `OffsetDateTime` from the current [`UtcOffset`] to the provided [`UtcOffset`].
|
|
272 |
///
|
|
273 |
- /// ```rust
|
|
274 |
+ /// ```ignore
|
|
275 |
/// # use time::macros::{datetime, offset};
|
|
276 |
/// assert_eq!(
|
|
277 |
/// datetime!(2000-01-01 0:00 UTC)
|
|
278 |
@@ -109,7 +109,7 @@ impl OffsetDateTime {
|
|
279 |
/// Create an `OffsetDateTime` from the provided Unix timestamp. Calling `.offset()` on the
|
|
280 |
/// resulting value is guaranteed to return UTC.
|
|
281 |
///
|
|
282 |
- /// ```rust
|
|
283 |
+ /// ```ignore
|
|
284 |
/// # use time::{OffsetDateTime, macros::datetime};
|
|
285 |
/// assert_eq!(
|
|
286 |
/// OffsetDateTime::from_unix_timestamp(0),
|
|
287 |
@@ -163,7 +163,7 @@ impl OffsetDateTime {
|
|
288 |
/// Construct an `OffsetDateTime` from the provided Unix timestamp (in nanoseconds). Calling
|
|
289 |
/// `.offset()` on the resulting value is guaranteed to return UTC.
|
|
290 |
///
|
|
291 |
- /// ```rust
|
|
292 |
+ /// ```ignore
|
|
293 |
/// # use time::{OffsetDateTime, macros::datetime};
|
|
294 |
/// assert_eq!(
|
|
295 |
/// OffsetDateTime::from_unix_timestamp_nanos(0),
|
|
296 |
@@ -194,7 +194,7 @@ impl OffsetDateTime {
|
|
297 |
// region: getters
|
|
298 |
/// Get the [`UtcOffset`].
|
|
299 |
///
|
|
300 |
- /// ```rust
|
|
301 |
+ /// ```ignore
|
|
302 |
/// # use time::macros::{datetime, offset};
|
|
303 |
/// assert_eq!(datetime!(2019-01-01 0:00 UTC).offset(), offset!(UTC));
|
|
304 |
/// assert_eq!(datetime!(2019-01-01 0:00 +1).offset(), offset!(+1));
|
|
305 |
@@ -205,7 +205,7 @@ impl OffsetDateTime {
|
|
306 |
|
|
307 |
/// Get the [Unix timestamp](https://en.wikipedia.org/wiki/Unix_time).
|
|
308 |
///
|
|
309 |
- /// ```rust
|
|
310 |
+ /// ```ignore
|
|
311 |
/// # use time::macros::datetime;
|
|
312 |
/// assert_eq!(datetime!(1970-01-01 0:00 UTC).unix_timestamp(), 0);
|
|
313 |
/// assert_eq!(datetime!(1970-01-01 0:00 -1).unix_timestamp(), 3_600);
|
|
314 |
@@ -221,7 +221,7 @@ impl OffsetDateTime {
|
|
315 |
|
|
316 |
/// Get the Unix timestamp in nanoseconds.
|
|
317 |
///
|
|
318 |
- /// ```rust
|
|
319 |
+ /// ```ignore
|
|
320 |
/// use time::macros::datetime;
|
|
321 |
/// assert_eq!(datetime!(1970-01-01 0:00 UTC).unix_timestamp_nanos(), 0);
|
|
322 |
/// assert_eq!(
|
|
323 |
@@ -235,7 +235,7 @@ impl OffsetDateTime {
|
|
324 |
|
|
325 |
/// Get the [`Date`] in the stored offset.
|
|
326 |
///
|
|
327 |
- /// ```rust
|
|
328 |
+ /// ```ignore
|
|
329 |
/// # use time::macros::{date, datetime, offset};
|
|
330 |
/// assert_eq!(datetime!(2019-01-01 0:00 UTC).date(), date!(2019-01-01));
|
|
331 |
/// assert_eq!(
|
|
332 |
@@ -261,7 +261,7 @@ impl OffsetDateTime {
|
|
333 |
|
|
334 |
/// Get the [`Time`] in the stored offset.
|
|
335 |
///
|
|
336 |
- /// ```rust
|
|
337 |
+ /// ```ignore
|
|
338 |
/// # use time::macros::{datetime, offset, time};
|
|
339 |
/// assert_eq!(datetime!(2019-01-01 0:00 UTC).time(), time!(0:00));
|
|
340 |
/// assert_eq!(
|
|
341 |
@@ -290,7 +290,7 @@ impl OffsetDateTime {
|
|
342 |
// region: date getters
|
|
343 |
/// Get the year of the date in the stored offset.
|
|
344 |
///
|
|
345 |
- /// ```rust
|
|
346 |
+ /// ```ignore
|
|
347 |
/// # use time::macros::{datetime, offset};
|
|
348 |
/// assert_eq!(datetime!(2019-01-01 0:00 UTC).year(), 2019);
|
|
349 |
/// assert_eq!(
|
|
350 |
@@ -317,7 +317,7 @@ impl OffsetDateTime {
|
|
351 |
|
|
352 |
/// Get the month of the date in the stored offset.
|
|
353 |
///
|
|
354 |
- /// ```rust
|
|
355 |
+ /// ```ignore
|
|
356 |
/// # use time::Month;
|
|
357 |
/// # use time::macros::{datetime, offset};
|
|
358 |
/// assert_eq!(datetime!(2019-01-01 0:00 UTC).month(), Month::January);
|
|
359 |
@@ -336,7 +336,7 @@ impl OffsetDateTime {
|
|
360 |
///
|
|
361 |
/// The returned value will always be in the range `1..=31`.
|
|
362 |
///
|
|
363 |
- /// ```rust
|
|
364 |
+ /// ```ignore
|
|
365 |
/// # use time::macros::{datetime, offset};
|
|
366 |
/// assert_eq!(datetime!(2019-01-01 0:00 UTC).day(), 1);
|
|
367 |
/// assert_eq!(
|
|
368 |
@@ -354,7 +354,7 @@ impl OffsetDateTime {
|
|
369 |
///
|
|
370 |
/// The returned value will always be in the range `1..=366`.
|
|
371 |
///
|
|
372 |
- /// ```rust
|
|
373 |
+ /// ```ignore
|
|
374 |
/// # use time::macros::{datetime, offset};
|
|
375 |
/// assert_eq!(datetime!(2019-01-01 0:00 UTC).ordinal(), 1);
|
|
376 |
/// assert_eq!(
|
|
377 |
@@ -382,7 +382,7 @@ impl OffsetDateTime {
|
|
378 |
///
|
|
379 |
/// The returned value will always be in the range `1..=53`.
|
|
380 |
///
|
|
381 |
- /// ```rust
|
|
382 |
+ /// ```ignore
|
|
383 |
/// # use time::macros::datetime;
|
|
384 |
/// assert_eq!(datetime!(2019-01-01 0:00 UTC).iso_week(), 1);
|
|
385 |
/// assert_eq!(datetime!(2020-01-01 0:00 UTC).iso_week(), 1);
|
|
386 |
@@ -397,7 +397,7 @@ impl OffsetDateTime {
|
|
387 |
///
|
|
388 |
/// The returned value will always be in the range `0..=53`.
|
|
389 |
///
|
|
390 |
- /// ```rust
|
|
391 |
+ /// ```ignore
|
|
392 |
/// # use time::macros::datetime;
|
|
393 |
/// assert_eq!(datetime!(2019-01-01 0:00 UTC).sunday_based_week(), 0);
|
|
394 |
/// assert_eq!(datetime!(2020-01-01 0:00 UTC).sunday_based_week(), 0);
|
|
395 |
@@ -412,7 +412,7 @@ impl OffsetDateTime {
|
|
396 |
///
|
|
397 |
/// The returned value will always be in the range `0..=53`.
|
|
398 |
///
|
|
399 |
- /// ```rust
|
|
400 |
+ /// ```ignore
|
|
401 |
/// # use time::macros::datetime;
|
|
402 |
/// assert_eq!(datetime!(2019-01-01 0:00 UTC).monday_based_week(), 0);
|
|
403 |
/// assert_eq!(datetime!(2020-01-01 0:00 UTC).monday_based_week(), 0);
|
|
404 |
@@ -425,7 +425,7 @@ impl OffsetDateTime {
|
|
405 |
|
|
406 |
/// Get the year, month, and day.
|
|
407 |
///
|
|
408 |
- /// ```rust
|
|
409 |
+ /// ```ignore
|
|
410 |
/// # use time::{macros::datetime, Month};
|
|
411 |
/// assert_eq!(
|
|
412 |
/// datetime!(2019-01-01 0:00 UTC).to_calendar_date(),
|
|
413 |
@@ -438,7 +438,7 @@ impl OffsetDateTime {
|
|
414 |
|
|
415 |
/// Get the year and ordinal day number.
|
|
416 |
///
|
|
417 |
- /// ```rust
|
|
418 |
+ /// ```ignore
|
|
419 |
/// # use time::macros::datetime;
|
|
420 |
/// assert_eq!(
|
|
421 |
/// datetime!(2019-01-01 0:00 UTC).to_ordinal_date(),
|
|
422 |
@@ -451,7 +451,7 @@ impl OffsetDateTime {
|
|
423 |
|
|
424 |
/// Get the ISO 8601 year, week number, and weekday.
|
|
425 |
///
|
|
426 |
- /// ```rust
|
|
427 |
+ /// ```ignore
|
|
428 |
/// # use time::{Weekday::*, macros::datetime};
|
|
429 |
/// assert_eq!(
|
|
430 |
/// datetime!(2019-01-01 0:00 UTC).to_iso_week_date(),
|
|
431 |
@@ -480,7 +480,7 @@ impl OffsetDateTime {
|
|
432 |
|
|
433 |
/// Get the weekday of the date in the stored offset.
|
|
434 |
///
|
|
435 |
- /// ```rust
|
|
436 |
+ /// ```ignore
|
|
437 |
/// # use time::{Weekday::*, macros::datetime};
|
|
438 |
/// assert_eq!(datetime!(2019-01-01 0:00 UTC).weekday(), Tuesday);
|
|
439 |
/// assert_eq!(datetime!(2019-02-01 0:00 UTC).weekday(), Friday);
|
|
440 |
@@ -495,7 +495,7 @@ impl OffsetDateTime {
|
|
441 |
/// The algorithm to perform this conversion is derived from one provided by Peter Baum; it is
|
|
442 |
/// freely available [here](https://www.researchgate.net/publication/316558298_Date_Algorithms).
|
|
443 |
///
|
|
444 |
- /// ```rust
|
|
445 |
+ /// ```ignore
|
|
446 |
/// # use time::macros::datetime;
|
|
447 |
/// assert_eq!(datetime!(-4713-11-24 0:00 UTC).to_julian_day(), 0);
|
|
448 |
/// assert_eq!(datetime!(2000-01-01 0:00 UTC).to_julian_day(), 2_451_545);
|
|
449 |
@@ -510,7 +510,7 @@ impl OffsetDateTime {
|
|
450 |
// region: time getters
|
|
451 |
/// Get the clock hour, minute, and second.
|
|
452 |
///
|
|
453 |
- /// ```rust
|
|
454 |
+ /// ```ignore
|
|
455 |
/// # use time::macros::datetime;
|
|
456 |
/// assert_eq!(datetime!(2020-01-01 0:00:00 UTC).to_hms(), (0, 0, 0));
|
|
457 |
/// assert_eq!(datetime!(2020-01-01 23:59:59 UTC).to_hms(), (23, 59, 59));
|
|
458 |
@@ -521,7 +521,7 @@ impl OffsetDateTime {
|
|
459 |
|
|
460 |
/// Get the clock hour, minute, second, and millisecond.
|
|
461 |
///
|
|
462 |
- /// ```rust
|
|
463 |
+ /// ```ignore
|
|
464 |
/// # use time::macros::datetime;
|
|
465 |
/// assert_eq!(
|
|
466 |
/// datetime!(2020-01-01 0:00:00 UTC).to_hms_milli(),
|
|
467 |
@@ -538,7 +538,7 @@ impl OffsetDateTime {
|
|
468 |
|
|
469 |
/// Get the clock hour, minute, second, and microsecond.
|
|
470 |
///
|
|
471 |
- /// ```rust
|
|
472 |
+ /// ```ignore
|
|
473 |
/// # use time::macros::datetime;
|
|
474 |
/// assert_eq!(
|
|
475 |
/// datetime!(2020-01-01 0:00:00 UTC).to_hms_micro(),
|
|
476 |
@@ -555,7 +555,7 @@ impl OffsetDateTime {
|
|
477 |
|
|
478 |
/// Get the clock hour, minute, second, and nanosecond.
|
|
479 |
///
|
|
480 |
- /// ```rust
|
|
481 |
+ /// ```ignore
|
|
482 |
/// # use time::macros::datetime;
|
|
483 |
/// assert_eq!(
|
|
484 |
/// datetime!(2020-01-01 0:00:00 UTC).to_hms_nano(),
|
|
485 |
@@ -574,7 +574,7 @@ impl OffsetDateTime {
|
|
486 |
///
|
|
487 |
/// The returned value will always be in the range `0..24`.
|
|
488 |
///
|
|
489 |
- /// ```rust
|
|
490 |
+ /// ```ignore
|
|
491 |
/// # use time::macros::{datetime, offset};
|
|
492 |
/// assert_eq!(datetime!(2019-01-01 0:00 UTC).hour(), 0);
|
|
493 |
/// assert_eq!(
|
|
494 |
@@ -598,7 +598,7 @@ impl OffsetDateTime {
|
|
495 |
///
|
|
496 |
/// The returned value will always be in the range `0..60`.
|
|
497 |
///
|
|
498 |
- /// ```rust
|
|
499 |
+ /// ```ignore
|
|
500 |
/// # use time::macros::{datetime, offset};
|
|
501 |
/// assert_eq!(datetime!(2019-01-01 0:00 UTC).minute(), 0);
|
|
502 |
/// assert_eq!(
|
|
503 |
@@ -620,7 +620,7 @@ impl OffsetDateTime {
|
|
504 |
///
|
|
505 |
/// The returned value will always be in the range `0..60`.
|
|
506 |
///
|
|
507 |
- /// ```rust
|
|
508 |
+ /// ```ignore
|
|
509 |
/// # use time::macros::{datetime, offset};
|
|
510 |
/// assert_eq!(datetime!(2019-01-01 0:00 UTC).second(), 0);
|
|
511 |
/// assert_eq!(
|
|
512 |
@@ -642,7 +642,7 @@ impl OffsetDateTime {
|
|
513 |
///
|
|
514 |
/// The returned value will always be in the range `0..1_000`.
|
|
515 |
///
|
|
516 |
- /// ```rust
|
|
517 |
+ /// ```ignore
|
|
518 |
/// # use time::macros::datetime;
|
|
519 |
/// assert_eq!(datetime!(2019-01-01 0:00 UTC).millisecond(), 0);
|
|
520 |
/// assert_eq!(datetime!(2019-01-01 23:59:59.999 UTC).millisecond(), 999);
|
|
521 |
@@ -655,7 +655,7 @@ impl OffsetDateTime {
|
|
522 |
///
|
|
523 |
/// The returned value will always be in the range `0..1_000_000`.
|
|
524 |
///
|
|
525 |
- /// ```rust
|
|
526 |
+ /// ```ignore
|
|
527 |
/// # use time::macros::datetime;
|
|
528 |
/// assert_eq!(datetime!(2019-01-01 0:00 UTC).microsecond(), 0);
|
|
529 |
/// assert_eq!(
|
|
530 |
@@ -671,7 +671,7 @@ impl OffsetDateTime {
|
|
531 |
///
|
|
532 |
/// The returned value will always be in the range `0..1_000_000_000`.
|
|
533 |
///
|
|
534 |
- /// ```rust
|
|
535 |
+ /// ```ignore
|
|
536 |
/// # use time::macros::datetime;
|
|
537 |
/// assert_eq!(datetime!(2019-01-01 0:00 UTC).nanosecond(), 0);
|
|
538 |
/// assert_eq!(
|
|
539 |
@@ -688,7 +688,7 @@ impl OffsetDateTime {
|
|
540 |
// region: checked arithmetic
|
|
541 |
/// Computes `self + duration`, returning `None` if an overflow occurred.
|
|
542 |
///
|
|
543 |
- /// ```
|
|
544 |
+ /// ```ignore
|
|
545 |
/// # use time::{Date, ext::NumericalDuration};
|
|
546 |
/// # use time::macros::{datetime, offset};
|
|
547 |
/// let datetime = Date::MIN.midnight().assume_offset(offset!(+10:00));
|
|
548 |
@@ -709,7 +709,7 @@ impl OffsetDateTime {
|
|
549 |
|
|
550 |
/// Computes `self - duration`, returning `None` if an overflow occurred.
|
|
551 |
///
|
|
552 |
- /// ```
|
|
553 |
+ /// ```ignore
|
|
554 |
/// # use time::{Date, ext::NumericalDuration};
|
|
555 |
/// # use time::macros::{datetime, offset};
|
|
556 |
/// let datetime = Date::MIN.midnight().assume_offset(offset!(+10:00));
|
|
557 |
@@ -737,7 +737,7 @@ impl OffsetDateTime {
|
|
558 |
/// Replace the time, which is assumed to be in the stored offset. The date and offset
|
|
559 |
/// components are unchanged.
|
|
560 |
///
|
|
561 |
- /// ```rust
|
|
562 |
+ /// ```ignore
|
|
563 |
/// # use time::macros::{datetime, time};
|
|
564 |
/// assert_eq!(
|
|
565 |
/// datetime!(2020-01-01 5:00 UTC).replace_time(time!(12:00)),
|
|
566 |
@@ -763,7 +763,7 @@ impl OffsetDateTime {
|
|
567 |
/// Replace the date, which is assumed to be in the stored offset. The time and offset
|
|
568 |
/// components are unchanged.
|
|
569 |
///
|
|
570 |
- /// ```rust
|
|
571 |
+ /// ```ignore
|
|
572 |
/// # use time::macros::{datetime, date};
|
|
573 |
/// assert_eq!(
|
|
574 |
/// datetime!(2020-01-01 12:00 UTC).replace_date(date!(2020-01-30)),
|
|
575 |
@@ -785,7 +785,7 @@ impl OffsetDateTime {
|
|
576 |
/// Replace the date and time, which are assumed to be in the stored offset. The offset
|
|
577 |
/// component remains unchanged.
|
|
578 |
///
|
|
579 |
- /// ```rust
|
|
580 |
+ /// ```ignore
|
|
581 |
/// # use time::macros::datetime;
|
|
582 |
/// assert_eq!(
|
|
583 |
/// datetime!(2020-01-01 12:00 UTC).replace_date_time(datetime!(2020-01-30 16:00)),
|
|
584 |
@@ -803,7 +803,7 @@ impl OffsetDateTime {
|
|
585 |
|
|
586 |
/// Replace the offset. The date and time components remain unchanged.
|
|
587 |
///
|
|
588 |
- /// ```rust
|
|
589 |
+ /// ```ignore
|
|
590 |
/// # use time::macros::{datetime, offset};
|
|
591 |
/// assert_eq!(
|
|
592 |
/// datetime!(2020-01-01 0:00 UTC).replace_offset(offset!(-5)),
|
|
593 |
@@ -839,7 +839,7 @@ impl OffsetDateTime {
|
|
594 |
/// Format the `OffsetDateTime` using the provided [format
|
|
595 |
/// description](crate::format_description).
|
|
596 |
///
|
|
597 |
- /// ```rust
|
|
598 |
+ /// ```ignore
|
|
599 |
/// # use time::{format_description, macros::datetime};
|
|
600 |
/// let format = format_description::parse(
|
|
601 |
/// "[year]-[month]-[day] [hour]:[minute]:[second] [offset_hour \
|
|
602 |
@@ -862,7 +862,7 @@ impl OffsetDateTime {
|
|
603 |
/// Parse an `OffsetDateTime` from the input using the provided [format
|
|
604 |
/// description](crate::format_description).
|
|
605 |
///
|
|
606 |
- /// ```rust
|
|
607 |
+ /// ```ignore
|
|
608 |
/// # use time::{format_description, macros::datetime, OffsetDateTime};
|
|
609 |
/// let format = format_description::parse(
|
|
610 |
/// "[year]-[month]-[day] [hour]:[minute]:[second] [offset_hour \
|
|
611 |
Index: time/src/primitive_date_time.rs
|
|
612 |
===================================================================
|
|
613 |
--- time.orig/src/primitive_date_time.rs
|
|
614 |
+++ time/src/primitive_date_time.rs
|
|
615 |
@@ -26,7 +26,7 @@ pub struct PrimitiveDateTime {
|
|
616 |
impl PrimitiveDateTime {
|
|
617 |
/// Create a new `PrimitiveDateTime` from the provided [`Date`] and [`Time`].
|
|
618 |
///
|
|
619 |
- /// ```rust
|
|
620 |
+ /// ```ignore
|
|
621 |
/// # use time::{PrimitiveDateTime, macros::{date, datetime, time}};
|
|
622 |
/// assert_eq!(
|
|
623 |
/// PrimitiveDateTime::new(date!(2019-01-01), time!(0:00)),
|
|
624 |
@@ -40,7 +40,7 @@ impl PrimitiveDateTime {
|
|
625 |
// region: component getters
|
|
626 |
/// Get the [`Date`] component of the `PrimitiveDateTime`.
|
|
627 |
///
|
|
628 |
- /// ```rust
|
|
629 |
+ /// ```ignore
|
|
630 |
/// # use time::macros::{date, datetime};
|
|
631 |
/// assert_eq!(datetime!(2019-01-01 0:00).date(), date!(2019-01-01));
|
|
632 |
/// ```
|
|
633 |
@@ -50,7 +50,7 @@ impl PrimitiveDateTime {
|
|
634 |
|
|
635 |
/// Get the [`Time`] component of the `PrimitiveDateTime`.
|
|
636 |
///
|
|
637 |
- /// ```rust
|
|
638 |
+ /// ```ignore
|
|
639 |
/// # use time::macros::{datetime, time};
|
|
640 |
/// assert_eq!(datetime!(2019-01-01 0:00).time(), time!(0:00));
|
|
641 |
pub const fn time(self) -> Time {
|
|
642 |
@@ -61,7 +61,7 @@ impl PrimitiveDateTime {
|
|
643 |
// region: date getters
|
|
644 |
/// Get the year of the date.
|
|
645 |
///
|
|
646 |
- /// ```rust
|
|
647 |
+ /// ```ignore
|
|
648 |
/// # use time::macros::datetime;
|
|
649 |
/// assert_eq!(datetime!(2019-01-01 0:00).year(), 2019);
|
|
650 |
/// assert_eq!(datetime!(2019-12-31 0:00).year(), 2019);
|
|
651 |
@@ -73,7 +73,7 @@ impl PrimitiveDateTime {
|
|
652 |
|
|
653 |
/// Get the month of the date.
|
|
654 |
///
|
|
655 |
- /// ```rust
|
|
656 |
+ /// ```ignore
|
|
657 |
/// # use time::{macros::datetime, Month};
|
|
658 |
/// assert_eq!(datetime!(2019-01-01 0:00).month(), Month::January);
|
|
659 |
/// assert_eq!(datetime!(2019-12-31 0:00).month(), Month::December);
|
|
660 |
@@ -86,7 +86,7 @@ impl PrimitiveDateTime {
|
|
661 |
///
|
|
662 |
/// The returned value will always be in the range `1..=31`.
|
|
663 |
///
|
|
664 |
- /// ```rust
|
|
665 |
+ /// ```ignore
|
|
666 |
/// # use time::macros::datetime;
|
|
667 |
/// assert_eq!(datetime!(2019-01-01 0:00).day(), 1);
|
|
668 |
/// assert_eq!(datetime!(2019-12-31 0:00).day(), 31);
|
|
669 |
@@ -99,7 +99,7 @@ impl PrimitiveDateTime {
|
|
670 |
///
|
|
671 |
/// The returned value will always be in the range `1..=366` (`1..=365` for common years).
|
|
672 |
///
|
|
673 |
- /// ```rust
|
|
674 |
+ /// ```ignore
|
|
675 |
/// # use time::macros::datetime;
|
|
676 |
/// assert_eq!(datetime!(2019-01-01 0:00).ordinal(), 1);
|
|
677 |
/// assert_eq!(datetime!(2019-12-31 0:00).ordinal(), 365);
|
|
678 |
@@ -112,7 +112,7 @@ impl PrimitiveDateTime {
|
|
679 |
///
|
|
680 |
/// The returned value will always be in the range `1..=53`.
|
|
681 |
///
|
|
682 |
- /// ```rust
|
|
683 |
+ /// ```ignore
|
|
684 |
/// # use time::macros::datetime;
|
|
685 |
/// assert_eq!(datetime!(2019-01-01 0:00).iso_week(), 1);
|
|
686 |
/// assert_eq!(datetime!(2019-10-04 0:00).iso_week(), 40);
|
|
687 |
@@ -128,7 +128,7 @@ impl PrimitiveDateTime {
|
|
688 |
///
|
|
689 |
/// The returned value will always be in the range `0..=53`.
|
|
690 |
///
|
|
691 |
- /// ```rust
|
|
692 |
+ /// ```ignore
|
|
693 |
/// # use time::macros::datetime;
|
|
694 |
/// assert_eq!(datetime!(2019-01-01 0:00).sunday_based_week(), 0);
|
|
695 |
/// assert_eq!(datetime!(2020-01-01 0:00).sunday_based_week(), 0);
|
|
696 |
@@ -143,7 +143,7 @@ impl PrimitiveDateTime {
|
|
697 |
///
|
|
698 |
/// The returned value will always be in the range `0..=53`.
|
|
699 |
///
|
|
700 |
- /// ```rust
|
|
701 |
+ /// ```ignore
|
|
702 |
/// # use time::macros::datetime;
|
|
703 |
/// assert_eq!(datetime!(2019-01-01 0:00).monday_based_week(), 0);
|
|
704 |
/// assert_eq!(datetime!(2020-01-01 0:00).monday_based_week(), 0);
|
|
705 |
@@ -156,7 +156,7 @@ impl PrimitiveDateTime {
|
|
706 |
|
|
707 |
/// Get the year, month, and day.
|
|
708 |
///
|
|
709 |
- /// ```rust
|
|
710 |
+ /// ```ignore
|
|
711 |
/// # use time::{macros::datetime, Month};
|
|
712 |
/// assert_eq!(
|
|
713 |
/// datetime!(2019-01-01 0:00).to_calendar_date(),
|
|
714 |
@@ -169,7 +169,7 @@ impl PrimitiveDateTime {
|
|
715 |
|
|
716 |
/// Get the year and ordinal day number.
|
|
717 |
///
|
|
718 |
- /// ```rust
|
|
719 |
+ /// ```ignore
|
|
720 |
/// # use time::macros::datetime;
|
|
721 |
/// assert_eq!(datetime!(2019-01-01 0:00).to_ordinal_date(), (2019, 1));
|
|
722 |
/// ```
|
|
723 |
@@ -179,7 +179,7 @@ impl PrimitiveDateTime {
|
|
724 |
|
|
725 |
/// Get the ISO 8601 year, week number, and weekday.
|
|
726 |
///
|
|
727 |
- /// ```rust
|
|
728 |
+ /// ```ignore
|
|
729 |
/// # use time::{Weekday::*, macros::datetime};
|
|
730 |
/// assert_eq!(
|
|
731 |
/// datetime!(2019-01-01 0:00).to_iso_week_date(),
|
|
732 |
@@ -208,7 +208,7 @@ impl PrimitiveDateTime {
|
|
733 |
|
|
734 |
/// Get the weekday.
|
|
735 |
///
|
|
736 |
- /// ```rust
|
|
737 |
+ /// ```ignore
|
|
738 |
/// # use time::{Weekday::*, macros::datetime};
|
|
739 |
/// assert_eq!(datetime!(2019-01-01 0:00).weekday(), Tuesday);
|
|
740 |
/// assert_eq!(datetime!(2019-02-01 0:00).weekday(), Friday);
|
|
741 |
@@ -232,7 +232,7 @@ impl PrimitiveDateTime {
|
|
742 |
/// The algorithm to perform this conversion is derived from one provided by Peter Baum; it is
|
|
743 |
/// freely available [here](https://www.researchgate.net/publication/316558298_Date_Algorithms).
|
|
744 |
///
|
|
745 |
- /// ```rust
|
|
746 |
+ /// ```ignore
|
|
747 |
/// # use time::macros::datetime;
|
|
748 |
/// assert_eq!(datetime!(-4713-11-24 0:00).to_julian_day(), 0);
|
|
749 |
/// assert_eq!(datetime!(2000-01-01 0:00).to_julian_day(), 2_451_545);
|
|
750 |
@@ -247,7 +247,7 @@ impl PrimitiveDateTime {
|
|
751 |
// region: time getters
|
|
752 |
/// Get the clock hour, minute, and second.
|
|
753 |
///
|
|
754 |
- /// ```rust
|
|
755 |
+ /// ```ignore
|
|
756 |
/// # use time::macros::datetime;
|
|
757 |
/// assert_eq!(datetime!(2020-01-01 0:00:00).as_hms(), (0, 0, 0));
|
|
758 |
/// assert_eq!(datetime!(2020-01-01 23:59:59).as_hms(), (23, 59, 59));
|
|
759 |
@@ -258,7 +258,7 @@ impl PrimitiveDateTime {
|
|
760 |
|
|
761 |
/// Get the clock hour, minute, second, and millisecond.
|
|
762 |
///
|
|
763 |
- /// ```rust
|
|
764 |
+ /// ```ignore
|
|
765 |
/// # use time::macros::datetime;
|
|
766 |
/// assert_eq!(datetime!(2020-01-01 0:00:00).as_hms_milli(), (0, 0, 0, 0));
|
|
767 |
/// assert_eq!(
|
|
768 |
@@ -272,7 +272,7 @@ impl PrimitiveDateTime {
|
|
769 |
|
|
770 |
/// Get the clock hour, minute, second, and microsecond.
|
|
771 |
///
|
|
772 |
- /// ```rust
|
|
773 |
+ /// ```ignore
|
|
774 |
/// # use time::macros::datetime;
|
|
775 |
/// assert_eq!(datetime!(2020-01-01 0:00:00).as_hms_micro(), (0, 0, 0, 0));
|
|
776 |
/// assert_eq!(
|
|
777 |
@@ -286,7 +286,7 @@ impl PrimitiveDateTime {
|
|
778 |
|
|
779 |
/// Get the clock hour, minute, second, and nanosecond.
|
|
780 |
///
|
|
781 |
- /// ```rust
|
|
782 |
+ /// ```ignore
|
|
783 |
/// # use time::macros::datetime;
|
|
784 |
/// assert_eq!(datetime!(2020-01-01 0:00:00).as_hms_nano(), (0, 0, 0, 0));
|
|
785 |
/// assert_eq!(
|
|
786 |
@@ -302,7 +302,7 @@ impl PrimitiveDateTime {
|
|
787 |
///
|
|
788 |
/// The returned value will always be in the range `0..24`.
|
|
789 |
///
|
|
790 |
- /// ```rust
|
|
791 |
+ /// ```ignore
|
|
792 |
/// # use time::macros::datetime;
|
|
793 |
/// assert_eq!(datetime!(2019-01-01 0:00).hour(), 0);
|
|
794 |
/// assert_eq!(datetime!(2019-01-01 23:59:59).hour(), 23);
|
|
795 |
@@ -315,7 +315,7 @@ impl PrimitiveDateTime {
|
|
796 |
///
|
|
797 |
/// The returned value will always be in the range `0..60`.
|
|
798 |
///
|
|
799 |
- /// ```rust
|
|
800 |
+ /// ```ignore
|
|
801 |
/// # use time::macros::datetime;
|
|
802 |
/// assert_eq!(datetime!(2019-01-01 0:00).minute(), 0);
|
|
803 |
/// assert_eq!(datetime!(2019-01-01 23:59:59).minute(), 59);
|
|
804 |
@@ -328,7 +328,7 @@ impl PrimitiveDateTime {
|
|
805 |
///
|
|
806 |
/// The returned value will always be in the range `0..60`.
|
|
807 |
///
|
|
808 |
- /// ```rust
|
|
809 |
+ /// ```ignore
|
|
810 |
/// # use time::macros::datetime;
|
|
811 |
/// assert_eq!(datetime!(2019-01-01 0:00).second(), 0);
|
|
812 |
/// assert_eq!(datetime!(2019-01-01 23:59:59).second(), 59);
|
|
813 |
@@ -341,7 +341,7 @@ impl PrimitiveDateTime {
|
|
814 |
///
|
|
815 |
/// The returned value will always be in the range `0..1_000`.
|
|
816 |
///
|
|
817 |
- /// ```rust
|
|
818 |
+ /// ```ignore
|
|
819 |
/// # use time::macros::datetime;
|
|
820 |
/// assert_eq!(datetime!(2019-01-01 0:00).millisecond(), 0);
|
|
821 |
/// assert_eq!(datetime!(2019-01-01 23:59:59.999).millisecond(), 999);
|
|
822 |
@@ -354,7 +354,7 @@ impl PrimitiveDateTime {
|
|
823 |
///
|
|
824 |
/// The returned value will always be in the range `0..1_000_000`.
|
|
825 |
///
|
|
826 |
- /// ```rust
|
|
827 |
+ /// ```ignore
|
|
828 |
/// # use time::macros::datetime;
|
|
829 |
/// assert_eq!(datetime!(2019-01-01 0:00).microsecond(), 0);
|
|
830 |
/// assert_eq!(
|
|
831 |
@@ -370,7 +370,7 @@ impl PrimitiveDateTime {
|
|
832 |
///
|
|
833 |
/// The returned value will always be in the range `0..1_000_000_000`.
|
|
834 |
///
|
|
835 |
- /// ```rust
|
|
836 |
+ /// ```ignore
|
|
837 |
/// # use time::macros::datetime;
|
|
838 |
/// assert_eq!(datetime!(2019-01-01 0:00).nanosecond(), 0);
|
|
839 |
/// assert_eq!(
|
|
840 |
@@ -387,7 +387,7 @@ impl PrimitiveDateTime {
|
|
841 |
/// Assuming that the existing `PrimitiveDateTime` represents a moment in the provided
|
|
842 |
/// [`UtcOffset`], return an [`OffsetDateTime`].
|
|
843 |
///
|
|
844 |
- /// ```rust
|
|
845 |
+ /// ```ignore
|
|
846 |
/// # use time::macros::{datetime, offset};
|
|
847 |
/// assert_eq!(
|
|
848 |
/// datetime!(2019-01-01 0:00)
|
|
849 |
@@ -412,7 +412,7 @@ impl PrimitiveDateTime {
|
|
850 |
/// Assuming that the existing `PrimitiveDateTime` represents a moment in UTC, return an
|
|
851 |
/// [`OffsetDateTime`].
|
|
852 |
///
|
|
853 |
- /// ```rust
|
|
854 |
+ /// ```ignore
|
|
855 |
/// # use time::macros::datetime;
|
|
856 |
/// assert_eq!(
|
|
857 |
/// datetime!(2019-01-01 0:00).assume_utc().unix_timestamp(),
|
|
858 |
@@ -430,7 +430,7 @@ impl PrimitiveDateTime {
|
|
859 |
// region: checked arithmetic
|
|
860 |
/// Computes `self + duration`, returning `None` if an overflow occurred.
|
|
861 |
///
|
|
862 |
- /// ```
|
|
863 |
+ /// ```ignore
|
|
864 |
/// # use time::{Date, ext::NumericalDuration};
|
|
865 |
/// # use time::macros::datetime;
|
|
866 |
/// let datetime = Date::MIN.midnight();
|
|
867 |
@@ -460,7 +460,7 @@ impl PrimitiveDateTime {
|
|
868 |
|
|
869 |
/// Computes `self - duration`, returning `None` if an overflow occurred.
|
|
870 |
///
|
|
871 |
- /// ```
|
|
872 |
+ /// ```ignore
|
|
873 |
/// # use time::{Date, ext::NumericalDuration};
|
|
874 |
/// # use time::macros::datetime;
|
|
875 |
/// let datetime = Date::MIN.midnight();
|
|
876 |
@@ -495,7 +495,7 @@ impl PrimitiveDateTime {
|
|
877 |
impl PrimitiveDateTime {
|
|
878 |
/// Replace the time, preserving the date.
|
|
879 |
///
|
|
880 |
- /// ```rust
|
|
881 |
+ /// ```ignore
|
|
882 |
/// # use time::macros::{datetime, time};
|
|
883 |
/// assert_eq!(
|
|
884 |
/// datetime!(2020-01-01 17:00).replace_time(time!(5:00)),
|
|
885 |
@@ -509,7 +509,7 @@ impl PrimitiveDateTime {
|
|
886 |
|
|
887 |
/// Replace the date, preserving the time.
|
|
888 |
///
|
|
889 |
- /// ```rust
|
|
890 |
+ /// ```ignore
|
|
891 |
/// # use time::macros::{datetime, date};
|
|
892 |
/// assert_eq!(
|
|
893 |
/// datetime!(2020-01-01 12:00).replace_date(date!(2020-01-30)),
|
|
894 |
@@ -578,7 +578,7 @@ impl PrimitiveDateTime {
|
|
895 |
/// Format the `PrimitiveDateTime` using the provided [format
|
|
896 |
/// description](crate::format_description).
|
|
897 |
///
|
|
898 |
- /// ```rust
|
|
899 |
+ /// ```ignore
|
|
900 |
/// # use time::{format_description, macros::datetime};
|
|
901 |
/// let format = format_description::parse("[year]-[month]-[day] [hour]:[minute]:[second]")?;
|
|
902 |
/// assert_eq!(
|
|
903 |
@@ -597,7 +597,7 @@ impl PrimitiveDateTime {
|
|
904 |
/// Parse a `PrimitiveDateTime` from the input using the provided [format
|
|
905 |
/// description](crate::format_description).
|
|
906 |
///
|
|
907 |
- /// ```rust
|
|
908 |
+ /// ```ignore
|
|
909 |
/// # use time::{format_description, macros::datetime, PrimitiveDateTime};
|
|
910 |
/// let format = format_description::parse("[year]-[month]-[day] [hour]:[minute]:[second]")?;
|
|
911 |
/// assert_eq!(
|
|
912 |
Index: time/src/time.rs
|
|
913 |
===================================================================
|
|
914 |
--- time.orig/src/time.rs
|
|
915 |
+++ time/src/time.rs
|
|
916 |
@@ -56,7 +56,7 @@ impl fmt::Debug for Time {
|
|
917 |
impl Time {
|
|
918 |
/// Create a `Time` that is exactly midnight.
|
|
919 |
///
|
|
920 |
- /// ```rust
|
|
921 |
+ /// ```ignore
|
|
922 |
/// # use time::{Time, macros::time};
|
|
923 |
/// assert_eq!(Time::MIDNIGHT, time!(0:00));
|
|
924 |
/// ```
|
|
925 |
@@ -197,7 +197,7 @@ impl Time {
|
|
926 |
// region: getters
|
|
927 |
/// Get the clock hour, minute, and second.
|
|
928 |
///
|
|
929 |
- /// ```rust
|
|
930 |
+ /// ```ignore
|
|
931 |
/// # use time::macros::time;
|
|
932 |
/// assert_eq!(time!(0:00:00).as_hms(), (0, 0, 0));
|
|
933 |
/// assert_eq!(time!(23:59:59).as_hms(), (23, 59, 59));
|
|
934 |
@@ -208,7 +208,7 @@ impl Time {
|
|
935 |
|
|
936 |
/// Get the clock hour, minute, second, and millisecond.
|
|
937 |
///
|
|
938 |
- /// ```rust
|
|
939 |
+ /// ```ignore
|
|
940 |
/// # use time::macros::time;
|
|
941 |
/// assert_eq!(time!(0:00:00).as_hms_milli(), (0, 0, 0, 0));
|
|
942 |
/// assert_eq!(time!(23:59:59.999).as_hms_milli(), (23, 59, 59, 999));
|
|
943 |
@@ -224,7 +224,7 @@ impl Time {
|
|
944 |
|
|
945 |
/// Get the clock hour, minute, second, and microsecond.
|
|
946 |
///
|
|
947 |
- /// ```rust
|
|
948 |
+ /// ```ignore
|
|
949 |
/// # use time::macros::time;
|
|
950 |
/// assert_eq!(time!(0:00:00).as_hms_micro(), (0, 0, 0, 0));
|
|
951 |
/// assert_eq!(
|
|
952 |
@@ -238,7 +238,7 @@ impl Time {
|
|
953 |
|
|
954 |
/// Get the clock hour, minute, second, and nanosecond.
|
|
955 |
///
|
|
956 |
- /// ```rust
|
|
957 |
+ /// ```ignore
|
|
958 |
/// # use time::macros::time;
|
|
959 |
/// assert_eq!(time!(0:00:00).as_hms_nano(), (0, 0, 0, 0));
|
|
960 |
/// assert_eq!(
|
|
961 |
@@ -254,7 +254,7 @@ impl Time {
|
|
962 |
///
|
|
963 |
/// The returned value will always be in the range `0..24`.
|
|
964 |
///
|
|
965 |
- /// ```rust
|
|
966 |
+ /// ```ignore
|
|
967 |
/// # use time::macros::time;
|
|
968 |
/// assert_eq!(time!(0:00:00).hour(), 0);
|
|
969 |
/// assert_eq!(time!(23:59:59).hour(), 23);
|
|
970 |
@@ -267,7 +267,7 @@ impl Time {
|
|
971 |
///
|
|
972 |
/// The returned value will always be in the range `0..60`.
|
|
973 |
///
|
|
974 |
- /// ```rust
|
|
975 |
+ /// ```ignore
|
|
976 |
/// # use time::macros::time;
|
|
977 |
/// assert_eq!(time!(0:00:00).minute(), 0);
|
|
978 |
/// assert_eq!(time!(23:59:59).minute(), 59);
|
|
979 |
@@ -280,7 +280,7 @@ impl Time {
|
|
980 |
///
|
|
981 |
/// The returned value will always be in the range `0..60`.
|
|
982 |
///
|
|
983 |
- /// ```rust
|
|
984 |
+ /// ```ignore
|
|
985 |
/// # use time::macros::time;
|
|
986 |
/// assert_eq!(time!(0:00:00).second(), 0);
|
|
987 |
/// assert_eq!(time!(23:59:59).second(), 59);
|
|
988 |
@@ -293,7 +293,7 @@ impl Time {
|
|
989 |
///
|
|
990 |
/// The returned value will always be in the range `0..1_000`.
|
|
991 |
///
|
|
992 |
- /// ```rust
|
|
993 |
+ /// ```ignore
|
|
994 |
/// # use time::macros::time;
|
|
995 |
/// assert_eq!(time!(0:00).millisecond(), 0);
|
|
996 |
/// assert_eq!(time!(23:59:59.999).millisecond(), 999);
|
|
997 |
@@ -306,7 +306,7 @@ impl Time {
|
|
998 |
///
|
|
999 |
/// The returned value will always be in the range `0..1_000_000`.
|
|
1000 |
///
|
|
1001 |
- /// ```rust
|
|
1002 |
+ /// ```ignore
|
|
1003 |
/// # use time::macros::time;
|
|
1004 |
/// assert_eq!(time!(0:00).microsecond(), 0);
|
|
1005 |
/// assert_eq!(time!(23:59:59.999_999).microsecond(), 999_999);
|
|
1006 |
@@ -319,7 +319,7 @@ impl Time {
|
|
1007 |
///
|
|
1008 |
/// The returned value will always be in the range `0..1_000_000_000`.
|
|
1009 |
///
|
|
1010 |
- /// ```rust
|
|
1011 |
+ /// ```ignore
|
|
1012 |
/// # use time::macros::time;
|
|
1013 |
/// assert_eq!(time!(0:00).nanosecond(), 0);
|
|
1014 |
/// assert_eq!(time!(23:59:59.999_999_999).nanosecond(), 999_999_999);
|
|
1015 |
@@ -454,7 +454,7 @@ impl Time {
|
|
1016 |
|
|
1017 |
/// Format the `Time` using the provided [format description](crate::format_description).
|
|
1018 |
///
|
|
1019 |
- /// ```rust
|
|
1020 |
+ /// ```ignore
|
|
1021 |
/// # use time::{format_description, macros::time};
|
|
1022 |
/// let format = format_description::parse("[hour]:[minute]:[second]")?;
|
|
1023 |
/// assert_eq!(time!(12:00).format(&format)?, "12:00:00");
|
|
1024 |
@@ -473,7 +473,7 @@ impl Time {
|
|
1025 |
/// Parse a `Time` from the input using the provided [format
|
|
1026 |
/// description](crate::format_description).
|
|
1027 |
///
|
|
1028 |
- /// ```rust
|
|
1029 |
+ /// ```ignore
|
|
1030 |
/// # use time::{format_description, macros::time, Time};
|
|
1031 |
/// let format = format_description::parse("[hour]:[minute]:[second]")?;
|
|
1032 |
/// assert_eq!(Time::parse("12:00:00", &format)?, time!(12:00));
|
|
1033 |
@@ -519,7 +519,7 @@ impl Add<Duration> for Time {
|
|
1034 |
|
|
1035 |
/// Add the sub-day time of the [`Duration`] to the `Time`. Wraps on overflow.
|
|
1036 |
///
|
|
1037 |
- /// ```rust
|
|
1038 |
+ /// ```ignore
|
|
1039 |
/// # use time::{ext::NumericalDuration, macros::time};
|
|
1040 |
/// assert_eq!(time!(12:00) + 2.hours(), time!(14:00));
|
|
1041 |
/// assert_eq!(time!(0:00:01) + (-2).seconds(), time!(23:59:59));
|
|
1042 |
@@ -534,7 +534,7 @@ impl Add<StdDuration> for Time {
|
|
1043 |
|
|
1044 |
/// Add the sub-day time of the [`std::time::Duration`] to the `Time`. Wraps on overflow.
|
|
1045 |
///
|
|
1046 |
- /// ```rust
|
|
1047 |
+ /// ```ignore
|
|
1048 |
/// # use time::{ext::NumericalStdDuration, macros::time};
|
|
1049 |
/// assert_eq!(time!(12:00) + 2.std_hours(), time!(14:00));
|
|
1050 |
/// assert_eq!(time!(23:59:59) + 2.std_seconds(), time!(0:00:01));
|
|
1051 |
@@ -551,7 +551,7 @@ impl Sub<Duration> for Time {
|
|
1052 |
|
|
1053 |
/// Subtract the sub-day time of the [`Duration`] from the `Time`. Wraps on overflow.
|
|
1054 |
///
|
|
1055 |
- /// ```rust
|
|
1056 |
+ /// ```ignore
|
|
1057 |
/// # use time::{ext::NumericalDuration, macros::time};
|
|
1058 |
/// assert_eq!(time!(14:00) - 2.hours(), time!(12:00));
|
|
1059 |
/// assert_eq!(time!(23:59:59) - (-2).seconds(), time!(0:00:01));
|
|
1060 |
@@ -566,7 +566,7 @@ impl Sub<StdDuration> for Time {
|
|
1061 |
|
|
1062 |
/// Subtract the sub-day time of the [`std::time::Duration`] from the `Time`. Wraps on overflow.
|
|
1063 |
///
|
|
1064 |
- /// ```rust
|
|
1065 |
+ /// ```ignore
|
|
1066 |
/// # use time::{ext::NumericalStdDuration, macros::time};
|
|
1067 |
/// assert_eq!(time!(14:00) - 2.std_hours(), time!(12:00));
|
|
1068 |
/// assert_eq!(time!(0:00:01) - 2.std_seconds(), time!(23:59:59));
|
|
1069 |
@@ -584,7 +584,7 @@ impl Sub for Time {
|
|
1070 |
/// Subtract two `Time`s, returning the [`Duration`] between. This assumes both `Time`s are in
|
|
1071 |
/// the same calendar day.
|
|
1072 |
///
|
|
1073 |
- /// ```rust
|
|
1074 |
+ /// ```ignore
|
|
1075 |
/// # use time::{ext::NumericalDuration, macros::time};
|
|
1076 |
/// assert_eq!(time!(0:00) - time!(0:00), 0.seconds());
|
|
1077 |
/// assert_eq!(time!(1:00) - time!(0:00), 1.hours());
|
|
1078 |
Index: time/src/utc_offset.rs
|
|
1079 |
===================================================================
|
|
1080 |
--- time.orig/src/utc_offset.rs
|
|
1081 |
+++ time/src/utc_offset.rs
|
|
1082 |
@@ -33,7 +33,7 @@ pub struct UtcOffset {
|
|
1083 |
impl UtcOffset {
|
|
1084 |
/// A `UtcOffset` that is UTC.
|
|
1085 |
///
|
|
1086 |
- /// ```rust
|
|
1087 |
+ /// ```ignore
|
|
1088 |
/// # use time::{UtcOffset, macros::offset};
|
|
1089 |
/// assert_eq!(UtcOffset::UTC, offset!(UTC));
|
|
1090 |
/// ```
|
|
1091 |
@@ -109,7 +109,7 @@ impl UtcOffset {
|
|
1092 |
/// Obtain the UTC offset as its hours, minutes, and seconds. The sign of all three components
|
|
1093 |
/// will always match. A positive value indicates an offset to the east; a negative to the west.
|
|
1094 |
///
|
|
1095 |
- /// ```rust
|
|
1096 |
+ /// ```ignore
|
|
1097 |
/// # use time::macros::offset;
|
|
1098 |
/// assert_eq!(offset!(+1:02:03).as_hms(), (1, 2, 3));
|
|
1099 |
/// assert_eq!(offset!(-1:02:03).as_hms(), (-1, -2, -3));
|
|
1100 |
@@ -121,7 +121,7 @@ impl UtcOffset {
|
|
1101 |
/// Obtain the number of whole hours the offset is from UTC. A positive value indicates an
|
|
1102 |
/// offset to the east; a negative to the west.
|
|
1103 |
///
|
|
1104 |
- /// ```rust
|
|
1105 |
+ /// ```ignore
|
|
1106 |
/// # use time::macros::offset;
|
|
1107 |
/// assert_eq!(offset!(+1:02:03).whole_hours(), 1);
|
|
1108 |
/// assert_eq!(offset!(-1:02:03).whole_hours(), -1);
|
|
1109 |
@@ -133,7 +133,7 @@ impl UtcOffset {
|
|
1110 |
/// Obtain the number of whole minutes the offset is from UTC. A positive value indicates an
|
|
1111 |
/// offset to the east; a negative to the west.
|
|
1112 |
///
|
|
1113 |
- /// ```rust
|
|
1114 |
+ /// ```ignore
|
|
1115 |
/// # use time::macros::offset;
|
|
1116 |
/// assert_eq!(offset!(+1:02:03).whole_minutes(), 62);
|
|
1117 |
/// assert_eq!(offset!(-1:02:03).whole_minutes(), -62);
|
|
1118 |
@@ -145,7 +145,7 @@ impl UtcOffset {
|
|
1119 |
/// Obtain the number of minutes past the hour the offset is from UTC. A positive value
|
|
1120 |
/// indicates an offset to the east; a negative to the west.
|
|
1121 |
///
|
|
1122 |
- /// ```rust
|
|
1123 |
+ /// ```ignore
|
|
1124 |
/// # use time::macros::offset;
|
|
1125 |
/// assert_eq!(offset!(+1:02:03).minutes_past_hour(), 2);
|
|
1126 |
/// assert_eq!(offset!(-1:02:03).minutes_past_hour(), -2);
|
|
1127 |
@@ -157,7 +157,7 @@ impl UtcOffset {
|
|
1128 |
/// Obtain the number of whole seconds the offset is from UTC. A positive value indicates an
|
|
1129 |
/// offset to the east; a negative to the west.
|
|
1130 |
///
|
|
1131 |
- /// ```rust
|
|
1132 |
+ /// ```ignore
|
|
1133 |
/// # use time::macros::offset;
|
|
1134 |
/// assert_eq!(offset!(+1:02:03).whole_seconds(), 3723);
|
|
1135 |
/// assert_eq!(offset!(-1:02:03).whole_seconds(), -3723);
|
|
1136 |
@@ -171,7 +171,7 @@ impl UtcOffset {
|
|
1137 |
/// Obtain the number of seconds past the minute the offset is from UTC. A positive value
|
|
1138 |
/// indicates an offset to the east; a negative to the west.
|
|
1139 |
///
|
|
1140 |
- /// ```rust
|
|
1141 |
+ /// ```ignore
|
|
1142 |
/// # use time::macros::offset;
|
|
1143 |
/// assert_eq!(offset!(+1:02:03).seconds_past_minute(), 3);
|
|
1144 |
/// assert_eq!(offset!(-1:02:03).seconds_past_minute(), -3);
|
|
1145 |
@@ -185,7 +185,7 @@ impl UtcOffset {
|
|
1146 |
/// Check if the offset is exactly UTC.
|
|
1147 |
///
|
|
1148 |
///
|
|
1149 |
- /// ```rust
|
|
1150 |
+ /// ```ignore
|
|
1151 |
/// # use time::macros::offset;
|
|
1152 |
/// assert!(!offset!(+1:02:03).is_utc());
|
|
1153 |
/// assert!(!offset!(-1:02:03).is_utc());
|
|
1154 |
@@ -197,7 +197,7 @@ impl UtcOffset {
|
|
1155 |
|
|
1156 |
/// Check if the offset is positive, or east of UTC.
|
|
1157 |
///
|
|
1158 |
- /// ```rust
|
|
1159 |
+ /// ```ignore
|
|
1160 |
/// # use time::macros::offset;
|
|
1161 |
/// assert!(offset!(+1:02:03).is_positive());
|
|
1162 |
/// assert!(!offset!(-1:02:03).is_positive());
|
|
1163 |
@@ -209,7 +209,7 @@ impl UtcOffset {
|
|
1164 |
|
|
1165 |
/// Check if the offset is negative, or west of UTC.
|
|
1166 |
///
|
|
1167 |
- /// ```rust
|
|
1168 |
+ /// ```ignore
|
|
1169 |
/// # use time::macros::offset;
|
|
1170 |
/// assert!(!offset!(+1:02:03).is_negative());
|
|
1171 |
/// assert!(offset!(-1:02:03).is_negative());
|
|
1172 |
@@ -268,7 +268,7 @@ impl UtcOffset {
|
|
1173 |
|
|
1174 |
/// Format the `UtcOffset` using the provided [format description](crate::format_description).
|
|
1175 |
///
|
|
1176 |
- /// ```rust
|
|
1177 |
+ /// ```ignore
|
|
1178 |
/// # use time::{format_description, macros::offset};
|
|
1179 |
/// let format = format_description::parse("[offset_hour sign:mandatory]:[offset_minute]")?;
|
|
1180 |
/// assert_eq!(offset!(+1).format(&format)?, "+01:00");
|
|
1181 |
@@ -284,7 +284,7 @@ impl UtcOffset {
|
|
1182 |
/// Parse a `UtcOffset` from the input using the provided [format
|
|
1183 |
/// description](crate::format_description).
|
|
1184 |
///
|
|
1185 |
- /// ```rust
|
|
1186 |
+ /// ```ignore
|
|
1187 |
/// # use time::{format_description, macros::offset, UtcOffset};
|
|
1188 |
/// let format = format_description::parse("[offset_hour]:[offset_minute]")?;
|
|
1189 |
/// assert_eq!(UtcOffset::parse("-03:42", &format)?, offset!(-3:42));
|