View Full Version : How to use twenty-four-hour time instead of AM/PM
Pete
18-Aug-2010, 07:08 AM
Using Ubuntu Linux, I'd like to use twenty-four-hour time in file listings instead of AM/PM. Is there a way to set this in BC? If not, I'd like to know which API function BC calls so maybe I can find a solution myself (e.g. perhaps by setting an environment variable).
David
18-Aug-2010, 03:12 PM
Pete,
BC picks this up from the 'locale' system that linux uses. You cannot change it in BC but you can change what your linux system uses. Here are a couple of web links that talk about how to do it (unfortunately not as simple as changing to 24 mode from a control panel).
http://ccollins.wordpress.com/2009/01/06/how-to-change-date-formats-on-ubuntu/
http://blog.chewearn.com/2008/11/14/change-date-format-globally-in-ubuntu/
What worked best for me in Ubuntu 10.04 was:
1) sudo cp /usr/share/i18n/locales/en_US /usr/share/i18n/locales/en_DFJ
2) sudo vi /usr/share/i18n/locales/en_DFJ
edit the line for 't_fmt_ampm' and remove the last three atoms i.e. <U0020><U0025><U0070>. Be sure to leave it all one line and close it with ". This will remove the '%p' from the LC_TIME string that says to use AM/PM
3) sudo vi /var/lib/locales/supported.d/en
add in a line for en_DFJ.UTF-8
4) sudo locale-gen
This will regenerate all the locales listed in /var/lib/locales/supported.d
5) sudo vi /etc/environment
add following
LC_TIME="en_DFJ.UTF-8"
The above will get a custom locale built with the AM/PM turned off and then set LC_TIME to use the custom version. You will have to log out and back in for it to take affect.
Pete
19-Aug-2010, 08:38 AM
Thanks for the detailed instructions. I now have 24-hour time.
(I'd like to know the genius who thought it would be a good idea to use for example <U0025><U0054> instead of %T.)
I wasn't able to change the date format however. I tried setting this:
d_fmt "<U0025><U0046>" (which is %F: yyyy-mm-dd)
and re-ran locale-gen.
Well, the time setting is more important to me than the date so I can live with it.
graemeg
19-Oct-2011, 04:52 AM
Try using LC_ALL instead of LC_TIME
eg:
export LC_ALL=en_DK.UTF-8
I do the same for Mozilla Thunderbird. So I simply created my own start-up script for each application (or edit the bcompare script) and add the above line in the script.
Pete
20-Oct-2011, 05:07 AM
Try using LC_ALL instead of LC_TIME
Thanks, I'll try it when I have time.
vBulletin® v3.7.1, Copyright ©2000-2013, Jelsoft Enterprises Ltd.