Crates.io | clia-local-offset |
lib.rs | clia-local-offset |
version | 0.1.0 |
source | src |
created_at | 2022-10-22 03:30:02.000326 |
updated_at | 2022-10-22 03:30:02.000326 |
description | Get current local timezone offset simplely. |
homepage | https://github.com/clia/local-offset |
repository | https://github.com/clia/local-offset |
max_upload_size | |
id | 694065 |
size | 5,155 |
Get current local timezone offset simplely.
This crate uses tz-rs
to obtain local timezone offset, and returns a time-rs
UtcOffset
.
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]"
),
);