summaryrefslogtreecommitdiff
path: root/src/ls.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1996-10-13 19:04:51 +0000
committerJim Meyering <jim@meyering.net>1996-10-13 19:04:51 +0000
commitbeb67dc95419e7f2a80ef1834139642df48a9672 (patch)
tree617e4c5c15c31f4f4c699a28dec40ff436ededdf /src/ls.c
parent242f2fa2e1ebe4b3bdb65058035821734ccffbd3 (diff)
downloadcoreutils-beb67dc95419e7f2a80ef1834139642df48a9672.tar.xz
(print_long_format): Use strftime of localtime
(not ctime) to produce the date/time in long listings. From Rafal Maszkowski.
Diffstat (limited to 'src/ls.c')
-rw-r--r--src/ls.c7
1 files changed, 5 insertions, 2 deletions
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';