[rrd-users] First day of week (again...)
Daniel R. Hurtmans
dhurtma at ulb.ac.be
Tue Sep 11 15:36:11 CEST 2012
Hello Toby and all others,
I'm trying to move from the already excellent "mrtg" to the even better "rrd"
and facing a problem of first-day-of-week determination.
Apparently locale information is not interpreted correctly. (eg when using an
export LC_ALL="en_GB.utf8" instead of "en_US.UTF-8" it does not switch from
sunday to monday).
Apparently the detection is not made correctly, I've modified successfully the
find_first_weekday function of rrd_graph.c file around line 1378 as follows.
Sorry it's not a proper patch, but it is so short.
Hope it could help providing a better interface.
Daniel
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 */
/* 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) 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
}
return first_weekday;
}
--
/----------------------------------------------------------------------\
| Daniel R. Hurtmans http://www.ulb.ac.be/cpm |
| dhurtma at ulb.ac.be |
| |
| Phone: +32- 2-650 49 40 Fax: +32-2-650 42 32 |
| Université Libre de Bruxelles / Chimie Quantique et Photophysique |
| |\ ___,,--, _ (Atomes, Molécules et Atmosphères) |
| /,`--'' \-,,__,'/ 50 Av F.D. Roosevelt CPi 160/09 |
| |,4 ) )_ ) /~-----' B-1050 Bruxelles, BELGIUM |
\-'---^~(_/-_)--(_/_)--------------------------------------------------/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.oetiker.ch/pipermail/rrd-users/attachments/20120911/11499b3a/attachment-0001.htm
More information about the rrd-users
mailing list