File tree Expand file tree Collapse file tree 4 files changed +56
-1
lines changed
Expand file tree Collapse file tree 4 files changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ du-error-invalid-time-style = invalid argument { $style } for 'time style'
5252 - 'full-iso'
5353 - 'long-iso'
5454 - 'iso'
55+ - +FORMAT (e.g., +%H:%M) for a 'date'-style format
5556 Try '{ $help } ' for more information.
5657du-error-invalid-time-arg = 'birth' and 'creation' arguments for --time are not supported on this platform.
5758du-error-invalid-glob = Invalid exclude syntax: { $error }
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ du-error-invalid-time-style = argument invalide { $style } pour 'style de temps'
5252 - 'full-iso'
5353 - 'long-iso'
5454 - 'iso'
55+ - +FORMAT (e.g., +%H:%M) pour un format de type 'date'
5556 Essayez '{ $help } ' pour plus d'informations.
5657du-error-invalid-time-arg = les arguments 'birth' et 'creation' pour --time ne sont pas supportés sur cette plateforme.
5758du-error-invalid-glob = Syntaxe d'exclusion invalide : { $error }
Original file line number Diff line number Diff line change @@ -761,7 +761,10 @@ fn parse_time_style(s: Option<&str>) -> UResult<&str> {
761761 "full-iso" => Ok ( "%Y-%m-%d %H:%M:%S.%f %z" ) ,
762762 "long-iso" => Ok ( "%Y-%m-%d %H:%M" ) ,
763763 "iso" => Ok ( "%Y-%m-%d" ) ,
764- _ => Err ( DuError :: InvalidTimeStyleArg ( s. into ( ) ) . into ( ) ) ,
764+ _ => match s. chars ( ) . next ( ) . unwrap ( ) {
765+ '+' => Ok ( & s[ 1 ..] ) ,
766+ _ => Err ( DuError :: InvalidTimeStyleArg ( s. into ( ) ) . into ( ) ) ,
767+ } ,
765768 } ,
766769 None => Ok ( "%Y-%m-%d %H:%M" ) ,
767770 }
Original file line number Diff line number Diff line change @@ -626,6 +626,56 @@ fn test_du_time() {
626626 . succeeds ( ) ;
627627 result. stdout_only ( "0\t 2016-06-16 00:00\t date_test\n " ) ;
628628
629+ // long-iso (same as default)
630+ let result = ts
631+ . ucmd ( )
632+ . env ( "TZ" , "UTC" )
633+ . arg ( "--time" )
634+ . arg ( "--time-style=long-iso" )
635+ . arg ( "date_test" )
636+ . succeeds ( ) ;
637+ result. stdout_only ( "0\t 2016-06-16 00:00\t date_test\n " ) ;
638+
639+ // full-iso
640+ let result = ts
641+ . ucmd ( )
642+ . env ( "TZ" , "UTC" )
643+ . arg ( "--time" )
644+ . arg ( "--time-style=full-iso" )
645+ . arg ( "date_test" )
646+ . succeeds ( ) ;
647+ result. stdout_only ( "0\t 2016-06-16 00:00:00.000000000 +0000\t date_test\n " ) ;
648+
649+ // iso
650+ let result = ts
651+ . ucmd ( )
652+ . env ( "TZ" , "UTC" )
653+ . arg ( "--time" )
654+ . arg ( "--time-style=iso" )
655+ . arg ( "date_test" )
656+ . succeeds ( ) ;
657+ result. stdout_only ( "0\t 2016-06-16\t date_test\n " ) ;
658+
659+ // custom +FORMAT
660+ let result = ts
661+ . ucmd ( )
662+ . env ( "TZ" , "UTC" )
663+ . arg ( "--time" )
664+ . arg ( "--time-style=+%Y__%H" )
665+ . arg ( "date_test" )
666+ . succeeds ( ) ;
667+ result. stdout_only ( "0\t 2016__00\t date_test\n " ) ;
668+
669+ // ls has special handling for new line in format, du doesn't.
670+ let result = ts
671+ . ucmd ( )
672+ . env ( "TZ" , "UTC" )
673+ . arg ( "--time" )
674+ . arg ( "--time-style=+%Y_\n _%H" )
675+ . arg ( "date_test" )
676+ . succeeds ( ) ;
677+ result. stdout_only ( "0\t 2016_\n _00\t date_test\n " ) ;
678+
629679 for argument in [ "--time=atime" , "--time=atim" , "--time=a" ] {
630680 let result = ts
631681 . ucmd ( )
You can’t perform that action at this time.
0 commit comments