From owner-freebsd-questions@FreeBSD.ORG Sun Jun 7 08:51:34 2015 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 610F2CC1 for ; Sun, 7 Jun 2015 08:51:34 +0000 (UTC) (envelope-from mail@ozzmosis.com) Received: from homiemail-a50.g.dreamhost.com (sub5.mail.dreamhost.com [208.113.200.129]) by mx1.freebsd.org (Postfix) with ESMTP id 467D51AB8 for ; Sun, 7 Jun 2015 08:51:33 +0000 (UTC) (envelope-from mail@ozzmosis.com) Received: from homiemail-a50.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a50.g.dreamhost.com (Postfix) with ESMTP id 09C782038 for ; Sun, 7 Jun 2015 01:51:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=ozzmosis.com; h=date:from :to:subject:message-id:mime-version:content-type; s= ozzmosis.com; bh=rRVZOtqyhhaV6OCoawhXWLPSSRI=; b=jEyDflyhbmWmkVc 4tQ8Tp4577DiLSQLhWmfSMr+Y6AaP67x5TtpemoUn3TX2/Hseu1zFFz87EVTBPsH nc+0n+KqEf1lW3YnNyFKmU4Ru1Qf/aHMKVrUwkw0Owa23P6FnvzNe9HYEBYKSOIP 8P3kS+8OYnFaqK3AE2pdbXY/hpUM= Received: from blizzard.ozzmosis.com (114-198-63-194.dyn.iinet.net.au [114.198.63.194]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: relay@ozzmosis.com) by homiemail-a50.g.dreamhost.com (Postfix) with ESMTPSA id BDC092037 for ; Sun, 7 Jun 2015 01:51:32 -0700 (PDT) Received: by blizzard.ozzmosis.com (Postfix, from userid 1001) id 643D6AFF; Sun, 7 Jun 2015 18:51:30 +1000 (AEST) Date: Sun, 7 Jun 2015 18:51:30 +1000 From: andrew clarke To: freebsd-questions@freebsd.org Subject: Custom locale to use ISO 8601 date format Message-ID: <20150607085130.GA77300@ozzmosis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jun 2015 08:51:34 -0000 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