tempotime 0.1.3

Luxon.js in Rust — immutable, chainable, IANA timezone-aware dates
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#![cfg(not(feature = "chrono"))]

use tempotime::{DateTime, Duration};

#[test]
fn test_jan31_plus_one_month() {
    let dt = DateTime::from_iso("2025-01-31T00:00:00Z").unwrap();
    let result = dt.plus(&Duration::from_object(&[("months", 1)]));
    assert_eq!(result.to_format("yyyy-MM-dd"), "2025-02-28");
}

#[test]
fn test_feb28_leap_year_plus_one_day() {
    let dt = DateTime::from_iso("2024-02-28T00:00:00Z").unwrap();
    let result = dt.plus(&Duration::from_object(&[("days", 1)]));
    assert_eq!(result.to_format("yyyy-MM-dd"), "2024-02-29");
}