MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / format_timestamp

Function format_timestamp

crates/openshell-tui/src/lib.rs:2484–2496  ·  view source on GitHub ↗

Format epoch milliseconds as a human-readable UTC timestamp: `YYYY-MM-DD HH:MM`.

(epoch_ms: i64)

Source from the content-addressed store, hash-verified

2482
2483/// Format epoch milliseconds as a human-readable UTC timestamp: `YYYY-MM-DD HH:MM`.
2484fn format_timestamp(epoch_ms: i64) -> String {
2485 if epoch_ms <= 0 {
2486 return String::from("-");
2487 }
2488 let secs = epoch_ms / 1000;
2489 let days = secs / 86400;
2490 let time_of_day = secs % 86400;
2491 let hours = time_of_day / 3600;
2492 let minutes = (time_of_day % 3600) / 60;
2493
2494 let (year, month, day) = days_to_ymd(days);
2495 format!("{year:04}-{month:02}-{day:02} {hours:02}:{minutes:02}")
2496}
2497
2498/// Convert days since Unix epoch (1970-01-01) to (year, month, day).
2499#[allow(clippy::unreadable_literal)]

Callers 1

refresh_sandboxesFunction · 0.70

Calls 1

days_to_ymdFunction · 0.85

Tested by

no test coverage detected