Skip to main content

time_str

Macro time_str 

Source
time_str!() { /* proc-macro */ }
Expand description

Returns the compile time as &'static str in hh:mm:ss format.

By default, the returned time is in UTC, call time_str!(local) to return the local time.

ยงExample

Get the UTC time:

const COMPILE_TIME: time::Time = compile_time::time!();

let hour = COMPILE_TIME.hour();
let minute = COMPILE_TIME.minute();
let second = COMPILE_TIME.second();
let time_string = format!("{hour:02}:{minute:02}:{second:02}");

assert_eq!(compile_time::time_str!(), time_string);

Get the time for the local time zone:

const COMPILE_TIME: time::Time = compile_time::time!(local);

let hour = COMPILE_TIME.hour();
let minute = COMPILE_TIME.minute();
let second = COMPILE_TIME.second();
let time_string = format!("{hour:02}:{minute:02}:{second:02}");

assert_eq!(compile_time::time_str!(local), time_string);