From e3663eb257702ce569238cbac1ad8a6bfe80117f Mon Sep 17 00:00:00 2001 From: Laurent Arnoud Date: Sat, 20 Aug 2016 20:21:33 +0200 Subject: [PATCH] Use std::time instead of deprecated crate time --- Cargo.toml | 1 - src/lib.rs | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1ea59c3..e2e350d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,6 @@ version = "0.4.4" [dependencies] hyper = "0.9" -time = "0.1" url = "1.1" [dependencies.clippy] diff --git a/src/lib.rs b/src/lib.rs index 1fc6383..cfcd4c4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,7 +34,6 @@ #![cfg_attr(feature="clippy", warn(cyclomatic_complexity))] extern crate url; -extern crate time; extern crate hyper; use std::io::Read; @@ -44,7 +43,7 @@ use url::Url; use hyper::{Client}; use hyper::header::{UserAgent}; use hyper::status::StatusCode; -use std::time::Duration; +use std::time::{Duration, SystemTime, UNIX_EPOCH}; const USER_AGENT: &'static str = "robotparser-rs (https://crates.io/crates/robotparser)"; @@ -214,9 +213,8 @@ impl<'a> RobotFileParser<'a> { /// Sets the time the robots.txt file was last fetched to the /// current time. pub fn modified(&self) { - use time::get_time; - - self.last_checked.set(get_time().sec); + let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs() as i64; + self.last_checked.set(now); } /// Sets the URL referring to a robots.txt file.