Re: Dates and l10n
- From: Bjorn Andersson <ban lifix fi>
- To: gnome-devel-list gnome org
- Subject: Re: Dates and l10n
- Date: Mon, 29 Nov 1999 21:17:47 +0200
On Mon, Nov 29 1999, at 20:48:25 +0200, Bjorn Andersson wrote:
> I will attach a suggestion for a patch against gnome-libs-1.0.54 to
> the i18n related FIXMEs in gnome-dateedit.c.
Sorry about that, I sent you a buggy patch :(. Here is the
correct one that should contain at least one bug less.
Regards,
--
Björn Andersson <bjorn@lifix.fi> +358-50-3412556
Lifix Systems Oy <http://www.lifix.fi/> Professional Linux Solutions
Tekniikantie 21, FIN-02150 Espoo +358-9-4375272
--- gnome-libs-1.0.54.orig/libgnomeui/gnome-dateedit.c Wed Oct 20 15:46:06 1999
+++ gnome-libs-1.0.54/libgnomeui/gnome-dateedit.c Mon Nov 29 20:07:24 1999
@@ -75,11 +75,16 @@
{
char buffer [40];
gint year, month, day;
+ struct tm tm = {0};
gtk_calendar_get_date (calendar, &year, &month, &day);
-
- /* FIXME: internationalize this - strftime()*/
- g_snprintf (buffer, sizeof(buffer), "%d/%d/%d", month + 1, day, year);
+ if (year >= 1900)
+ tm.tm_year = year - 1900;
+ else
+ tm.tm_year = year;
+ tm.tm_mon = month;
+ tm.tm_mday = day;
+ strftime(buffer, sizeof(buffer), "%x", &tm);
gtk_entry_set_text (GTK_ENTRY (gde->date_entry), buffer);
gtk_signal_emit (GTK_OBJECT (gde), date_edit_signals [DATE_CHANGED]);
}
@@ -177,16 +182,8 @@
GdkCursor *cursor;
/* 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--;
-
- /* 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;
+ strptime(gtk_entry_get_text (GTK_ENTRY (gde->date_entry)), "%x",
+ &mtm);
gtk_calendar_select_month (GTK_CALENDAR (gde->calendar), mtm.tm_mon, 1900 + mtm.tm_year);
gtk_calendar_select_day (GTK_CALENDAR (gde->calendar), mtm.tm_mday);
@@ -394,10 +391,7 @@
mytm = localtime (&the_time);
/* Set the date */
- 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);
gtk_entry_set_text (GTK_ENTRY (gde->date_entry), buffer);
/* Set the time */
@@ -573,16 +567,7 @@
g_assert(gde != NULL);
g_assert(GNOME_IS_DATE_EDIT(gde));
- 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--;
-
- /* 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;
+ strptime(gtk_entry_get_text (GTK_ENTRY (gde->date_entry)), "%x", &tm);
if (gde->flags & GNOME_DATE_EDIT_SHOW_TIME) {
char *tokp, *temp;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]