make sure we only use _NL_TIME_WEEK_1STDAY if we actually have it ... thanks kevin...
[rrdtool.git] / src / rrd_graph.c
index bd7e3c3..9e23a4a 100644 (file)
@@ -1359,12 +1359,15 @@ int data_proc(
     return 0;
 }
 
-
 static int find_first_weekday(void){
     static int first_weekday = -1;
     if (first_weekday == -1){
-#if defined(HAVE_NL_LANGINFO)
-        first_weekday = nl_langinfo(_NL_TIME_FIRST_WEEKDAY)[0] - 1;
+#ifdef HAVE__NL_TIME_WEEK_1STDAY
+        /* according to http://sourceware.org/ml/libc-locales/2009-q1/msg00011.html */
+        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 */
 #else
         first_weekday = 1;
 #endif