5 stable releases

new 1.1.1 Jan 11, 2025
1.1.0 Dec 28, 2024
1.0.3 Jul 31, 2024
1.0.2 Oct 7, 2023
1.0.0 Nov 27, 2022

#398 in Database interfaces

Download history 7/week @ 2024-09-24 10/week @ 2024-10-01 2/week @ 2024-12-03 17/week @ 2024-12-10 191/week @ 2024-12-24 4/week @ 2024-12-31 150/week @ 2025-01-07

345 downloads per month

MIT license

24KB
631 lines

sys_datetime

Local system date time

Cargo Feature Flags

  • mysql: Sqlx mysql support

  • postgres: Sqlx postgres support

  • sqlx: Sqlx support

Examples

use sys_datetime::Datetime;

fn main() {
    let dt = Datetime::now();
    let mut dt2 = Datetime::default();
    dt2.add_years(dt.year())
        .add_months(dt.month())
        .add_days(dt.day())
        .add_hours(dt.hour())
        .add_minutes(dt.minute())
        .add_seconds(dt.second());

    assert!(dt == dt2);

    let mut dt = Datetime::default();
    dt.add_years(-1).add_months(1).add_days(31);
    dt.add_days(29);

    assert!(Some(dt) == Datetime::from_str("0001-02-29 00:00:00 BC"));

    // Eastern 8th District Time
    let mut dt = Datetime::now();
    dt.add_hours(8);
}

License

sys-datetime is provided under the MIT license. See LICENSE.

Dependencies

~2–18MB
~194K SLoC