summaryrefslogtreecommitdiff
path: root/coreutils/ls.c
diff options
context:
space:
mode:
authorDenys Vlasenko2015-02-16 15:36:25 +0100
committerDenys Vlasenko2015-02-16 15:36:25 +0100
commit8e92df15b512d108901ce1762e917518553a8aaf (patch)
tree63ff5cf77e045eecc5158b087f314f55cd2926fe /coreutils/ls.c
parent402afe1cc69ea505c9bf82ffe06e51ffecf694df (diff)
downloadbusybox-8e92df15b512d108901ce1762e917518553a8aaf.zip
busybox-8e92df15b512d108901ce1762e917518553a8aaf.tar.gz
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.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 1b63be5..a30422a 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -581,12 +581,15 @@ static NOINLINE unsigned display_single(const struct dnode *dn)
} else { /* LIST_DATE_TIME */
/* G.current_time_t ~== time(NULL) */
time_t age = G.current_time_t - ttime;
- printf("%.6s ", filetime + 4); /* "Jun 30" */
if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) {
- /* hh:mm if less than 6 months old */
- printf("%.5s ", filetime + 11);
- } else { /* year. buggy if year > 9999 ;) */
- printf(" %.4s ", filetime + 20);
+ /* less than 6 months old */
+ /* "mmm dd hh:mm " */
+ printf("%.12s ", filetime + 4);
+ } else {
+ /* "mmm dd yyyy " */
+ /* "mmm dd yyyyy " after year 9999 :) */
+ strchr(filetime + 20, '\n')[0] = ' ';
+ printf("%.7s%6s", filetime + 4, filetime + 20);
}
column += 13;
}