(gnucash:12739): GLib-CRITICAL **: g_date_set_month: assertion `g_date_valid_month (m)' failedI had seen the error messages above so often that after 10 minutes, I decided to fix them.
(gnucash:12739): GLib-CRITICAL **: g_date_strftime: assertion `g_date_valid (d)' failed
I searched for the error messages and soon landed at the month_name function in src/gnome-utils/gnc-dense-cal.c
The comment above has it: the variable mon will be from 0 to 11 and the number 0 is what choked glib. This is done.
#define MONTH_NAME_BUFSIZE 5
/* Takes the number of months since January, in the range 0 to
* 11. Returns the abbreviated month name according to the current
* locale. (i18n'd version of the above static character array.) */
static const gchar *month_name(int mon)
{
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;
}
Next, the error message on strftime is cryptic. I went online and searched for what actually g_date_strftime expects and what g_date_new does. From a reliable source, it seems g_date_new creates a new date which is invalid, to make it valid we can use the function g_date_new_dmy.
With all these, let's whack the bugs:
GnuCash developers have my permission to incorporate this fix into the project if they wish.
#define MONTH_NAME_BUFSIZE 5
/* Takes the number of months since January, in the range 0 to
* 11. Returns the abbreviated month name according to the current
* locale. (i18n'd version of the above static character array.) */
static const gchar *month_name(int mon)
{
static gchar buf[MONTH_NAME_BUFSIZE];
GDate *date;
memset(buf, 0, MONTH_NAME_BUFSIZE);
/* date = g_date_new();*/
date = g_date_new_dmy(4, G_DATE_JULY, 2006); /* initialize to sane value */
/* printf("%s: setmonth is %d \n", __func__, mon); */ /* Debug statement */
g_date_set_month(date, mon+1);
g_date_strftime(buf, MONTH_NAME_BUFSIZE-1, "%b", date);
g_date_free(date);
return buf;
}

