From: John Marino Date: Sun, 22 Nov 2015 19:45:10 +0000 (+0100) Subject: ls(1): New long format for named locales X-Git-Tag: v4.5.0~1 X-Git-Url: https://gitweb.dragonflybsd.org/~tuxillo/dragonfly.git/commitdiff_plain/c0a9d818d37fe13ff33ba651056e33434690a20f ls(1): New long format for named locales The use of the basic version of ISO 8601 was not very popular. After a discussion on IRC, the Long Format of named locales is the following: DD-MMM-YYYY hh:mm DD is day number with leading zeros MMM is abbreviated month *in english* (regardless of locale) YYYY is 4-digit year hh is 24-hour with leading zeros ss is seconds with leading zeros --- diff --git a/bin/ls/ls.1 b/bin/ls/ls.1 index e0d34e2230..c635641a80 100644 --- a/bin/ls/ls.1 +++ b/bin/ls/ls.1 @@ -327,8 +327,8 @@ is displayed for each file: file mode, number of links, owner name, group name, number of bytes in the file, -last modified time in either per POSIX requirements or per -ISO 8601 basic format reduced to hour accuracy, and the pathname. +last modified time in either per POSIX requirements or +using the format DD-MMM-YYYY hh:ss, and the pathname. In addition, for each directory whose contents are displayed, the total number of 512-byte blocks used by the files in the directory is displayed on a line by itself immediately before the information for the files in the diff --git a/bin/ls/print.c b/bin/ls/print.c index 17d1914fcd..06211dbd81 100644 --- a/bin/ls/print.c +++ b/bin/ls/print.c @@ -383,11 +383,15 @@ printtime(time_t ftime) else format = "%b %e %R "; } else { - /* Named locales use ISO 8601 (basic with T): YYYYDDMMThh */ - format = "%Y%m%dT%H "; + /* + * Named locales use format DD-MMM-YYYY hh:mm + * Regardless of locale, English is used for month field + */ + format = "%d-%b-%Y %H:%M "; } - strftime(longstring, sizeof(longstring), format, localtime(&ftime)); + strftime_l(longstring, sizeof(longstring), format, localtime(&ftime), + NULL); fputs(longstring, stdout); }