#date-time #timezone #chrono #interval #calculations #component #calculate

date_component

the missed date_component with chrono. calculate date interval with chrono.

6 releases (3 breaking)

0.4.1 Sep 28, 2023
0.4.0 Sep 25, 2023
0.3.1 Feb 11, 2023
0.3.0 Jul 8, 2022
0.1.2 Feb 19, 2021

#100 in Date and time

Download history 15/week @ 2023-12-15 7/week @ 2023-12-22 13/week @ 2023-12-29 6/week @ 2024-01-05 3/week @ 2024-01-12 13/week @ 2024-01-26 2/week @ 2024-02-02 7/week @ 2024-02-09 41/week @ 2024-02-16 97/week @ 2024-02-23 52/week @ 2024-03-01 80/week @ 2024-03-08 76/week @ 2024-03-15 80/week @ 2024-03-22 83/week @ 2024-03-29

328 downloads per month
Used in starrytoy-rs

MIT license

3.5MB
1K SLoC

date_component

calculate dates interval between 2 dates with shared timezone with chrono. and the calculation is considered with Daylight Saving Time.

API

https://gpgkd906.github.io/date_component/date_component/

Example

use chrono::prelude::*;
use date_component::date_component;

fn main() {
    let date1 = Utc.ymd(2015, 4, 20).and_hms(0, 0, 0);
    let date2 =  Utc.ymd(2015, 12, 19).and_hms(0, 0, 0);
    
    let date_interval = date_component::calculate(&date1, &date2);
    println!("{:?}", date_interval);
}
// DateComponent { year: 0, month: 7, week: 4, modulo_days: 1, day: 29, hour: 0, minute: 0, second: 0, interval_seconds: 20995200, interval_minutes: 349920, interval_hours: 5832, interval_days: 243, invert: false }

Tests

Run tests with cargo test. see src/lib.rs.

Dependencies