#tracing #local #time #localtime

clia-local-time

A LocalTime implementation to set timezone manually

3 unstable releases

0.2.1 Dec 27, 2021
0.2.0 Dec 27, 2021
0.1.0 Dec 27, 2021

#404 in Date and time

Download history 10/week @ 2023-10-28 7/week @ 2023-11-04 9/week @ 2023-11-11 5/week @ 2023-11-18 17/week @ 2023-11-25 9/week @ 2023-12-02 3/week @ 2023-12-09 7/week @ 2023-12-16 10/week @ 2023-12-23 5/week @ 2023-12-30 4/week @ 2024-01-06 6/week @ 2024-01-13 9/week @ 2024-01-20 26/week @ 2024-01-27 10/week @ 2024-02-03 19/week @ 2024-02-10

64 downloads per month

MIT license

11KB
104 lines

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();
}

lib.rs:

A LocalTime implementation to set timezone manually.

Dependencies

~2MB
~33K SLoC