#date #time

chrono-utilities

Utility functions to manipulate chrono dates

1 unstable release

0.0.0-alpha1 Apr 24, 2020

#91 in #date

Download history 4/week @ 2022-06-11 9/week @ 2022-06-18 8/week @ 2022-06-25 12/week @ 2022-07-02 35/week @ 2022-07-09 14/week @ 2022-07-16 39/week @ 2022-07-23 298/week @ 2022-07-30 59/week @ 2022-08-06 65/week @ 2022-08-13 60/week @ 2022-08-20 53/week @ 2022-08-27 51/week @ 2022-09-03 73/week @ 2022-09-10 66/week @ 2022-09-17 70/week @ 2022-09-24

268 downloads per month

MIT/Apache

25KB
173 lines

Chrono Utils

Provides utility functions to manipulate chrono dates. Only NaiveDate is supported as of now. Support for naive and timezone aware DateTime coming soon.

The crate provides the following:

Transition APIs

Transition a chrono struct into a future or previous date using standardised methods like start_of_pred_iso8601_week() which provides the date on which the previous week starts. Such functions are provided for week, month and year.


Feature Matrix

Feature Status
Transition APIs for NaiveDate
Transition APIs for Aware Dates 𐄂
Transition APIs for NaiveDateTime 𐄂
Transition APIs for Aware DateTime 𐄂

Code Sample

use chrono::NaiveDate;
use chrono_utils::naive::DateTransitions;

let d = NaiveDate::from_ymd(2019, 3, 31);
assert_eq!(d.start_of_succ_year().unwrap(), NaiveDate::from_ymd(2020, 1, 1));

let d1 = NaiveDate::from_ymd(1996, 2, 23);
assert_eq!(d1.last_day_of_month(), 29);

let d2 = NaiveDate::from_ymd(1999, 10, 17);
assert_eq!(d2.start_of_pred_iso8601_week().unwrap(), NaiveDate::from_ymd(1999, 10, 4));

Licence

Dual licensed under Apache 2.0 and MIT. (Same as Rust and chrono.)

Dependencies

~1.5MB
~25K SLoC