#timezone #local #time

clia-local-offset

Get current local timezone offset simplely

1 unstable release

0.1.0 Oct 22, 2022

#566 in Date and time

Download history 137/week @ 2024-07-20 63/week @ 2024-07-27 98/week @ 2024-08-03 141/week @ 2024-08-10 330/week @ 2024-08-17 180/week @ 2024-08-24 92/week @ 2024-08-31 71/week @ 2024-09-07 88/week @ 2024-09-14 128/week @ 2024-09-21 64/week @ 2024-09-28 33/week @ 2024-10-05 57/week @ 2024-10-12 49/week @ 2024-10-19 44/week @ 2024-10-26 56/week @ 2024-11-02

212 downloads per month
Used in 8 crates (2 directly)

MIT license

4KB
50 lines

clia-local-offset

Get current local timezone offset simplely.

This crate uses tz-rs to obtain local timezone offset, and returns a time-rs UtcOffset.

Usage

use tracing_subscriber::fmt::time::OffsetTime;

// Local offset timezone init, and set time format.
let offset = clia_local_offset::current_local_offset()
    .expect("Can not get local offset!");

let timer = OffsetTime::new(
    offset,
    format_description!(
        "[year]-[month]-[day] [hour]:[minute]:[second].[subsecond digits:3]"
    ),
);

lib.rs:

Get current local timezone offset simplely.

Dependencies

~1MB
~17K SLoC