refactor!: made timeago module private
This commit is contained in:
parent
800073df48
commit
2241223c9f
8 changed files with 11 additions and 19 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@ use crate::{
|
|||
text::{AccessibilityText, Text, TextComponent},
|
||||
MapResult,
|
||||
},
|
||||
timeago,
|
||||
util::{self, TryRemove},
|
||||
util::{self, timeago, TryRemove},
|
||||
};
|
||||
|
||||
#[serde_as]
|
||||
|
|
|
|||
|
|
@ -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::{
|
||||
|
|
|
|||
|
|
@ -14,5 +14,4 @@ pub mod error;
|
|||
pub mod model;
|
||||
pub mod param;
|
||||
pub mod report;
|
||||
pub mod timeago;
|
||||
pub mod validate;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
|
|
|
|||
|
|
@ -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>,
|
||||
Reference in a new issue