|
26 | 26 | //! month in 2025:
|
27 | 27 | //!
|
28 | 28 | //! ```rust
|
29 |
| -//! let start = NaiveDate::ymd(2025, 1, 31); |
30 |
| -//! let rule = DateRule<NaiveDate>::monthly(start).with_count(12); |
| 29 | +//! # use chrono::NaiveDate; |
| 30 | +//! # use chronoutil::DateRule; |
| 31 | +//! let start = NaiveDate::from_ymd(2025, 1, 31); |
| 32 | +//! let rule = DateRule::monthly(start).with_count(12); |
31 | 33 | //! // 2025-1-31, 2025-2-28, 2025-3-31, 2025-4-30, ...
|
32 | 34 | //! ```
|
33 | 35 | //!
|
|
72 | 74 | //! _associative_:
|
73 | 75 | //!
|
74 | 76 | //! ```rust
|
75 |
| -//! let d1 = NaiveDate::ymd(2020, 1, 31) + RelativeDuration::months(1) + RelativeDuration::months(1); |
76 |
| -//! let d2 = NaiveDate::ymd(2020, 1, 31) + (RelativeDuration::months(1) + RelativeDuration::months(1)); |
| 77 | +//! # use chrono::NaiveDate; |
| 78 | +//! # use chronoutil::RelativeDuration; |
77 | 79 | //!
|
78 |
| -//! assert_eq!(d1, NaiveDate::ymd(2020, 3, 29)); |
79 |
| -//! assert_eq!(d2, NaiveDate::ymd(2020, 3, 31)); |
| 80 | +//! let d1 = (NaiveDate::from_ymd(2020, 1, 31) + RelativeDuration::months(1)) + RelativeDuration::months(1); |
| 81 | +//! let d2 = NaiveDate::from_ymd(2020, 1, 31) + (RelativeDuration::months(1) + RelativeDuration::months(1)); |
| 82 | +//! |
| 83 | +//! assert_eq!(d1, NaiveDate::from_ymd(2020, 3, 29)); |
| 84 | +//! assert_eq!(d2, NaiveDate::from_ymd(2020, 3, 31)); |
80 | 85 | //! ```
|
81 | 86 | //!
|
82 | 87 | //! If you want a series of shifted dates, we advise using the `DateRule`, which takes
|
|
0 commit comments