date_component

Crates.iodate_component
lib.rsdate_component
version0.4.1
sourcesrc
created_at2021-02-19 07:27:30.704815
updated_at2023-09-28 10:10:41.535581
descriptionthe missed date_component with chrono. calculate date interval with chrono.
homepagehttps://github.com/gpgkd906/date_component/
repositoryhttps://github.com/gpgkd906/date_component/
max_upload_size
id357445
size39,453,161
陈瀚 (gpgkd906)

documentation

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

README

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.

Commit count: 45

cargo fmt