GNU ls timestamp format

04.11.2010 22:09

This is just in case someone else will find this little piece of Unix trivia useful.

The terse date and time format used by GNU ls -la - you've probably seen it a thousand times. Where does it come from?

It appears to be sensitive to the LC_TIME locale setting:

$ export LC_TIME=sl_SI.UTF-8
$ ls -l
-rw-r--r-- 1 avian avian 0 apr 23 15:56 foo
$ export LC_TIME=en_US.UTF-8
$ ls -l
-rw-r--r-- 1 avian avian 0 2010-04-23 15:56 foo

My first guess were the system-wide locale settings, say in /usr/share/i18n/locales/en_US. However, while that file contains a number of date and time formats, none match those used by ls.

GNU fileutils source code reveals that those are actually stored in the program's specific message translations. The formats use the same gettext mechanism as when localizing messages. They are stored in the source in .po files (for instance in coreutils-8.5/po/en.po).

Obvious, once you find it.

Posted by Tomaž | Categories: Code

Add a new comment

(No HTML tags allowed. Separate paragraphs with a blank line.)