#date #chrono #calculations #relative #supporting #adjust

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 224/week @ 2024-11-15 210/week @ 2024-11-22 193/week @ 2024-11-29 258/week @ 2024-12-06 211/week @ 2024-12-13 101/week @ 2024-12-20 66/week @ 2024-12-27 108/week @ 2025-01-03 172/week @ 2025-01-10 183/week @ 2025-01-17 276/week @ 2025-01-24 314/week @ 2025-01-31 269/week @ 2025-02-07 327/week @ 2025-02-14 380/week @ 2025-02-21 273/week @ 2025-02-28

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