#date #timezone #chrono #interval #calculations #dst #component

date_component

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

7 unstable releases

0.4.2 Jan 5, 2025
0.4.1 Sep 28, 2023
0.3.1 Feb 11, 2023
0.3.0 Jul 8, 2022
0.1.2 Feb 19, 2021

#68 in Date and time

Download history 709/week @ 2024-11-02 798/week @ 2024-11-09 791/week @ 2024-11-16 931/week @ 2024-11-23 1589/week @ 2024-11-30 1386/week @ 2024-12-07 974/week @ 2024-12-14 296/week @ 2024-12-21 237/week @ 2024-12-28 934/week @ 2025-01-04 1352/week @ 2025-01-11 913/week @ 2025-01-18 1628/week @ 2025-01-25 1528/week @ 2025-02-01 1143/week @ 2025-02-08 214/week @ 2025-02-15

4,671 downloads per month
Used in starrytoy-rs

MIT license

3.5MB
1.5K SLoC

Contains (WOFF font, 400KB) NanumBarunGothic-0f09457c7a19b7c6.ttf.woff2, (WOFF font, 135KB) FiraSans-Medium-8f9a781e4970d388.woff2, (WOFF font, 130KB) FiraSans-Regular-018c141bf0843ffd.woff2, (WOFF font, 82KB) SourceSerif4-Bold-a2c9cd1067f8b328.ttf.woff2, (WOFF font, 77KB) SourceSerif4-Regular-46f98efaafac5295.ttf.woff2, (WOFF font, 45KB) SourceCodePro-It-1cc31594bf4f1f79.ttf.woff2 and 3 more.

date_component

calculate dates interval between 2 dates with shared timezone with chrono. and the calculation is also considered with DST if necessary.

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