| Crates.io | date-calculations |
| lib.rs | date-calculations |
| version | 0.1.1 |
| created_at | 2020-12-20 14:49:46.509303+00 |
| updated_at | 2020-12-20 14:55:34.667436+00 |
| description | Adjust dates relative to provided Chrono's NaiveDate |
| homepage | |
| repository | https://github.com/joshuaclayton/date-calculations |
| max_upload_size | |
| id | 324912 |
| size | 14,319 |
This is a crate supporting relative date calculations for Chrono's NaiveDate, most notably only Gregorian dates.
use chrono::prelude::*;
use date_calculations::*;
let twenty_twenty_one = NaiveDate::from_ymd_opt(2021, 1, 31).unwrap();
assert_eq!(next_year(&twenty_twenty_one).unwrap().year(), 2022);
assert_eq!(next_year(&twenty_twenty_one).unwrap().month(), 1);
assert_eq!(next_year(&twenty_twenty_one).unwrap().day(), 1);
assert_eq!(previous_quarter(&twenty_twenty_one).unwrap().year(), 2020);
assert_eq!(previous_quarter(&twenty_twenty_one).unwrap().month(), 10);
assert_eq!(previous_quarter(&twenty_twenty_one).unwrap().day(), 1);
Copyright 2020 Josh Clayton. See the LICENSE.