ic-query 0.2.14

Internet Computer query CLI for NNS, SNS, and related public network metadata
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Module: sns::report::neurons_cache::attempt::timestamp
//!
//! Responsibility: format refresh-attempt update timestamps.
//! Does not own: attempt persistence, cache refresh, or report rendering.
//! Boundary: supplies deterministic fallback behavior for attempt timestamp text.

use crate::subnet_catalog::format_utc_timestamp_secs;
use std::time::{SystemTime, UNIX_EPOCH};

pub(in crate::sns::report::neurons_cache::attempt) fn current_timestamp_text(
    fallback: &str,
) -> String {
    SystemTime::now().duration_since(UNIX_EPOCH).map_or_else(
        |_| fallback.to_string(),
        |duration| format_utc_timestamp_secs(duration.as_secs()),
    )
}