[PLUG] Modifying LC_TIME

Daniel Hedlund daniel at digitree.org
Mon Sep 25 07:54:09 UTC 2006


Rich,

Rich Shepard wrote:
> week-1stday=19971201
> 
>   If I change the week-1stday -- somehow -- to 19971130 then the week will
> start on Sunday. Also, I could change the first_workday to =2 and that 
> would

19971201 -> 1997/12/01 (YYYY/MM/DD) = Monday
19971130 -> 1997/11/30 (YYYY/MM/DD) = Sunday

This problem that you describe appears to have been widely reported as a 
bug in GNU C library's locale.
http://sourceware.org/bugzilla/show_bug.cgi?id=2371

I'm not sure what version of the glibc library you're running, but 
you're probably stuck with one of the versions that has the bug.  The 
version I'm using, 2.4.11 doesn't seem to be affected by this problem 
and my week-1stday entry appears as 19971130...so the problem has been 
fixed at some point.

I only see the following options for you:
1. upgrade glibc (ugly and probably not worth it!)

2. change to a different locale for the LC_TIME variable, such as 
en_US.UTF-8 and see if that provides a different value for week-1stday. 
  The following code automates testing every single locale on the system 
that matches your desired LC_TIME settings:
#!/bin/bash
# finds other locales that match the desired LC_TIME settings
export LC_TIME="en_US"
locale -k LC_TIME | sed s/19971201/19971130/ > locale.old
for i in `locale -a`; do
    export LC_TIME="$i"
    locale -k LC_TIME > locale.new
    (diff --brief locale.old locale.new > /dev/null) \
      && echo "match found...$i"
done

3. use localedef.  I wrote a bash script specifically to do this for 
you!  Well, for anyone else who comes across the bug in the future and 
for myself.  I wanted to be able to change the starting day of the week 
for the en_AU locale to be on a Monday (which for some reason it isn't). 
  I can imagine that several months in the future when I 
reinstall/upgrade my distro that I'll forget to copy over the new 
locales (or they won't work), and I'll have forgotten how to fix things 
again.  I've tested the script on my system and it seemed to work. 
There is nothing destructive and it can be run as non-root.  The 
defaults on the configuration variables are already set for your bug; 
just run the script and follow the "further instructions".  Have a look 
here:
http://projects.digitree.org/miscellaneous/wiki/locale_week_fix

Cheers,

Daniel Hedlund
daniel at digitree.org



More information about the PLUG mailing list