timext

Build Status Crate Docs Crate Version Crate Coverage

Also check out other xwde projects here.

The collection of time-rs/time extensions for calendar arithmetics, incomplete formats handling, imprecise time, and other things time crate is not intended for.

```rust use time::{Date, Month::*}; use timext::ext::NumericCalendarDuration;

fn main() { let d0 = Date::fromcalendardate(2023, January, 31); let d1 = Date::fromcalendardate(2023, February, 28); assert_eq!(d0.unwrap() + 1.months(), d1.unwrap());

let d0 = Date::from_calendar_date(2024, February, 29);
let d1 = Date::from_calendar_date(2025, February, 28);
assert_eq!(d0.unwrap() + 1.years(), d1.unwrap());

} ```

Warning : parsing & formatting are not yet implemented.

```rust use time::{Date, Month::*}; use timext::{InComplete, InDate};

fn main() { let d0 = Date::fromcalendardate(2023, January, 28); let d1 = InDate::fromcalendardate(None, None, Some(28)); let d1 = d1.unwrap();

let d1 = d1.replace_year(Some(2023)).unwrap();
let d1 = d1.replace_month(Some(January)).unwrap();
assert_eq!(d0.unwrap(), d1.into_complete().unwrap());

} ```

Links