From: Ian Jackson Date: Thu, 15 Oct 2020 00:49:12 +0000 (+0100) Subject: wip before reorg timezone type X-Git-Tag: otter-0.2.0~640 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=c0fb67b8ca001e450cd206b466d962fd7f831511;p=otter.git wip before reorg timezone type Signed-off-by: Ian Jackson --- 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) } }