Bug#789130: bsdmainutils: [ncal] prints wrong week number
On Thu, Sep 03, 2015 at 10:36:36PM +0200, Sergey Romanov wrote: > Weird. I'd never expect C and C.UTF-8 be different. These are locale values: > $ LC_ALL=C locale week-1stweek > 4 > $ LC_ALL=C.UTF-8 locale week-1stweek > 7 So is this a locale problem then? Michael -- Michael Meskes Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org) Meskes at (Debian|Postgresql) dot Org Jabber: michael at xmpp dot meskes dot org VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL
Bug#789130: bsdmainutils: [ncal] prints wrong week number
It depends on the current locale and what day, Sunday or Monday, counts as start of the week. In C/POSIX, the first Sunday of the year starts week 1: $ LC_ALL=C ncal -wd 2015-01 January 2015 Su 4 11 18 25 Mo 5 12 19 26 Tu 6 13 20 27 We 7 14 21 28 Th 1 8 15 22 29 Fr 2 9 16 23 30 Sa 3 10 17 24 31 53 1 2 3 4 $ LC_ALL=C ncal -Mwd 2015-01 January 2015 Mo 5 12 19 26 Tu 6 13 20 27 We 7 14 21 28 Th 1 8 15 22 29 Fr 2 9 16 23 30 Sa 3 10 17 24 31 Su 4 11 18 25 1 2 3 4 5 But in de_DE.UTF-8, it's ISO 8601 (i.e. %V): weeks start on a Monday, and week 1 must contain at least four days: $ LC_ALL=de_DE.UTF-8 ncal -wd 2015-01 Januar 2015 Mo 5 12 19 26 Di 6 13 20 27 Mi 7 14 21 28 Do 1 8 15 22 29 Fr 2 9 16 23 30 Sa 3 10 17 24 31 So 4 11 18 25 1 2 3 4 5 $ LC_ALL=de_DE.UTF-8 ncal -wd 2016-01 Januar 2016 Mo 4 11 18 25 Di 5 12 19 26 Mi 6 13 20 27 Do 7 14 21 28 Fr 1 8 15 22 29 Sa 2 9 16 23 30 So 3 10 17 24 31 53 1 2 3 4 $ date -d 2015-01-03 +'%U %V %W' 00 01 00 $ date -d 2015-01-04 +'%U %V %W' 01 01 00 $ date -d 2015-01-05 +'%U %V %W' 01 02 01
Bug#789130: bsdmainutils: [ncal] prints wrong week number
Weird. I'd never expect C and C.UTF-8 be different. These are locale values: $ LC_ALL=C locale week-1stweek 4 $ LC_ALL=C.UTF-8 locale week-1stweek 7 $ LC_ALL=en_US locale week-1stweek 7 LC_ALL=en_US.utf8 locale week-1stweek 7 $ LC_ALL=de_DE.utf8 locale week-1stweek 4 $ LC_ALL=ru_RU.utf8 locale week-1stweek 0
Bug#789130: bsdmainutils: [ncal] prints wrong week number
Ah, sorry, it seems I was wrong about the C locale. I just cannot make out how it counts weeks. Comments in usr.bin/ncal/calendar.c suggest that it uses ISO definition, except when exactly 3 days of the first week are in the preceding year -- in this case it would use the locale value. Still, I get strange results with en_US.UTF-8, e.g: $ LC_ALL=en_US.UTF-8 ncal -wd 2011-01 January 2011 Su 2 9 16 23 30 Mo 3 10 17 24 31 Tu 4 11 18 25 We 5 12 19 26 Th 6 13 20 27 Fr 7 14 21 28 Sa 1 8 15 22 29 1 2 3 4 5 6
Bug#789130: bsdmainutils: [ncal] prints wrong week number
Package: bsdmainutils Version: 9.0.6 Severity: normal A similar bug was reported in #676426 which was already archived. This time however, the week's number displayed by ncal is one week behind (24 instead of 25): $ date Thursday 18 June 15:14:18 AEST 2015 $ ncal -w June 2015 Su 7 14 21 28 Mo 1 8 15 22 29 Tu 2 9 16 23 30 We 3 10 17 24 Th 4 11 18 25 Fr 5 12 19 26 Sa 6 13 20 27 22 23 24 25 26 -- System Information: Debian Release: 8.0 APT prefers stable APT policy: (500, 'stable') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores) Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: sysvinit (via /sbin/init) Versions of packages bsdmainutils depends on: ii bsdutils 1:2.25.2-6 ii debianutils 4.4+b1 ii libc62.19-18 ii libncurses5 5.9+20140913-1+b1 ii libtinfo55.9+20140913-1+b1 bsdmainutils recommends no packages. Versions of packages bsdmainutils suggests: ii cpp 4:4.9.2-2 pn vacation none ii wamerican [wordlist] 7.1-1 pn whois none -- no debconf information -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org