Date: Sun, 7 Jun 2015 18:51:30 +1000 From: andrew clarke <mail@ozzmosis.com> To: freebsd-questions@freebsd.org Subject: Custom locale to use ISO 8601 date format Message-ID: <20150607085130.GA77300@ozzmosis.com>
next in thread | raw e-mail | index | archive | help
Here in Australia the general population uses the British DD/MM/YY format for representing dates, eg. today is 07/06/15, and the en_AU.UTF-8 locale in FreeBSD 10.1 honours that: lrwxr-xr-x 1 root wheel 22 17 Feb 2011 /usr/share/locale/en_AU.UTF-8/LC_TIME -> ../en_GB.UTF-8/LC_TIME However I wanted programs to use the ISO 8601 YYYY-MM-DD date format (2015-06-07) instead. To do this in Linux, the general method seems to set LC_TIME=en_DK.utf8, but FreeBSD has no locale by that name. As root, I could modify /usr/share/locale/en_AU.UTF-8/LC_TIME, but that could be overwritten when I upgrade to 10.2 with freebsd-update. After reading locale(1) it turns out users can set PATH_LOCALE=$HOME/locale to use their own custom locales, so I copied /usr/share/locale/ to $HOME/locale/ then modified $HOME/locale/en_AU.UTF-8/LC_TIME: $ diff -u /usr/share/locale/en_AU.UTF-8/LC_TIME $HOME/locale/en_AU.UTF-8/LC_TIME --- /usr/share/locale/en_AU.UTF-8/LC_TIME 2011-02-17 13:19:18.000000000 +1100 +++ /home/ozzmosis/locale/en_AU.UTF-8/LC_TIME 2015-06-07 18:17:57.537156884 +1000 @@ -37,7 +37,7 @@ Friday Saturday %H:%M:%S -%d/%m/%Y +%Y-%m-%d %a %e %b %X %Y am pm Make sure LANG=en_AU.UTF-8 is set in your login, then logout and back in: $ locale LANG=en_AU.UTF-8 LC_CTYPE="en_AU.UTF-8" LC_COLLATE="en_AU.UTF-8" LC_TIME="en_AU.UTF-8" LC_NUMERIC="en_AU.UTF-8" LC_MONETARY="en_AU.UTF-8" LC_MESSAGES="en_AU.UTF-8" LC_ALL= $ date +"%x %X" 2015-06-07 18:42:59 Hopefully others find this useful. Regards Andrew
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150607085130.GA77300>