From 4df8bd5bedeffc9b2d5dec6b017c061a9a877ccb Mon Sep 17 00:00:00 2001 From: Mario Manno Date: Sun, 6 Mar 2022 14:19:30 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Abin Simon --- src/app.rs | 5 ++--- src/meta/date.rs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app.rs b/src/app.rs index 8964dcc78..cb6135c78 100644 --- a/src/app.rs +++ b/src/app.rs @@ -290,11 +290,10 @@ fn validate_date_argument(arg: String) -> Result<(), String> { } pub fn validate_time_format(formatter: &str) -> Result<(), String> { - let str = formatter.to_string(); - let vec: Vec<&str> = str.split('\n').collect(); + let vec: Vec<&str> = formatter.split('\n').collect(); if vec.len() > 2 { - return Err("invalid format, can only contain one newline separator".to_owned()); + return Err("invalid date format, cannot contain more than two entries".to_owned()); } for s in vec { diff --git a/src/meta/date.rs b/src/meta/date.rs index 2f82d32ad..b952c38fe 100644 --- a/src/meta/date.rs +++ b/src/meta/date.rs @@ -68,7 +68,7 @@ impl Date { DateFlag::Formatted(format) => { let vec: Vec<&str> = format.split('\n').collect(); - if vec.len() == 1 || *val > Local::now() - Duration::seconds(15_778_476) { + if vec.len() == 1 || *val < Local::now() - Duration::seconds(15_778_476) { // non-recent or only one format val.format(vec[0]).to_string() } else {