X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_graph.c;h=bd7e3c341a2dd3f8934146736f14c3914363bcd0;hp=a93fbb1c52708ca3d047630eb587434c6ac29a00;hb=8be74deb0aa2a4ee0898642ba9df8a3e5f3f97d6;hpb=f54455954eb3111c1b702d3ed7b9daff833690f3 diff --git a/src/rrd_graph.c b/src/rrd_graph.c index a93fbb1..bd7e3c3 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -29,6 +29,10 @@ #include +#ifdef HAVE_LANGINFO_H +#include +#endif + #include "rrd_graph.h" #include "rrd_client.h" @@ -1356,6 +1360,17 @@ int data_proc( } +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; +#else + first_weekday = 1; +#endif + } + return first_weekday; +} /* identify the point where the first gridline, label ... gets placed */ @@ -1397,10 +1412,10 @@ time_t find_first_time( tm. tm_sec = 0; tm. tm_min = 0; tm. tm_hour = 0; - tm. tm_mday -= tm.tm_wday - 1; /* -1 because we want the monday */ + tm. tm_mday -= tm.tm_wday - find_first_weekday(); - if (tm.tm_wday == 0) - tm. tm_mday -= 7; /* we want the *previous* monday */ + if (tm.tm_wday == 0 && find_first_weekday() > 0) + tm. tm_mday -= 7; /* we want the *previous* week */ break; case TMT_MONTH: