clia-local-time

Crates.ioclia-local-time
lib.rsclia-local-time
version0.2.1
sourcesrc
created_at2021-12-27 01:09:41.135912
updated_at2021-12-27 01:34:56.601354
descriptionA LocalTime implementation to set timezone manually.
homepage
repositoryhttps://github.com/clia/clia-local-time
max_upload_size
id503521
size12,387
clia (clia)

documentation

https://docs.rs/clia-local-time/0.2.1

README

clia-local-time

A LocalTime implementation to set timezone manually.

Tracing-subscriber 3.x switched from chrono crate to time. When using with LocalTime on some platforms it will cause to failure, when auto fetching the timezone from system.

So we build ourselves' LocalTime to fix it. In this patch, you can pass the timezone manually to LocalTime, it default use UTC.

Example

Cargo.toml:

[dependencies]
time = { version = "0.3", features = ["macros"] }
tracing-subscriber = { version = "0.3", features = ["fmt", "std", "time", "local-time"] }
clia-local-time = "0.2"

main.rs:

use time::macros::format_description;
use clia_local_time::LocalTime;

fn main {
    let timer = LocalTime::with_timezone(
        format_description!(
            "[year]-[month]-[day] [hour]:[minute]:[second].[subsecond digits:3]"
        ),
        (8, 0, 0),
    );
    tracing_subscriber::fmt()
        .with_timer(timer)
        .init();
}
Commit count: 6

cargo fmt