clia-local-offset

Crates.ioclia-local-offset
lib.rsclia-local-offset
version0.1.0
sourcesrc
created_at2022-10-22 03:30:02.000326
updated_at2022-10-22 03:30:02.000326
descriptionGet current local timezone offset simplely.
homepagehttps://github.com/clia/local-offset
repositoryhttps://github.com/clia/local-offset
max_upload_size
id694065
size5,155
clia (clia)

documentation

README

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]"
    ),
);
Commit count: 5

cargo fmt