From f51605a92c1f49292b7f3a6b15a2c79d459c3652 Mon Sep 17 00:00:00 2001 From: Jan Lukas Gernert Date: Wed, 20 May 2020 16:33:40 +0200 Subject: [PATCH] naivedatetime -> datetime utc --- Cargo.toml | 2 +- src/article.rs | 4 ++-- src/lib.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index abf9904..c0f1101 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "article_scraper" -version = "1.0.0" +version = "1.1.0" authors = ["Jan Lukas Gernert "] edition = "2018" license = "GPL-3.0-or-later" diff --git a/src/article.rs b/src/article.rs index a6f57c3..5d860fd 100644 --- a/src/article.rs +++ b/src/article.rs @@ -1,5 +1,5 @@ use crate::error::{ScraperError, ScraperErrorKind}; -use chrono::NaiveDateTime; +use chrono::{DateTime, Utc}; use failure::ResultExt; use std; use std::io::Write; @@ -10,7 +10,7 @@ pub struct Article { pub title: Option, pub author: Option, pub url: Url, - pub date: Option, + pub date: Option>, pub html: Option, } diff --git a/src/lib.rs b/src/lib.rs index 86485ae..c16fa49 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,7 @@ use self::error::{ScraperError, ScraperErrorKind}; use crate::article::Article; use crate::config::{ConfigCollection, GrabberConfig}; use crate::images::ImageDownloader; -use chrono::NaiveDateTime; +use chrono::DateTime; use encoding_rs::Encoding; use failure::ResultExt; use libxml::parser::Parser; @@ -677,7 +677,7 @@ impl ArticleScraper { for xpath_date in &config.xpath_date { if let Ok(date_string) = ArticleScraper::extract_value(&context, xpath_date) { debug!("Article date: '{}'", date_string); - if let Ok(date) = NaiveDateTime::from_str(&date_string) { + if let Ok(date) = DateTime::from_str(&date_string) { article.date = Some(date); break; } else {