Some Bits: Nelson's log

Locale fine tuning

I finally fixed an annoyance of several years where date in Linux was printing out 12 hour time like Sun Dec 21 02:53:05 PM UTC 2025. Here’s where I landed in my .bashenv

# locale configuration. US UTF-8 everywhere but 24 hour clocks.
export LANG=en_US.UTF-8
export LC_TIME=en_GB.UTF-8
export LC_NUMERIC=en_US.UTF-8
export LC_COLLATE=POSIX
export LC_CTYPE=en_US.UTF-8
# have to unset this so LC_TIME will override.
unset LC_ALL

The key thing here is LC_TIME. But also unsetting LC_ALL.

I used to just set LC_ALL to en_US.UTF-8, I started doing that before UTF-8 became common. But if you do that it overrides LC_TIME so you still get 12 hour dates. Instead you have to unset LC_ALL and then set each locale thing separately. There’s twelve of them! Most systems I log into are probably already set up as en_US.UTF_8 so this doesn’t matter, but hopefully this overrides the important stuff. I haven’t tested it well, I’m going off ChatGPT’s recommendation which is suspect as always.

LC_COLLATE=POSIX is something I’ve been doing many years, ever since Unix environments started doing more proper language-specific collation. The problem is that changed the behavior of /bin/sort which broke a lot of things, so hacking it back to a non-linguistic sorting works better for programming.

Now I also have to hope the system generated the en_GB.UTF-8 locale.