diff --git a/src/database.rs b/src/database.rs index a629c89..18835f5 100644 --- a/src/database.rs +++ b/src/database.rs @@ -1,7 +1,6 @@ use crate::queries::*; use sqlite::*; use std::fs::{self, OpenOptions}; -use std::io; use std::path::{Path, PathBuf}; pub struct DatasetMetadata { @@ -21,7 +20,7 @@ pub struct DatasetMetadata { } /// Return the path to the datasets file. -fn datasets_path(config_dir: &Path) -> io::Result { +fn datasets_path(config_dir: &Path) -> std::io::Result { let mut path = config_dir.to_owned(); path.push("startrnr"); diff --git a/src/main.rs b/src/main.rs index 85793a5..002118a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,6 @@ use clap::{Parser, Subcommand}; use sqlite::*; use std::path::PathBuf; -use std::time::SystemTime; use time_format::strftime_utc; mod queries; @@ -172,10 +171,6 @@ fn dataset_list(connection: &Connection) { println!("(Global)"); } - let current_time = SystemTime::now() - .duration_since(SystemTime::UNIX_EPOCH) - .unwrap_or_else(|_| error("System time is before the Unix epoch (1970)!", 2)) - .as_secs(); if metadata.last_sync.0 == 1 { print!("\x1b[1m\x1b[91mUnsynced\x1b[0m"); } else { @@ -184,7 +179,7 @@ fn dataset_list(connection: &Connection) { strftime_utc("%b %e, %Y %I:%M %p", metadata.last_sync.0 as i64).unwrap() ); } - if current_time - metadata.last_sync.0 > SECS_IN_WEEK { + if current_time().0 - metadata.last_sync.0 > SECS_IN_WEEK { if name == "default" { print!(" - \x1b[33mRun 'startrnr sync' to update!\x1b[0m"); } else { diff --git a/src/util.rs b/src/util.rs index ceda0f1..f9ede46 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,7 +1,6 @@ use sqlite::*; use std::io::{self, Write}; use std::process::exit; -use std::time::SystemTime; use crate::database::*; use crate::queries::{PlayerData, PlayerId, Timestamp}; @@ -21,6 +20,8 @@ pub fn issue(msg: &str, code: i32) -> ! { } pub fn current_time() -> Timestamp { + use std::time::SystemTime; + Timestamp( SystemTime::now() .duration_since(SystemTime::UNIX_EPOCH)