[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Locale and ISO8601 date-format in ls (patches)
From: |
Stian Soiland |
Subject: |
Locale and ISO8601 date-format in ls (patches) |
Date: |
Tue, 16 Jan 2001 16:17:43 +0100 |
User-agent: |
Mutt/1.3.12i |
Here's a patch to make ls print dates in international format as well
as in international language (already supported).
diff -ruN fileutils-4.0.36.orig/src/ls.c fileutils-4.0.36/src/ls.c
--- fileutils-4.0.36.orig/src/ls.c Sun Jan 7 11:57:14 2001
+++ fileutils-4.0.36/src/ls.c Tue Jan 16 14:09:21 2001
@@ -1367,7 +1367,7 @@
{
if (full_time)
long_time_format[0] = long_time_format[1] =
- dcgettext (NULL, "%a %b %d %H:%M:%S %Y", LC_TIME);
+ dcgettext (NULL, "%x %X", LC_TIME);
else
{
long_time_format[0] = dcgettext (NULL, "%b %e %Y", LC_TIME);
This yields this output:
address@hidden:~$ export LC_TIME=no_NO
address@hidden:~$ ./ls -al --full-time | head
total 4952
drwxr-xr-x 135 stain users 12288 16-01-2001 14:24:42 .
drwxrwsr-x 32 root staff 4096 09-11-2000 08:29:37 ..
address@hidden:~$ export LC_TIME=C
address@hidden:~$ ./ls -al --full-time | head
total 4952
drwxr-xr-x 135 stain users 12288 01/16/01 14:24:42 .
drwxrwsr-x 32 root staff 4096 11/09/00 08:29:37 ..
address@hidden:~$ export LC_TIME=en_GB
You have new mail in /var/spool/mail/stain
address@hidden:~$ ./ls -al --full-time | head
total 4952
drwxr-xr-x 135 stain users 12288 01/16/01 14:24:42 .
drwxrwsr-x 32 root staff 4096 11/09/00 08:29:37 ..
address@hidden:~$ export LC_TIME=en_GB
address@hidden:~$ ./ls -al --full-time | head
total 3096
drwxr-xr-x 67 stain stain 8192 16/01/01 14:28:25 .
drwxr-xr-x 24 root root 4096 15/01/01 09:21:41 ..
and with my weird locale no_STAIN, which sets ISO-8601 date format:
address@hidden:~$ ./ls -al --full-time | head
total 4952
drwxr-xr-x 135 stain users 12288 2001-01-16 14:24:42 .
drwxrwsr-x 32 root staff 4096 2000-11-09 08:29:37 ..
(this is the nicest one :=)
NOTE: This breaks the old output. This was locale-dependent, ie.
søn okt 08 23:36:18 2000 with no_NO or Sun Oct 08 23:36:18 2000 with C.
Should this be done in some other way? Should we use international
format in the normal short-date option as well? Or disguise it with a
--use-locale ?
Should I use d_fmt or d_t_fmt instead?
Here's another patch for using ISO 8601-format directly from the
command options:
diff -ruN fileutils-4.0.36.orig/src/ls.c fileutils-4.0.36/src/ls.c
--- fileutils-4.0.36.orig/src/ls.c Sun Jan 7 11:57:14 2001
+++ fileutils-4.0.36/src/ls.c Tue Jan 16 15:40:57 2001
@@ -436,6 +436,11 @@
static int full_time;
+/* print the full time in ISO 8601 format instead. */
+
+static int iso_8601;
+
+
/* The file characteristic to sort by. Controlled by -t, -S, -U, -X, -v. */
enum sort_type
@@ -687,6 +692,7 @@
{"full-time", no_argument, &full_time, 1},
{"human-readable", no_argument, 0, 'h'},
{"inode", no_argument, 0, 'i'},
+ {"iso-8601", no_argument, &iso_8601, 1},
{"kilobytes", no_argument, 0, 'k'},
{"numeric-uid-gid", no_argument, 0, 'n'},
{"no-group", no_argument, 0, 'G'},
@@ -1021,6 +1027,7 @@
time_type = time_mtime;
full_time = 0;
+ iso_8601 = 0;
sort_type = sort_name;
sort_reverse = 0;
numeric_ids = 0;
@@ -1368,6 +1375,9 @@
if (full_time)
long_time_format[0] = long_time_format[1] =
dcgettext (NULL, "%a %b %d %H:%M:%S %Y", LC_TIME);
+ else if (iso_8601)
+ long_time_format[0] = long_time_format[1] =
+ dcgettext (NULL, "%Y-%m-%d %H:%M:%S", LC_TIME);
else
{
long_time_format[0] = dcgettext (NULL, "%b %e %Y", LC_TIME);
@@ -3275,6 +3285,7 @@
none (default), classify (-F), file-type (-p)\n\
-i, --inode print index number of each file\n\
-I, --ignore=PATTERN do not list implied entries matching shell
PATTERN\n\
+ --iso-8601 use full ISO-8601 date format\n\
-k, --kilobytes like --block-size=1024\n\
-l use a long listing format\n\
-L, --dereference list entries pointed to by symbolic links\n\
@@ -3291,10 +3302,10 @@
--quoting-style=WORD use quoting style WORD for entry names:\n\
literal, locale, shell, shell-always, c,
escape\n\
-r, --reverse reverse order while sorting\n\
- -R, --recursive list subdirectories recursively\n\
- -s, --size print size of each file, in blocks\n"));
+ -R, --recursive list subdirectories recursively\n"));
printf (_("\
+ -s, --size print size of each file, in blocks\n\
-S sort by file size\n\
--sort=WORD extension -X, none -U, size -S, time -t,\n\
version -v\n\
This would work like this:
address@hidden:~$ ls -al --iso-8601 | head
total 4784
drwxr-xr-x 135 stain users 12288 2001-01-16 16:09:14 .
drwxrwsr-x 32 root staff 4096 2000-11-09 08:29:37 ..
One might argue that the ISO 8601 prefers 2001-01-16T16:09:14. I prefer
the version with space instead of T, this is much easier to read (and
still follows the standard), although the bevour of date(1) is:
address@hidden:~$ date --iso-8601=seconds
2001-01-16T16:12:17+0100
--
Stian Søiland - Trondheim, Norway - http://stain.portveien.to/
Etter kl. 23.00 på hverdager og kl. 24.00 på
dager før helligdager skal det herske ro i hybelen,
samt på eiendommen for øvrig. [Voll studentby]
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Locale and ISO8601 date-format in ls (patches),
Stian Soiland <=