refactor: replace chrono with time-rs

This commit is contained in:
ThetaDev 2022-10-18 22:53:09 +02:00
parent b5f6b7a174
commit 3c1cc92461
16 changed files with 195 additions and 112 deletions

View file

@ -1,5 +1,5 @@
use chrono::{DateTime, Utc};
use serde::Deserialize;
use time::OffsetDateTime;
use super::Thumbnail;
@ -9,8 +9,8 @@ pub(crate) struct ChannelRss {
pub channel_id: String,
#[serde(rename = "$unflatten=title")]
pub title: String,
#[serde(rename = "$unflatten=published")]
pub create_date: DateTime<Utc>,
#[serde(rename = "$unflatten=published", with = "time::serde::rfc3339")]
pub create_date: OffsetDateTime,
pub entry: Vec<Entry>,
}
@ -20,10 +20,10 @@ pub(crate) struct Entry {
pub video_id: String,
#[serde(rename = "$unflatten=title")]
pub title: String,
#[serde(rename = "$unflatten=published")]
pub published: DateTime<Utc>,
#[serde(rename = "$unflatten=updated")]
pub updated: DateTime<Utc>,
#[serde(rename = "$unflatten=published", with = "time::serde::rfc3339")]
pub published: OffsetDateTime,
#[serde(rename = "$unflatten=updated", with = "time::serde::rfc3339")]
pub updated: OffsetDateTime,
#[serde(rename = "$unflatten=media:group")]
pub media_group: MediaGroup,
}

View file

@ -1,6 +1,6 @@
use chrono::TimeZone;
use serde::Deserialize;
use serde_with::{json::JsonString, serde_as, DefaultOnError, VecSkipError};
use time::OffsetDateTime;
use super::{ChannelBadge, ContinuationEndpoint, Thumbnails};
use crate::{
@ -342,12 +342,7 @@ impl<T> YouTubeListMapper<T> {
publish_date: video
.upcoming_event_data
.as_ref()
.map(|upc| {
chrono::Local.from_utc_datetime(&chrono::NaiveDateTime::from_timestamp(
upc.start_time,
0,
))
})
.and_then(|upc| OffsetDateTime::from_unix_timestamp(upc.start_time).ok())
.or_else(|| {
video
.published_time_text