From c0fb67b8ca001e450cd206b466d962fd7f831511 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 15 Oct 2020 01:49:12 +0100 Subject: [PATCH] wip before reorg timezone type Signed-off-by: Ian Jackson --- src/gamestate.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/gamestate.rs b/src/gamestate.rs index db536c7c..1572cf62 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -174,7 +174,24 @@ impl Timestamp { } pub fn render(&self, tz: &Timezone) -> String { - format!("TS{}(@{:?})", self.0, tz) + #[derive(Error,Debug)] + enum E { + #[from] SystemTime(SystemTimeError); + #[from] Other(&'static str); + }; + + (||{ + let then = SytemTime::UNIX_EPOCH.checked_add( + Duration::from_secs(tz.0) + ).ok_or("SystemTime wrap error!")?; + let elapsed = then.elapsed()?; + if elapsed > 86400/2 { + + } + let now = SystemTime::now(); + let elapsed = now.duration_since(then); + + None => format!("TS{}(@{:?})", self.0, tz) } } -- 2.30.2