diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-02-16 15:36:25 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-02-16 15:36:25 +0100 |
commit | 8e92df15b512d108901ce1762e917518553a8aaf (patch) | |
tree | 63ff5cf77e045eecc5158b087f314f55cd2926fe /coreutils/ls.c | |
parent | 402afe1cc69ea505c9bf82ffe06e51ffecf694df (diff) | |
download | busybox-w32-8e92df15b512d108901ce1762e917518553a8aaf.tar.gz busybox-w32-8e92df15b512d108901ce1762e917518553a8aaf.tar.bz2 busybox-w32-8e92df15b512d108901ce1762e917518553a8aaf.zip |
ls: fix year 9999 bug :)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils/ls.c')
-rw-r--r-- | coreutils/ls.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c index 1b63be56d..a30422a8c 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -581,12 +581,15 @@ static NOINLINE unsigned display_single(const struct dnode *dn) | |||
581 | } else { /* LIST_DATE_TIME */ | 581 | } else { /* LIST_DATE_TIME */ |
582 | /* G.current_time_t ~== time(NULL) */ | 582 | /* G.current_time_t ~== time(NULL) */ |
583 | time_t age = G.current_time_t - ttime; | 583 | time_t age = G.current_time_t - ttime; |
584 | printf("%.6s ", filetime + 4); /* "Jun 30" */ | ||
585 | if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) { | 584 | if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) { |
586 | /* hh:mm if less than 6 months old */ | 585 | /* less than 6 months old */ |
587 | printf("%.5s ", filetime + 11); | 586 | /* "mmm dd hh:mm " */ |
588 | } else { /* year. buggy if year > 9999 ;) */ | 587 | printf("%.12s ", filetime + 4); |
589 | printf(" %.4s ", filetime + 20); | 588 | } else { |
589 | /* "mmm dd yyyy " */ | ||
590 | /* "mmm dd yyyyy " after year 9999 :) */ | ||
591 | strchr(filetime + 20, '\n')[0] = ' '; | ||
592 | printf("%.7s%6s", filetime + 4, filetime + 20); | ||
590 | } | 593 | } |
591 | column += 13; | 594 | column += 13; |
592 | } | 595 | } |