viewpoint_core/page/clock/
time_value.rs

1//! Time value types for clock mocking.
2
3/// A time value that can be either a timestamp or an ISO string.
4#[derive(Debug, Clone)]
5pub enum TimeValue {
6    /// Unix timestamp in milliseconds.
7    Timestamp(i64),
8    /// ISO 8601 formatted string.
9    IsoString(String),
10}
11
12impl From<i64> for TimeValue {
13    fn from(ts: i64) -> Self {
14        TimeValue::Timestamp(ts)
15    }
16}
17
18impl From<u64> for TimeValue {
19    fn from(ts: u64) -> Self {
20        TimeValue::Timestamp(ts as i64)
21    }
22}
23
24impl From<&str> for TimeValue {
25    fn from(s: &str) -> Self {
26        TimeValue::IsoString(s.to_string())
27    }
28}
29
30impl From<String> for TimeValue {
31    fn from(s: String) -> Self {
32        TimeValue::IsoString(s)
33    }
34}