diff options
author | Jim Meyering <jim@meyering.net> | 1996-10-13 19:04:51 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1996-10-13 19:04:51 +0000 |
commit | beb67dc95419e7f2a80ef1834139642df48a9672 (patch) | |
tree | 617e4c5c15c31f4f4c699a28dec40ff436ededdf | |
parent | 242f2fa2e1ebe4b3bdb65058035821734ccffbd3 (diff) | |
download | coreutils-beb67dc95419e7f2a80ef1834139642df48a9672.tar.xz |
(print_long_format): Use strftime of localtime
(not ctime) to produce the date/time in long listings.
From Rafal Maszkowski.
-rw-r--r-- | src/ls.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -2014,7 +2014,8 @@ static void print_long_format (const struct fileinfo *f) { char modebuf[20]; - char timebuf[40]; +#define TIMEBUF_SIZE 40 + char timebuf[TIMEBUF_SIZE]; /* 7 fields that may (worst case: 64-bit integral values) require 20 bytes, 1 10-character mode string, @@ -2046,7 +2047,9 @@ print_long_format (const struct fileinfo *f) break; } - strcpy (timebuf, ctime (&when)); + /* Use strftime rather than ctime, because the former can produce + locale-dependent names for the weekday (%a) and month (%b). */ + strftime (timebuf, TIMEBUF_SIZE, "%a %b %d %H:%M:%S %Y", localtime (&when)); if (full_time) timebuf[24] = '\0'; |