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
2 people authored and manno committed Mar 6, 2022
1 parent 0f9d4f5 commit 1aa15cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 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
7 changes: 3 additions & 4 deletions 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 All @@ -93,7 +93,6 @@ mod test {
use std::io;
use std::path::Path;
use std::process::{Command, ExitStatus};
use std::time;
use std::{env, fs};

#[cfg(unix)]
Expand Down Expand Up @@ -337,7 +336,7 @@ mod test {

assert_eq!(
creation_date
.format("%F")
.format("%H:%M")
.to_string()
.with(Color::AnsiValue(40)),
date.render(&colors, &flags)
Expand Down Expand Up @@ -365,7 +364,7 @@ mod test {

assert_eq!(
creation_date
.format("%H:%M")
.format("%F")
.to_string()
.with(Color::AnsiValue(36)),
date.render(&colors, &flags)
Expand Down

0 comments on commit 1aa15cf

Please sign in to comment.