time_from_systemtime

Macro time_from_systemtime 

Source
macro_rules! time_from_systemtime {
    ($time:expr) => { ... };
}
Expand description

Converts a std::time::SystemTime into a time_t i64 value. (Usually not needed - the systemtime field type does this automatically.)

Usage: let time = time_from_systemtime!(system_time_value);

This macro will convert the provided SystemTime value into a signed 64-bit integer storing the number of seconds since 1970, saturating if the value is out of the range that a 64-bit integer can represent.

The returned i64 value can be used with write_event! via the posix_time64 and posix_time64_slice field types. As an alternative, you can use the systemtime field type, which will automatically convert the provided std::time::SystemTime value into a time_t before writing the event.

Note: time_from_systemtime is implemented as a macro because this crate is [no_std]. Implementing this via a function would require this crate to reference std::time::SystemTimeError.