Pass over src/*.rs, webapp/src/**, and the in-app "?" docs prose: condensed multi-paragraph doc comments to single lines that state the non-obvious why, deleted comments that only restated adjacent code, and tightened the Docs.tsx help-panel wording. No logic, structure, or code formatting changed — verified via cargo test (143 passed) and tsc -b && vite build. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XFUNZwCvz3kcod3352ZR2o
26 lines
737 B
Rust
26 lines
737 B
Rust
use serde::Serialize;
|
|
use std::time::{SystemTime, UNIX_EPOCH};
|
|
|
|
/// Wall-clock instant stored as nanoseconds since the Unix epoch (not `std::time::Instant`, which has no epoch and can't be serialized).
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize)]
|
|
pub struct Timestamp(i64);
|
|
|
|
impl Timestamp {
|
|
pub fn now() -> Self {
|
|
let nanos = SystemTime::now()
|
|
.duration_since(UNIX_EPOCH)
|
|
.expect("system clock is before the Unix epoch")
|
|
.as_nanos() as i64;
|
|
Timestamp(nanos)
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub fn from_millis(millis: i64) -> Self {
|
|
Timestamp(millis * 1_000_000)
|
|
}
|
|
|
|
pub fn as_millis(&self) -> i64 {
|
|
self.0 / 1_000_000
|
|
}
|
|
}
|