GNOME Bugzilla – Bug 88798
Internationalization needed for date in GnomeDateEdit
Last modified: 2004-12-22 21:47:04 UTC
I was writting an application with GnomeDateEdit object when I saw that date where badly represented for European people like me. Date was represented like that: mm/dd/yyyy in the date_entry field. I saw in the code that it was something to develop so here is a patch to apply to libgnomeui/gnome-dateedit.c : ------------------------------ cut here ------------------------ 11a12 > #define __USE_XOPEN 78a80 > struct tm time; 82,83c84,91 < /* FIXME: internationalize this - strftime()*/ < g_snprintf (buffer, sizeof(buffer), "%d/%d/%d", month + 1, day, year); --- > time.tm_sec = 0; /* seconds */ > time.tm_min = 0; /* minutes */ > time.tm_hour = 0; /* hours */ > time.tm_mday = day; /* day of the month */ > time.tm_mon = month; /* month */ > time.tm_year = year - 1900; /* year */ > strftime (buffer, sizeof(buffer), "%x", &time); > 181,185c189,191 < /* This code is pretty much just copied from gtk_date_edit_get_date */< sscanf (gtk_entry_get_text (GTK_ENTRY (gde->date_entry)), "%d/%d/%d", < &mtm.tm_mon, &mtm.tm_mday, &mtm.tm_year); /* FIXME: internationalize this - strptime()*/ < < mtm.tm_mon = CLAMP (mtm.tm_mon, 1, 12); --- > strptime (gtk_entry_get_text (GTK_ENTRY (gde->date_entry)), > "%x", &mtm); > mtm.tm_mon = CLAMP (mtm.tm_mon, 0, 11); 188,195d193 < mtm.tm_mon--; < < /* Hope the user does not actually mean years early in the A.D. days... < * This date widget will obviously not work for a history program :-) < */ < if (mtm.tm_year >= 1900) < mtm.tm_year -= 1900; < 402,405c400 < g_snprintf (buffer, sizeof(buffer), "%d/%d/%d", < mytm->tm_mon + 1, < mytm->tm_mday, < 1900 + mytm->tm_year); --- > strftime (buffer, sizeof (buffer), "%x", mytm); 582,585c577,579 < sscanf (gtk_entry_get_text (GTK_ENTRY (gde->date_entry)), "%d/%d/%d", < &tm.tm_mon, &tm.tm_mday, &tm.tm_year); /* FIXME: internationalize this - strptime()*/ < < tm.tm_mon = CLAMP (tm.tm_mon, 1, 12); --- > strptime (gtk_entry_get_text (GTK_ENTRY (gde->date_entry)), > "%x", &tm); > tm.tm_mon = CLAMP (tm.tm_mon, 0, 11); 587,594d580 < < tm.tm_mon--; < < /* Hope the user does not actually mean years early in the A.D. days... < * This date widget will obviously not work for a history program :-) < */ < if (tm.tm_year >= 1900) < tm.tm_year -= 1900; ------------------------------ cut here ------------------------ I can provide full file if needed. This patch use strftime and strptime to internationalize. This is at least better than now but I think it is a little platform dependant and for US date is written like that : mm/dd/yy whereas for FR it is written like that : dd.mm.yyyy (but in France we normaly use dd/mm/yyyy). What ever I think it is already an approvement.
Thank you very much. Could you provide the patch as an attachment and please use -u when creating patches as that makes them so much more readable.
Created attachment 10084 [details] [review] The patch for gnome-dateedit.c file
Have you checked gnome-libs-1.4.1.7? This is the latest release and it doesn't look like the one you worked from. :/
No I haven't use le latest version : gnome-libs-1.4.1.7. My patch was done with : gnome-libs-1.4.1.2. Is it really necessary to provide a patch for the 1.4.1.7 version ? If yes, I will but it will be longer.
The problem is that someone else beat you to it. There was a patch for this in 1.4.1.7, but we are having doubts about that one, and if your patch is better I'll gladly swap it in the next release. Maybe they both have stuff that is good and should be merged etc.
I saw this in 1.4.1.7. I think this version is good (even if I not really try this version). In this version g_date is used. I means that dates problem are threated in glib. In glib the same function (strftime and strptime with format %x)is used. So it might be a better solution. Problem are now part of glib ;)