modelshelf 0.1.0

A shared local LLM model registry: discover, deduplicate, download, and update models across desktop apps.
Documentation
//! Timestamp helpers. The convention stores all timestamps as RFC 3339
//! strings in UTC.

use time::format_description::well_known::Rfc3339;
use time::OffsetDateTime;

/// The current instant as an RFC 3339 UTC string (second precision).
pub fn now_rfc3339() -> String {
    let now = OffsetDateTime::now_utc()
        .replace_nanosecond(0)
        .expect("zero nanosecond is valid");
    now.format(&Rfc3339)
        .expect("UTC datetime formats as RFC 3339")
}

/// A filesystem-safe compact UTC timestamp, e.g. `20260710T123456Z`,
/// used in quarantine file names and journal operation ids.
pub fn now_compact() -> String {
    let f = time::macros::format_description!("[year][month][day]T[hour][minute][second]Z");
    OffsetDateTime::now_utc()
        .format(&f)
        .expect("UTC datetime formats")
}

#[cfg(test)]
mod tests {
    #[test]
    fn rfc3339_shape() {
        let s = super::now_rfc3339();
        assert!(s.ends_with('Z'), "expected UTC zulu suffix: {s}");
        assert!(s.len() >= 20);
    }

    #[test]
    fn compact_shape() {
        let s = super::now_compact();
        assert_eq!(s.len(), 16, "unexpected: {s}");
        assert!(s.ends_with('Z'));
    }
}