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

index 6ad540a03e34dd3244fef15a9792816c29ed061c..9a262ca1fda6debbfafe34e8c3cd83551836a1ce 100644 (file)
@@ -1380,10 +1380,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