diff --git a/src/lib.rs b/src/lib.rs
index 41854cc..d1bf66b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,4 +1,4 @@
-use chrono::NaiveDate;
+use chrono::DateTime;
use serde_json::Value;
pub struct Feed {
@@ -50,13 +50,17 @@ impl Feed {
ret.push_str(&format!(
"
{} ({})",
episode.title,
- episode.date.format("%d. %m.")
+ episode.timestamp.format("%d.%m.")
));
ret.push_str(&format!(
"\n",
quick_xml::escape::escape(&episode.media_url)
));
ret.push_str("Journal");
+ ret.push_str(&format!(
+ "{}",
+ episode.timestamp.to_rfc2822()
+ ));
ret.push_str("");
}
@@ -98,7 +102,7 @@ pub struct Broadcast {
pub url: String,
pub media_url: String,
pub title: String,
- pub date: NaiveDate,
+ pub timestamp: DateTime,
}
impl Broadcast {
@@ -121,20 +125,22 @@ impl Broadcast {
return Err(format!("{url} has no title").into());
};
- let Some(date) = data["broadcastDay"].as_number() else {
- return Err(format!("{url} has no broadcastDay").into());
+ let Some(timestamp) = data["start"].as_number() else {
+ return Err(format!("{url} has no start").into());
};
- let Ok(date) = NaiveDate::parse_from_str(&date.to_string(), "%Y%m%d") else {
- return Err(
- format!("broadcastDay in {url} not in a valid format (%Y%m%d): {date}").into(),
- );
+ let Some(timestamp) = DateTime::from_timestamp(timestamp.as_i64().unwrap() / 1000, 0)
+ else {
+ return Err(format!(
+ "broadcastDay in {url} not in a valid format (unix timestamp): {timestamp}"
+ )
+ .into());
};
Ok(Some(Self {
url,
media_url,
title: title.into(),
- date,
+ timestamp,
}))
}
}