Skip to content

Commit

Permalink
logo: replace SystemTime/UNIX_EPOCH with Instant
Browse files Browse the repository at this point in the history
Although there's an open pull request to the `instant` crate to support
SystemTime and UNIX_EPOCH (sebcrozet/instant#9),
it is simpler to change ui/logo to simply use Instant and Duration.
  • Loading branch information
iceiix committed Dec 27, 2020
1 parent a7e5efc commit 163ea15
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ui/logo.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -15,6 +15,7 @@ pub struct Logo {
text_orig_x: f64,
text_index: isize,
text_strings: Vec<String>,
started: Instant,
}

impl Logo {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 163ea15

Please sign in to comment.