Skip to main content

now_utc_string

Function now_utc_string 

Source
pub fn now_utc_string() -> String
Expand description

Return the current UTC instant formatted as an RFC 3339 string with millisecond precision (YYYY-MM-DDTHH:MM:SS.mmmZ).

Uses std::time::SystemTime so no external dependency is needed.

Pre-epoch handling: if duration_since(UNIX_EPOCH) fails (system clock drifted before the epoch), this function uses the absolute duration from UNIX_EPOCH.duration_since(now) but negates the seconds — producing a timestamp in the range 1969-12-31T… through 1970-01-01T00:00:00Z. This is still monotonically increasing for subsequent calls and never silently produces 1970-01-01T00:00:00.000Z for a clock that is merely slightly behind.