From 163ea15f07e4d6b89c4424e9f00db617efacfe3f Mon Sep 17 00:00:00 2001 From: ice_iix Date: Sun, 27 Dec 2020 14:18:46 -0800 Subject: [PATCH] logo: replace SystemTime/UNIX_EPOCH with Instant Although there's an open pull request to the `instant` crate to support SystemTime and UNIX_EPOCH (https://github.com/sebcrozet/instant/pull/9), it is simpler to change ui/logo to simply use Instant and Duration. --- src/ui/logo.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ui/logo.rs b/src/ui/logo.rs index 257407f6..b33f1ecb 100644 --- a/src/ui/logo.rs +++ b/src/ui/logo.rs @@ -1,10 +1,10 @@ use crate::render; use crate::resources; use crate::ui; +use instant::Instant; use rand::{self, seq::SliceRandom}; use std::f64::consts; use std::sync::{Arc, RwLock}; -use std::time::{SystemTime, UNIX_EPOCH}; // TODO: replace with instant::Instant and Duration? pub struct Logo { _shadow: ui::BatchRef, @@ -15,6 +15,7 @@ pub struct Logo { text_orig_x: f64, text_index: isize, text_strings: Vec, + started: Instant, } impl Logo { @@ -131,11 +132,12 @@ impl Logo { text_orig_x, text_index: -1, text_strings, + started: Instant::now(), } } pub fn tick(&mut self, renderer: &mut render::Renderer) { - let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap(); + let now = Instant::now().duration_since(self.started); // Splash text let text_index = (now.as_secs() / 15) as isize % self.text_strings.len() as isize;