Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/dwarves

crates/dwarves-slsa/tests/time.rs

use dwarves_slsa::time::{compact, rfc3339, rfc3339_secs};

#[test]
fn the_epoch_and_known_instants() {
    assert_eq!(rfc3339_secs(0), "1970-01-01T00:00:00Z");
    assert_eq!(rfc3339_secs(1_700_000_000), "2023-11-14T22:13:20Z");
    assert_eq!(rfc3339_secs(951_782_400), "2000-02-29T00:00:00Z");
    assert_eq!(rfc3339_secs(1_793_232_000), "2026-10-29T00:00:00Z");
    assert_eq!(compact(1_700_000_000), "20231114T221320Z");
}

#[test]
fn system_time_is_written_the_same_way() {
    let t = std::time::UNIX_EPOCH + std::time::Duration::from_secs(1_700_000_000);
    assert_eq!(rfc3339(t), "2023-11-14T22:13:20Z");
}