|
|
79117e |
diff -up evolution-3.8.5/e-util/e-dateedit.c.edatetime-time-format evolution-3.8.5/e-util/e-dateedit.c
|
|
|
79117e |
--- evolution-3.8.5/e-util/e-dateedit.c.edatetime-time-format 2013-07-23 14:52:10.000000000 +0200
|
|
|
79117e |
+++ evolution-3.8.5/e-util/e-dateedit.c 2014-01-14 15:04:09.084813320 +0100
|
|
|
79117e |
@@ -1686,6 +1686,39 @@ hide_date_popup (EDateEdit *dedit)
|
|
|
79117e |
}
|
|
|
79117e |
}
|
|
|
79117e |
|
|
|
79117e |
+/* some locales may not define am/pm equivalents for '%p',
|
|
|
79117e |
+ thus force 24 hour format for these, otherwise the am/pm
|
|
|
79117e |
+ time clashes */
|
|
|
79117e |
+static gboolean
|
|
|
79117e |
+date_edit_use_24_hour_format (gboolean use_24_hour_format)
|
|
|
79117e |
+{
|
|
|
79117e |
+ struct tm tmp_tm = { 0 };
|
|
|
79117e |
+ gchar buffer[40];
|
|
|
79117e |
+
|
|
|
79117e |
+ if (use_24_hour_format)
|
|
|
79117e |
+ return TRUE;
|
|
|
79117e |
+
|
|
|
79117e |
+ /* Fill the struct tm with some sane values. */
|
|
|
79117e |
+ tmp_tm.tm_year = 2000;
|
|
|
79117e |
+ tmp_tm.tm_mon = 0;
|
|
|
79117e |
+ tmp_tm.tm_mday = 1;
|
|
|
79117e |
+ tmp_tm.tm_sec = 0;
|
|
|
79117e |
+ tmp_tm.tm_isdst = 0;
|
|
|
79117e |
+ tmp_tm.tm_hour = 1;
|
|
|
79117e |
+ tmp_tm.tm_min = 0;
|
|
|
79117e |
+
|
|
|
79117e |
+ if (e_utf8_strftime (buffer, sizeof (buffer), "%p", &tmp_tm) == 0)
|
|
|
79117e |
+ return TRUE;
|
|
|
79117e |
+
|
|
|
79117e |
+ tmp_tm.tm_hour = 13;
|
|
|
79117e |
+ tmp_tm.tm_min = 0;
|
|
|
79117e |
+
|
|
|
79117e |
+ if (e_utf8_strftime (buffer, sizeof (buffer), "%p", &tmp_tm) == 0)
|
|
|
79117e |
+ return TRUE;
|
|
|
79117e |
+
|
|
|
79117e |
+ return use_24_hour_format;
|
|
|
79117e |
+}
|
|
|
79117e |
+
|
|
|
79117e |
/* Clears the time popup and rebuilds it using the lower_hour, upper_hour
|
|
|
79117e |
* and use_24_hour_format settings. */
|
|
|
79117e |
static void
|
|
|
79117e |
@@ -1696,7 +1729,8 @@ rebuild_time_popup (EDateEdit *dedit)
|
|
|
79117e |
GtkListStore *list_store;
|
|
|
79117e |
GtkTreeIter iter;
|
|
|
79117e |
gchar buffer[40];
|
|
|
79117e |
- struct tm tmp_tm;
|
|
|
79117e |
+ gboolean use_24_hour_format;
|
|
|
79117e |
+ struct tm tmp_tm = { 0 };
|
|
|
79117e |
gint hour, min;
|
|
|
79117e |
|
|
|
79117e |
priv = dedit->priv;
|
|
|
79117e |
@@ -1712,6 +1746,8 @@ rebuild_time_popup (EDateEdit *dedit)
|
|
|
79117e |
tmp_tm.tm_sec = 0;
|
|
|
79117e |
tmp_tm.tm_isdst = 0;
|
|
|
79117e |
|
|
|
79117e |
+ use_24_hour_format = date_edit_use_24_hour_format (priv->use_24_hour_format);
|
|
|
79117e |
+
|
|
|
79117e |
for (hour = priv->lower_hour; hour <= priv->upper_hour; hour++) {
|
|
|
79117e |
|
|
|
79117e |
/* We don't want to display midnight at the end,
|
|
|
79117e |
@@ -1726,24 +1762,14 @@ rebuild_time_popup (EDateEdit *dedit)
|
|
|
79117e |
tmp_tm.tm_hour = hour;
|
|
|
79117e |
tmp_tm.tm_min = min;
|
|
|
79117e |
|
|
|
79117e |
- if (priv->use_24_hour_format)
|
|
|
79117e |
- /* This is a strftime() format.
|
|
|
79117e |
- * %H = hour (0-23), %M = minute. */
|
|
|
79117e |
- e_time_format_time (
|
|
|
79117e |
- &tmp_tm, 1, 0,
|
|
|
79117e |
- buffer, sizeof (buffer));
|
|
|
79117e |
- else
|
|
|
79117e |
- /* This is a strftime() format.
|
|
|
79117e |
- * %I = hour (1-12), %M = minute,
|
|
|
79117e |
- * %p = am/pm string. */
|
|
|
79117e |
- e_time_format_time (
|
|
|
79117e |
- &tmp_tm, 0, 0,
|
|
|
79117e |
- buffer, sizeof (buffer));
|
|
|
79117e |
+ e_time_format_time (
|
|
|
79117e |
+ &tmp_tm, use_24_hour_format, 0,
|
|
|
79117e |
+ buffer, sizeof (buffer));
|
|
|
79117e |
|
|
|
79117e |
/* For 12-hour am/pm format, we want space padding,
|
|
|
79117e |
* not zero padding. This can be done with strftime's
|
|
|
79117e |
* %l, but it's a potentially unportable extension. */
|
|
|
79117e |
- if (!priv->use_24_hour_format && buffer[0] == '0')
|
|
|
79117e |
+ if (use_24_hour_format && buffer[0] == '0')
|
|
|
79117e |
buffer[0] = ' ';
|
|
|
79117e |
|
|
|
79117e |
gtk_list_store_append (list_store, &iter);
|
|
|
79117e |
@@ -2104,7 +2130,7 @@ e_date_edit_update_time_entry (EDateEdit
|
|
|
79117e |
} else {
|
|
|
79117e |
GtkTreeModel *model;
|
|
|
79117e |
GtkTreeIter iter;
|
|
|
79117e |
- gboolean valid;
|
|
|
79117e |
+ gboolean valid, use_24_hour_format;
|
|
|
79117e |
gchar *b;
|
|
|
79117e |
|
|
|
79117e |
/* Set these to reasonable values just in case. */
|
|
|
79117e |
@@ -2118,21 +2144,15 @@ e_date_edit_update_time_entry (EDateEdit
|
|
|
79117e |
tmp_tm.tm_sec = 0;
|
|
|
79117e |
tmp_tm.tm_isdst = -1;
|
|
|
79117e |
|
|
|
79117e |
- if (priv->use_24_hour_format)
|
|
|
79117e |
- /* This is a strftime() format.
|
|
|
79117e |
- * %H = hour (0-23), %M = minute. */
|
|
|
79117e |
- e_time_format_time (
|
|
|
79117e |
- &tmp_tm, 1, 0, buffer, sizeof (buffer));
|
|
|
79117e |
- else
|
|
|
79117e |
- /* This is a strftime() format.
|
|
|
79117e |
- * %I = hour (1-12), %M = minute, %p = am/pm. */
|
|
|
79117e |
- e_time_format_time (
|
|
|
79117e |
- &tmp_tm, 0, 0, buffer, sizeof (buffer));
|
|
|
79117e |
+ use_24_hour_format = date_edit_use_24_hour_format (priv->use_24_hour_format);
|
|
|
79117e |
+
|
|
|
79117e |
+ e_time_format_time (
|
|
|
79117e |
+ &tmp_tm, use_24_hour_format, 0, buffer, sizeof (buffer));
|
|
|
79117e |
|
|
|
79117e |
/* For 12-hour am/pm format, we want space padding, not
|
|
|
79117e |
* zero padding. This can be done with strftime's %l,
|
|
|
79117e |
* but it's a potentially unportable extension. */
|
|
|
79117e |
- if (!priv->use_24_hour_format && buffer[0] == '0')
|
|
|
79117e |
+ if (!use_24_hour_format && buffer[0] == '0')
|
|
|
79117e |
buffer[0] = ' ';
|
|
|
79117e |
|
|
|
79117e |
gtk_entry_set_text (GTK_ENTRY (child), buffer);
|