AUDIT: r15408 - gnucash/trunk/src/gnome-utils - Bug#394420: initialized dates still aren't valid; set to 'now' before manipulating. Also: use correct month (!) :p
Josh Sled
jsled at cvs.gnucash.org
Sun Jan 21 12:03:36 EST 2007
Author: jsled
Date: 2007-01-21 12:03:36 -0500 (Sun, 21 Jan 2007)
New Revision: 15408
Trac: http://svn.gnucash.org/trac/changeset/15408
Modified:
gnucash/trunk/src/gnome-utils/gnc-dense-cal.c
Log:
Bug#394420: initialized dates still aren't valid; set to 'now' before manipulating. Also: use correct month (!) :p
BP
Modified: gnucash/trunk/src/gnome-utils/gnc-dense-cal.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-dense-cal.c 2007-01-21 16:38:42 UTC (rev 15407)
+++ gnucash/trunk/src/gnome-utils/gnc-dense-cal.c 2007-01-21 17:03:36 UTC (rev 15408)
@@ -147,16 +147,17 @@
* locale.*/
static const gchar *month_name(int mon)
{
- static gchar buf[MONTH_NAME_BUFSIZE];
- GDate *date;
+ static gchar buf[MONTH_NAME_BUFSIZE];
+ GDate date;
- memset(buf, 0, MONTH_NAME_BUFSIZE);
- date = g_date_new();
- g_date_set_month(date, mon);
- g_date_strftime(buf, MONTH_NAME_BUFSIZE-1, "%b", date);
- g_date_free(date);
-
- return buf;
+ memset(buf, 0, MONTH_NAME_BUFSIZE);
+ g_date_clear(&date, 1);
+ g_date_set_time_t(&date, time(NULL));
+ // g_date API is 1..12 (not 0..11)
+ g_date_set_month(&date, mon+1);
+ g_date_strftime(buf, MONTH_NAME_BUFSIZE-1, "%b", &date);
+
+ return buf;
}
/* Takes the number of days since Sunday, in the range 0 to 6. Returns
* the abbreviated weekday name according to the current locale. */
@@ -303,8 +304,8 @@
{
gint w, h;
gdk_string_extents(dcal->monthLabelFont, month_name(i),
- &lbearing, &rbearing, &width,
- &ascent, &descent);
+ &lbearing, &rbearing, &width,
+ &ascent, &descent);
w = rbearing - lbearing + 1;
h = ascent + descent;
maxLBearing = MAX(maxLBearing, ABS(lbearing));
More information about the gnucash-changes
mailing list