]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Fix for the first day of week detection logic in rrdtool
authorAntony Dovgal <antony.dovgal@gmail.com>
Tue, 13 Nov 2012 14:50:29 +0000 (15:50 +0100)
committerTobias Oetiker <tobi@oetiker.ch>
Tue, 13 Nov 2012 14:50:29 +0000 (15:50 +0100)
src/rrd_graph.c

index 94616cb44f44cf5f79ec674e440ee6abd3db2a15..5649214bc0e10044f9e43c1c7f165ebf55f79347 100644 (file)
@@ -1404,10 +1404,18 @@ static int find_first_weekday(void){
     if (first_weekday == -1){
 #ifdef HAVE__NL_TIME_WEEK_1STDAY
         /* according to http://sourceware.org/ml/libc-locales/2009-q1/msg00011.html */
+        /* See correct way here http://pasky.or.cz/dev/glibc/first_weekday.c */
+        first_weekday = nl_langinfo (_NL_TIME_FIRST_WEEKDAY)[0];
+        int week_1stday;
         long week_1stday_l = (long) nl_langinfo (_NL_TIME_WEEK_1STDAY);
-        if (week_1stday_l == 19971130) first_weekday = 0; /* Sun */
-        else if (week_1stday_l == 19971201) first_weekday = 1; /* Mon */
-        else first_weekday = 1; /* we go for a monday default */
+        if (week_1stday_l == 19971130) week_1stday = 0; /* Sun */
+        else if (week_1stday_l == 19971201) week_1stday = 1; /* Mon */
+        else
+        {
+            first_weekday = 1;
+            return first_weekday; /* we go for a monday default */
+        }
+        first_weekday=(week_1stday + first_weekday - 1) % 7;
 #else
         first_weekday = 1;
 #endif