#date #chrono #relative #calculations #supporting

date-calculations

Adjust dates relative to provided Chrono's NaiveDate

2 releases

0.1.1 Dec 20, 2020
0.1.0 Dec 20, 2020

#397 in Date and time

Download history 134/week @ 2024-09-02 153/week @ 2024-09-09 168/week @ 2024-09-16 226/week @ 2024-09-23 434/week @ 2024-09-30 230/week @ 2024-10-07 184/week @ 2024-10-14 238/week @ 2024-10-21 191/week @ 2024-10-28 124/week @ 2024-11-04 157/week @ 2024-11-11 239/week @ 2024-11-18 169/week @ 2024-11-25 259/week @ 2024-12-02 246/week @ 2024-12-09 173/week @ 2024-12-16

871 downloads per month

MIT license

14KB
210 lines

Date Calculations

This is a crate supporting relative date calculations for Chrono's NaiveDate, most notably only Gregorian dates.

Usage

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);

License

Copyright 2020 Josh Clayton. See the LICENSE.

Dependencies

~1MB
~18K SLoC