Skip to content

Commit af94854

Browse files
author
oliver
committed
Doctests
1 parent 7e82f80 commit af94854

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ For example, the following will yield one `NaiveDate` on the last day of each
4747
month in 2025:
4848

4949
```rust
50-
let start = NaiveDate::ymd(2025, 1, 31);
50+
let start = NaiveDate::from_ymd(2025, 1, 31);
5151
let rule = DateRule<NaiveDate>::monthly(start).with_count(12);
5252
// 2025-1-31, 2025-2-28, 2025-3-31, 2025-4-30, ...
5353
```
@@ -93,11 +93,11 @@ This leads us to an interesting point about the `RelativeDuration`: addition is
9393
_associative_:
9494

9595
```rust
96-
let d1 = NaiveDate::ymd(2020, 1, 31) + RelativeDuration::months(1) + RelativeDuration::months(1);
97-
let d2 = NaiveDate::ymd(2020, 1, 31) + (RelativeDuration::months(1) + RelativeDuration::months(1));
96+
let d1 = (NaiveDate::from_ymd(2020, 1, 31) + RelativeDuration::months(1)) + RelativeDuration::months(1);
97+
let d2 = NaiveDate::from_ymd(2020, 1, 31) + (RelativeDuration::months(1) + RelativeDuration::months(1));
9898

99-
assert_eq!(d1, NaiveDate::ymd(2020, 3, 29));
100-
assert_eq!(d2, NaiveDate::ymd(2020, 3, 31));
99+
assert_eq!(d1, NaiveDate::from_ymd(2020, 3, 29));
100+
assert_eq!(d2, NaiveDate::from_ymd(2020, 3, 31));
101101
```
102102

103103
If you want a series of shifted dates, we advise using the `DateRule`, which takes

src/lib.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
//! month in 2025:
2727
//!
2828
//! ```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);
3133
//! // 2025-1-31, 2025-2-28, 2025-3-31, 2025-4-30, ...
3234
//! ```
3335
//!
@@ -72,11 +74,14 @@
7274
//! _associative_:
7375
//!
7476
//! ```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;
7779
//!
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));
8085
//! ```
8186
//!
8287
//! If you want a series of shifted dates, we advise using the `DateRule`, which takes

0 commit comments

Comments
 (0)