fix: remove dots from timeago tokens
This commit is contained in:
parent
26fc5a0693
commit
bd0f3adba3
4 changed files with 1638 additions and 1640 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -133,12 +133,13 @@ impl From<ParsedDate> for OffsetDateTime {
|
|||
}
|
||||
}
|
||||
|
||||
fn filter_str(string: &str) -> String {
|
||||
/// Prepare the datestring for parsing: lowercase and filter out unnecessary punctuation
|
||||
fn filter_datestr(string: &str) -> String {
|
||||
string
|
||||
.to_lowercase()
|
||||
.chars()
|
||||
.filter_map(|c| {
|
||||
if c == '\u{200b}' || c.is_ascii_digit() {
|
||||
if matches!(c, '\u{200b}' | '.') || c.is_ascii_digit() {
|
||||
None
|
||||
} else if c == '-' {
|
||||
Some(' ')
|
||||
|
|
@ -197,7 +198,7 @@ fn parse_textual_month(entry: &dictionary::Entry, filtered_str: &str) -> Option<
|
|||
/// Returns [`None`] if the date could not be parsed.
|
||||
pub fn parse_timeago(lang: Language, textual_date: &str) -> Option<TimeAgo> {
|
||||
let entry = dictionary::entry(lang);
|
||||
let filtered_str = filter_str(textual_date);
|
||||
let filtered_str = filter_datestr(textual_date);
|
||||
|
||||
let qu: u8 = util::parse_numeric_prod(textual_date).unwrap_or(1);
|
||||
|
||||
|
|
@ -244,7 +245,7 @@ pub fn parse_timeago_dt_or_warn(
|
|||
pub fn parse_textual_date(lang: Language, textual_date: &str) -> Option<ParsedDate> {
|
||||
let entry = dictionary::entry(lang);
|
||||
let by_char = util::lang_by_char(lang);
|
||||
let filtered_str = filter_str(textual_date);
|
||||
let filtered_str = filter_datestr(textual_date);
|
||||
|
||||
let nums = util::parse_numeric_vec::<u16>(textual_date);
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -57,4 +57,4 @@ for (const [mainLang, entry] of Object.entries(dict)) {
|
|||
}
|
||||
}
|
||||
|
||||
fs.writeFileSync(DICT_PATH, JSON.stringify(dict, null, 2));
|
||||
fs.writeFileSync(DICT_PATH, JSON.stringify(dict, null, 2) + "\n");
|
||||
|
|
|
|||
Reference in a new issue