Compare commits
2 Commits
d2d95770a3
...
a55d304b57
Author | SHA1 | Date |
---|---|---|
Anna | a55d304b57 | |
Anna | 61a295d08b |
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "lodestone-parser"
|
name = "lodestone-parser"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
authors = ["Anna <git@anna.lgbt>"]
|
authors = ["Anna <git@anna.lgbt>"]
|
||||||
|
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use scraper::selector::ToCss;
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, Error>;
|
pub type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
|
@ -17,8 +19,7 @@ pub enum Error {
|
||||||
|
|
||||||
impl Error {
|
impl Error {
|
||||||
pub fn missing_element(select: &scraper::Selector) -> Self {
|
pub fn missing_element(select: &scraper::Selector) -> Self {
|
||||||
use cssparser::ToCss;
|
let css = select.to_css_string();
|
||||||
let css = select.selectors.iter().map(ToCss::to_css_string).collect::<Vec<_>>().join(" ");
|
|
||||||
Error::MissingElement(css)
|
Error::MissingElement(css)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,9 @@ fn parse_formed(html: &Html) -> Result<DateTime<Utc>> {
|
||||||
.ok_or_else(|| Error::invalid_content("comma-separated strftime call", Some(&script)))?;
|
.ok_or_else(|| Error::invalid_content("comma-separated strftime call", Some(&script)))?;
|
||||||
let timestamp: i64 = timestamp.parse().map_err(Error::InvalidNumber)?;
|
let timestamp: i64 = timestamp.parse().map_err(Error::InvalidNumber)?;
|
||||||
|
|
||||||
let utc = Local.timestamp(timestamp, 0).with_timezone(&Utc);
|
let utc = Local.timestamp_opt(timestamp, 0)
|
||||||
|
.unwrap()
|
||||||
|
.with_timezone(&Utc);
|
||||||
|
|
||||||
Ok(utc)
|
Ok(utc)
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,9 @@ fn parse_formed(html: ElementRef) -> Result<DateTime<Utc>> {
|
||||||
.ok_or_else(|| Error::invalid_content("comma-separated strftime call", Some(&script)))?;
|
.ok_or_else(|| Error::invalid_content("comma-separated strftime call", Some(&script)))?;
|
||||||
let timestamp: i64 = timestamp.parse().map_err(Error::InvalidNumber)?;
|
let timestamp: i64 = timestamp.parse().map_err(Error::InvalidNumber)?;
|
||||||
|
|
||||||
let utc = Local.timestamp(timestamp, 0).with_timezone(&Utc);
|
let utc = Local.timestamp_opt(timestamp, 0)
|
||||||
|
.unwrap()
|
||||||
|
.with_timezone(&Utc);
|
||||||
|
|
||||||
Ok(utc)
|
Ok(utc)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue