datetime_str!() { /* proc-macro */ }Expand description
Returns the compile date and time as &'static str in yyyy-MM-ddThh:mm:ssZ format.
By default, the returned datetime is in UTC, call datetime_str!(local)
to return the local date and time.
ยงExample
Get the UTC date and time:
const COMPILE_DATE_STRING: &str = compile_time::date_str!();
const COMPILE_TIME_STRING: &str = compile_time::time_str!();
let datetime_string = format!("{COMPILE_DATE_STRING}T{COMPILE_TIME_STRING}Z");
assert_eq!(compile_time::datetime_str!(), datetime_string);Get the date and time for the local time zone:
const COMPILE_DATE_STRING: &str = compile_time::date_str!(local);
const COMPILE_TIME_STRING: &str = compile_time::time_str!(local);
let datetime_string = format!("{COMPILE_DATE_STRING}T{COMPILE_TIME_STRING}Z");
assert_eq!(compile_time::datetime_str!(local), datetime_string);