#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

#374 in Date and time

Download history 223/week @ 2023-11-27 79/week @ 2023-12-04 130/week @ 2023-12-11 150/week @ 2023-12-18 41/week @ 2023-12-25 88/week @ 2024-01-01 90/week @ 2024-01-08 216/week @ 2024-01-15 193/week @ 2024-01-22 143/week @ 2024-01-29 122/week @ 2024-02-05 120/week @ 2024-02-12 127/week @ 2024-02-19 202/week @ 2024-02-26 163/week @ 2024-03-04 55/week @ 2024-03-11

553 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