Rearrange imports

This commit is contained in:
Kiana Sheibani 2023-12-02 13:20:19 -05:00
parent 5543f0a6b6
commit d33aa89ff6
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
3 changed files with 4 additions and 9 deletions

View file

@ -1,7 +1,6 @@
use crate::queries::*; use crate::queries::*;
use sqlite::*; use sqlite::*;
use std::fs::{self, OpenOptions}; use std::fs::{self, OpenOptions};
use std::io;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
pub struct DatasetMetadata { pub struct DatasetMetadata {
@ -21,7 +20,7 @@ pub struct DatasetMetadata {
} }
/// Return the path to the datasets file. /// Return the path to the datasets file.
fn datasets_path(config_dir: &Path) -> io::Result<PathBuf> { fn datasets_path(config_dir: &Path) -> std::io::Result<PathBuf> {
let mut path = config_dir.to_owned(); let mut path = config_dir.to_owned();
path.push("startrnr"); path.push("startrnr");

View file

@ -4,7 +4,6 @@
use clap::{Parser, Subcommand}; use clap::{Parser, Subcommand};
use sqlite::*; use sqlite::*;
use std::path::PathBuf; use std::path::PathBuf;
use std::time::SystemTime;
use time_format::strftime_utc; use time_format::strftime_utc;
mod queries; mod queries;
@ -172,10 +171,6 @@ fn dataset_list(connection: &Connection) {
println!("(Global)"); 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 { if metadata.last_sync.0 == 1 {
print!("\x1b[1m\x1b[91mUnsynced\x1b[0m"); print!("\x1b[1m\x1b[91mUnsynced\x1b[0m");
} else { } 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() 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" { if name == "default" {
print!(" - \x1b[33mRun 'startrnr sync' to update!\x1b[0m"); print!(" - \x1b[33mRun 'startrnr sync' to update!\x1b[0m");
} else { } else {

View file

@ -1,7 +1,6 @@
use sqlite::*; use sqlite::*;
use std::io::{self, Write}; use std::io::{self, Write};
use std::process::exit; use std::process::exit;
use std::time::SystemTime;
use crate::database::*; use crate::database::*;
use crate::queries::{PlayerData, PlayerId, Timestamp}; use crate::queries::{PlayerData, PlayerId, Timestamp};
@ -21,6 +20,8 @@ pub fn issue(msg: &str, code: i32) -> ! {
} }
pub fn current_time() -> Timestamp { pub fn current_time() -> Timestamp {
use std::time::SystemTime;
Timestamp( Timestamp(
SystemTime::now() SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH) .duration_since(SystemTime::UNIX_EPOCH)