X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_graph.c;h=9e23a4af06efa10ec652a8643cc0528c80211196;hp=24b58d08bf48b9b8264789aa340aeb382a1c8bc9;hb=9bd31998dca452615148d9e618118aee2a0d2dff;hpb=f99f5a6e7ff6ba37adb08eb0c3c5af9371d3bc56 diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 24b58d0..9e23a4a 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" @@ -1355,7 +1359,21 @@ int data_proc( return 0; } - +static int find_first_weekday(void){ + static int first_weekday = -1; + if (first_weekday == -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 + } + return first_weekday; +} /* identify the point where the first gridline, label ... gets placed */ @@ -1397,10 +1415,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: @@ -1730,6 +1748,7 @@ int leg_place( prt_fctn != 'r' && prt_fctn != 'j' && prt_fctn != 'c' && + prt_fctn != 'u' && prt_fctn != 's' && prt_fctn != '\0' && prt_fctn != 'g') { free(legspace); rrd_set_error @@ -1839,6 +1858,8 @@ int leg_place( leg_y += im->text_prop[TEXT_PROP_LEGEND].size * 1.8; if (prt_fctn == 's') leg_y -= im->text_prop[TEXT_PROP_LEGEND].size; + if (prt_fctn == 'u') + leg_y -= im->text_prop[TEXT_PROP_LEGEND].size *1.8; if(calc_width && (fill > legendwidth)){ legendwidth = fill;