From: Antony Dovgal Date: Tue, 13 Nov 2012 14:57:49 +0000 (+0100) Subject: fix for first day of the week detection logic X-Git-Tag: 1.4.8~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c583ec30a4d7b37e49f930d5fe4d6afc9b81ccd;p=thirdparty%2Frrdtool-1.x.git fix for first day of the week detection logic --- diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 6ad540a0..9a262ca1 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -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