Question

I've a assertion fail with my gtk+/C code, so, I don't know why :

The error is : g_date_set_month: assertion 'g_date_valid_month (m)' failed

And the suspected lines are:

t_day day; 
uint y, m, da;

gtk_calendar_get_date(GTK_CALENDAR(d->calendar), &y, &m, &da);

g_date_set_day(&day.date, da);
g_date_set_year(&day.date, y);
g_date_set_month(&day.date, m);

it's the only function which I use g_date_set_month().

Thanks for reading

Était-ce utile?

La solution

GtkCalendar returns a month value between 0-11:

month : location to store the month number (between 0 and 11), or NULL. [out][allow-none]

GDate uses month values between 1-12 (see the internal representation and the enum type used in the setter):

guint month : 4; the day of the day-month-year representation of the date, as a number between 1 and 12

You will presumably need to convert between the two formats.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top