diff --git a/codegen/src/gen_dictionary.rs b/codegen/src/gen_dictionary.rs index a2b7b53..e0bc9b1 100644 --- a/codegen/src/gen_dictionary.rs +++ b/codegen/src/gen_dictionary.rs @@ -38,7 +38,7 @@ pub fn generate_dictionary() { use crate::{ model::AlbumType, param::Language, - timeago::{DateCmp, TaToken, TimeUnit}, + util::timeago::{DateCmp, TaToken, TimeUnit}, }; /// The dictionary contains the information required to parse dates and numbers diff --git a/src/client/playlist.rs b/src/client/playlist.rs index c204dca..2130f6a 100644 --- a/src/client/playlist.rs +++ b/src/client/playlist.rs @@ -5,8 +5,7 @@ use time::OffsetDateTime; use crate::{ error::{Error, ExtractionError}, model::{paginator::Paginator, ChannelId, Playlist, PlaylistVideo}, - timeago, - util::{self, TryRemove}, + util::{self, timeago, TryRemove}, }; use super::{response, ClientType, MapResponse, MapResult, QBrowse, QContinuation, RustyPipeQuery}; diff --git a/src/client/response/video_item.rs b/src/client/response/video_item.rs index fcb8ed9..bae54a6 100644 --- a/src/client/response/video_item.rs +++ b/src/client/response/video_item.rs @@ -17,8 +17,7 @@ use crate::{ text::{AccessibilityText, Text, TextComponent}, MapResult, }, - timeago, - util::{self, TryRemove}, + util::{self, timeago, TryRemove}, }; #[serde_as] diff --git a/src/client/video_details.rs b/src/client/video_details.rs index f3fa4e3..0c20594 100644 --- a/src/client/video_details.rs +++ b/src/client/video_details.rs @@ -7,8 +7,7 @@ use crate::{ model::{paginator::Paginator, ChannelTag, Chapter, Comment, VideoDetails, VideoItem}, param::Language, serializer::MapResult, - timeago, - util::{self, TryRemove}, + util::{self, timeago, TryRemove}, }; use super::{ diff --git a/src/lib.rs b/src/lib.rs index 534205b..af8294d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,5 +14,4 @@ pub mod error; pub mod model; pub mod param; pub mod report; -pub mod timeago; pub mod validate; diff --git a/src/util/dictionary.rs b/src/util/dictionary.rs index 56823a0..7d9f3d4 100644 --- a/src/util/dictionary.rs +++ b/src/util/dictionary.rs @@ -3,7 +3,7 @@ use crate::{ model::AlbumType, param::Language, - timeago::{DateCmp, TaToken, TimeUnit}, + util::timeago::{DateCmp, TaToken, TimeUnit}, }; /// The dictionary contains the information required to parse dates and numbers diff --git a/src/util/mod.rs b/src/util/mod.rs index 51624bf..466c3ae 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -2,6 +2,7 @@ mod date; mod protobuf; pub mod dictionary; +pub mod timeago; pub use date::{now_sec, shift_months, shift_years}; pub use protobuf::{string_from_pb, ProtoBuilder}; diff --git a/src/timeago.rs b/src/util/timeago.rs similarity index 98% rename from src/timeago.rs rename to src/util/timeago.rs index a232898..c1118c1 100644 --- a/src/timeago.rs +++ b/src/util/timeago.rs @@ -9,11 +9,6 @@ //! //! This module can parse these dates using an embedded dictionary which //! contains date/time unit tokens for all supported languages. -//! -//! Note that this module is public so it can be tested from outside -//! the crate, which is important for including new languages, too. -//! -//! It is not intended to be used to parse textual dates that are not from YouTube. use std::ops::Mul; @@ -70,12 +65,12 @@ pub enum TimeUnit { /// Value of a parsed TimeAgo token, used in the dictionary #[derive(Debug, Copy, Clone, PartialEq, Eq)] -pub(crate) struct TaToken { +pub struct TaToken { pub n: u8, pub unit: Option, } -pub(crate) enum DateCmp { +pub enum DateCmp { Y, M, D, @@ -202,7 +197,7 @@ pub fn parse_timeago_dt(lang: Language, textual_date: &str) -> Option, @@ -214,7 +209,7 @@ pub(crate) fn parse_timeago_or_warn( res } -pub(crate) fn parse_timeago_dt_or_warn( +pub fn parse_timeago_dt_or_warn( lang: Language, textual_date: &str, warnings: &mut Vec, @@ -284,7 +279,7 @@ pub fn parse_textual_date_to_dt(lang: Language, textual_date: &str) -> Option,