File tree Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -290,11 +290,10 @@ fn validate_date_argument(arg: String) -> Result<(), String> {
290290}
291291
292292pub 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 {
Original file line number Diff line number Diff 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)
You can’t perform that action at this time.
0 commit comments