Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Abin Simon <[email protected]>
  • Loading branch information
Mario Manno and meain committed Mar 6, 2022
1 parent 0f9d4f5 commit 4df8bd5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/meta/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4df8bd5

Please sign in to comment.