From da5bd42968293ff3996e079d813698b644186f7c Mon Sep 17 00:00:00 2001 From: Joshua Sled Date: Sun, 21 Jan 2007 17:03:36 +0000 Subject: [PATCH] Bug#394420: initialized dates still aren't valid; set to 'now' before manipulating. Also: use correct month (!) :p BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15408 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/gnome-utils/gnc-dense-cal.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/gnome-utils/gnc-dense-cal.c b/src/gnome-utils/gnc-dense-cal.c index f4ff396bc7..e05affe0de 100644 --- a/src/gnome-utils/gnc-dense-cal.c +++ b/src/gnome-utils/gnc-dense-cal.c @@ -147,16 +147,17 @@ static GtkWidgetClass *parent_class = NULL; * 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 @@ gnc_dense_cal_init(GncDenseCal *dcal) { 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));