Skip to main content

format_rfc3339

Function format_rfc3339 

Source
pub fn format_rfc3339(time: SystemTime) -> String
Expand description

time as RFC 3339 in UTC, to the second (2024-02-29T12:34:56Z).

A time before the Unix epoch is formatted as the epoch.

use std::time::{Duration, UNIX_EPOCH};
use gemini_adk_rs::utils::time::format_rfc3339;

assert_eq!(format_rfc3339(UNIX_EPOCH), "1970-01-01T00:00:00Z");
assert_eq!(
    format_rfc3339(UNIX_EPOCH + Duration::from_secs(1_709_210_096)),
    "2024-02-29T12:34:56Z"
);