From beb67dc95419e7f2a80ef1834139642df48a9672 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 13 Oct 1996 19:04:51 +0000 Subject: (print_long_format): Use strftime of localtime (not ctime) to produce the date/time in long listings. From Rafal Maszkowski. --- src/ls.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ls.c b/src/ls.c index 2e082b5c8..bf73b1758 100644 --- a/src/ls.c +++ b/src/ls.c @@ -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'; -- cgit v1.2.3-70-g09d2