refactor!: made timeago module private

This commit is contained in:
ThetaDev 2023-05-06 21:14:51 +02:00
parent 800073df48
commit 2241223c9f
8 changed files with 11 additions and 19 deletions

View file

@ -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

View file

@ -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};

View file

@ -17,8 +17,7 @@ use crate::{
text::{AccessibilityText, Text, TextComponent},
MapResult,
},
timeago,
util::{self, TryRemove},
util::{self, timeago, TryRemove},
};
#[serde_as]

View file

@ -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::{

View file

@ -14,5 +14,4 @@ pub mod error;
pub mod model;
pub mod param;
pub mod report;
pub mod timeago;
pub mod validate;

View file

@ -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

View file

@ -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};

View file

@ -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<TimeUnit>,
}
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<OffsetDate
parse_timeago(lang, textual_date).map(|ta| ta.into())
}
pub(crate) fn parse_timeago_or_warn(
pub fn parse_timeago_or_warn(
lang: Language,
textual_date: &str,
warnings: &mut Vec<String>,
@ -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<String>,
@ -284,7 +279,7 @@ pub fn parse_textual_date_to_dt(lang: Language, textual_date: &str) -> Option<Of
parse_textual_date(lang, textual_date).map(|ta| ta.into())
}
pub(crate) fn parse_textual_date_or_warn(
pub fn parse_textual_date_or_warn(
lang: Language,
textual_date: &str,
warnings: &mut Vec<String>,