#date #calculations #chrono

date-calculations

Adjust dates relative to provided Chrono's NaiveDate

2 releases

0.1.1 Dec 20, 2020
0.1.0 Dec 20, 2020

#440 in Date and time

Download history 246/week @ 2024-12-09 173/week @ 2024-12-16 88/week @ 2024-12-23 49/week @ 2024-12-30 168/week @ 2025-01-06 147/week @ 2025-01-13 209/week @ 2025-01-20 249/week @ 2025-01-27 324/week @ 2025-02-03 301/week @ 2025-02-10 343/week @ 2025-02-17 345/week @ 2025-02-24 377/week @ 2025-03-03 411/week @ 2025-03-10 468/week @ 2025-03-17 404/week @ 2025-03-24

1,667 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