Skip to content

Commit 1aa15cf

Browse files
Mario Mannomeain
authored andcommitted
Apply suggestions from code review
Co-authored-by: Abin Simon <[email protected]>
1 parent 0f9d4f5 commit 1aa15cf

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/app.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,10 @@ fn validate_date_argument(arg: String) -> Result<(), String> {
290290
}
291291

292292
pub fn validate_time_format(formatter: &str) -> Result<(), String> {
293-
let str = formatter.to_string();
294-
let vec: Vec<&str> = str.split('\n').collect();
293+
let vec: Vec<&str> = formatter.split('\n').collect();
295294

296295
if vec.len() > 2 {
297-
return Err("invalid format, can only contain one newline separator".to_owned());
296+
return Err("invalid date format, cannot contain more than two entries".to_owned());
298297
}
299298

300299
for s in vec {

src/meta/date.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl Date {
6868
DateFlag::Formatted(format) => {
6969
let vec: Vec<&str> = format.split('\n').collect();
7070

71-
if vec.len() == 1 || *val > Local::now() - Duration::seconds(15_778_476) {
71+
if vec.len() == 1 || *val < Local::now() - Duration::seconds(15_778_476) {
7272
// non-recent or only one format
7373
val.format(vec[0]).to_string()
7474
} else {
@@ -93,7 +93,6 @@ mod test {
9393
use std::io;
9494
use std::path::Path;
9595
use std::process::{Command, ExitStatus};
96-
use std::time;
9796
use std::{env, fs};
9897

9998
#[cfg(unix)]
@@ -337,7 +336,7 @@ mod test {
337336

338337
assert_eq!(
339338
creation_date
340-
.format("%F")
339+
.format("%H:%M")
341340
.to_string()
342341
.with(Color::AnsiValue(40)),
343342
date.render(&colors, &flags)
@@ -365,7 +364,7 @@ mod test {
365364

366365
assert_eq!(
367366
creation_date
368-
.format("%H:%M")
367+
.format("%F")
369368
.to_string()
370369
.with(Color::AnsiValue(36)),
371370
date.render(&colors, &flags)

0 commit comments

Comments
 (0)