#793008 pal: weeknumber calculation not locale aware

Package:
pal
Source:
pal
Description:
command-line calendar program that can keep track of events
Submitter:
Rhonda D'Vine
Date:
2015-07-20 21:36:04 UTC
Severity:
normal
#793008#5
Date:
2015-07-20 12:10:28 UTC
From:
To:
Package: pal
Version: 0.4.3-8
Severity: normal

Dear Maintainer,

 I noticed today that pal seems to calculate the weeknumber always US
centric (or at least not locale aware).  If one has put show_weeknum
into ~/.pal/pal.conf, regardless of LC_TIME setting pal always seems to
calculate as if it's set to C.

 Example to reproduce:

#+
$> LC_TIME=de_AT.UTF-8 pal
     Mo   Di   Mi   Do   Fr   Sa   So |     Mo   Di   Mi   Do   Fr   Sa   So
Jul  13   14   15   16   17   18   19 |Aug  17   18   19   20   21   22   23
 29 @20@  21   22   23   24   25   26 | 34  24   25   26   27   28   29   30
Aug  27   28   29   30   31   01   02 |Sep  31   01   02   03   04   05   06
 31  03   04   05   06   07   08   09 | 36  07   08   09   10   11   12   13
 32  10   11   12   13   14  A15T  16 | 37  14   15   16   17   18   19   20
$> LC_TIME=C pal
Jul  13   14   15   16   17   18   19 |Aug  17   18   19   20   21   22   23
 29 @20@  21   22   23   24   25   26 | 34  24   25   26   27   28   29   30
Aug  27   28   29   30   31   01   02 |Sep  31   01   02   03   04   05   06
Aug  27   28   29   30   31   01   02 |Sep  31   01   02   03   04   05   06
 31  03   04   05   06   07   08   09 | 36  07   08   09   10   11   12   13
 32  10   11   12   13   14  A15T  16 | 37  14   15   16   17   18   19   20
$>
#-

 See first column, mixed with the month name: It's the same :)

 On the other hand, ncal -w does take the LC_TIME environment into account:

#v+
$> LC_TIME=de_AT.UTF-8 ncal -w
    Juli 2015
Mo     6 13 20 27
Di     7 14 21 28
Mi  1  8 15 22 29
Do  2  9 16 23 30
Fr  3 10 17 24 31
Sa  4 11 18 25
So  5 12 19 26
   27 28 29 30 31
$> LC_TIME=C ncal -w
    July 2015
Su     5 12 19 26
Mo     6 13 20 27
Tu     7 14 21 28
We  1  8 15 22 29
Th  2  9 16 23 30
Fr  3 10 17 24 31
Sa  4 11 18 25
   26 27 28 29 30
$>
#v-

 See last line. Interestingly, even with LC_TIME=en_US.UTF-8 the weeknum
becomes 30.

 Thanks,
Rhonda

#793008#8
Date:
2015-07-20 14:20:00 UTC
From:
To:
Thanks for this great bug report!

* Rhonda D'Vine [2015-07-20 14:10 +0200]:
 * A Google search revealed DIN 1355 / ISO 8601 as possibly relevant,
   if one wants to verify that ncal -w is indeed correct.
 * This bug presumably isn't triggered for all years (depending on the
   first day of the year).
 * LC_TIME=de_DE* seems to behave as LC_TIME=C in this case.
 * pal(1) does not mention show_weeknum.
 * An additional relevant pal rc setting is week_start_monday.
 * This could be useful for testing:
       LC_TIME=C TERM=dumb datefudge "1980-01-01 00:00" ...
 * Since ncal hardly implemented proper LC_TIME handling itself,
   this might be related to a libc function it uses - checking if
   setlocale() is used correctly looks like a good idea.

#793008#11
Date:
2015-07-20 14:20:00 UTC
From:
To:
Thanks for this great bug report!

* Rhonda D'Vine [2015-07-20 14:10 +0200]:
 * A Google search revealed DIN 1355 / ISO 8601 as possibly relevant,
   if one wants to verify that ncal -w is indeed correct.
 * This bug presumably isn't triggered for all years (depending on the
   first day of the year).
 * LC_TIME=de_DE* seems to behave as LC_TIME=C in this case.
 * pal(1) does not mention show_weeknum.
 * An additional relevant pal rc setting is week_start_monday.
 * This could be useful for testing:
       LC_TIME=C TERM=dumb datefudge "1980-01-01 00:00" ...
 * Since ncal hardly implemented proper LC_TIME handling itself,
   this might be related to a libc function it uses - checking if
   setlocale() is used correctly looks like a good idea.

#793008#16
Date:
2015-07-20 21:03:35 UTC
From:
To:
Interesting. I didn't think it was possile and at the very least it's
porely documented, but: it looks like the information is there:

$ LC_TIME=en_US.UTF-8 locale -k LC_TIME |grep week-1stweek
week-1stweek=7
$ LC_TIME=C locale -k LC_TIME |grep week-1stweek
week-1stweek=4
$ locale -k LC_TIME |grep week-1stweek
week-1stweek=0

This information is available via nl_langinfo(). It shouldn't be too
hard to make this usable somewhere...

Have a nice day,
-- Arthur Schopenhauer