clone 361223 -1
retitle -1 [cal] should use locale's _NL_TIME_WEEK_1STDAY to know the first day 
of a week
thanks

Hello,

Cal is still not using nl_langinfo(_NL_TIME_WEEK_1STDAY) to detect the
first day of a week, so that with a fr_FR locale cal makes it start
on Sunday instead of Monday.  The attached patch fixes that.  I have
checked all of en_US, fi_FI and fr_FR locales.

Samuel
--- bsdmainutils-6.1.10/usr.bin/ncal/ncal.c.orig        2008-03-23 
18:21:09.000000000 +0000
+++ bsdmainutils-6.1.10/usr.bin/ncal/ncal.c     2008-03-23 18:20:58.000000000 
+0000
@@ -250,8 +250,20 @@
 
        /* Determine on what day the week starts. */
 #ifdef __GLIBC__
-       if (flag_backward)
-               weekstart = *nl_langinfo(_NL_TIME_FIRST_WEEKDAY) - 1;
+       if (flag_backward) {
+               int first_week_i;
+               date first_week_d;
+               date sunday = { .y = 1997, .m = 11, .d = 30 };
+
+               first_week_i = (intptr_t) nl_langinfo(_NL_TIME_WEEK_1STDAY);
+               first_week_d.d = first_week_i % 100;
+               first_week_i /= 100;
+               first_week_d.m = first_week_i % 100;
+               first_week_i /= 100;
+               first_week_d.y = first_week_i;
+
+               weekstart = *nl_langinfo(_NL_TIME_FIRST_WEEKDAY) + 
(ndaysj(&first_week_d) - ndaysj(&sunday)) % 7 - 1;
+       }
 #endif
 
        while ((ch = getopt(argc, argv, "3Jejmops:wy")) != -1)

Reply via email to