goffice r2336 - in trunk: . goffice/utils
- From: mortenw svn gnome org
- To: svn-commits-list gnome org
- Subject: goffice r2336 - in trunk: . goffice/utils
- Date: Thu, 19 Mar 2009 23:13:07 +0000 (UTC)
Author: mortenw
Date: Thu Mar 19 23:13:07 2009
New Revision: 2336
URL: http://svn.gnome.org/viewvc/goffice?rev=2336&view=rev
Log:
2009-03-19 Morten Welinder <terra gnome org>
* goffice/utils/go-format.c (go_format_magic_fmt_str): Use
go_locale_24h.
* goffice/utils/go-locale.c (go_locale_24h): New function.
Modified:
trunk/ChangeLog
trunk/goffice/utils/go-format.c
trunk/goffice/utils/go-locale.c
trunk/goffice/utils/go-locale.h
Modified: trunk/goffice/utils/go-format.c
==============================================================================
--- trunk/goffice/utils/go-format.c (original)
+++ trunk/goffice/utils/go-format.c Thu Mar 19 23:13:07 2009
@@ -422,12 +422,6 @@
static char *
go_format_magic_fmt_str (GOFormatMagic m)
{
- const GString *tf = go_locale_get_time_format ();
- gboolean ampm = (strstr (tf->str, "AM/PM") ||
- strstr (tf->str, "am/pm") ||
- strstr (tf->str, "A/P") ||
- strstr (tf->str, "a/p"));
-
switch (m) {
default:
return NULL;
@@ -466,10 +460,10 @@
const char *fmt = _("*Long Time Format");
if (fmt[0] && fmt[0] != '*')
return g_strdup (fmt);
- if (ampm)
- return g_strdup ("h:mm:ss AM/PM");
- else
+ if (go_locale_24h ())
return g_strdup ("hh:mm:ss");
+ else
+ return g_strdup ("h:mm:ss AM/PM");
break;
}
@@ -478,10 +472,10 @@
const char *fmt = _("*Medium Time Format");
if (fmt[0] && fmt[0] != '*')
return g_strdup (fmt);
- if (ampm)
- return g_strdup ("h:mm AM/PM");
- else
+ if (go_locale_24h ())
return g_strdup ("hh:mm");
+ else
+ return g_strdup ("h:mm AM/PM");
break;
}
Modified: trunk/goffice/utils/go-locale.c
==============================================================================
--- trunk/goffice/utils/go-locale.c (original)
+++ trunk/goffice/utils/go-locale.c Thu Mar 19 23:13:07 2009
@@ -49,6 +49,8 @@
static gboolean date_order_cached = FALSE;
+static gboolean locale_is_24h_cached = FALSE;
+
static gboolean boolean_cached = FALSE;
static char const *lc_TRUE = NULL;
static char const *lc_FALSE = NULL;
@@ -60,6 +62,7 @@
date_format_cached = FALSE;
time_format_cached = FALSE;
date_order_cached = FALSE;
+ locale_is_24h_cached = FALSE;
boolean_cached = FALSE;
return setlocale (category, val);
}
@@ -287,6 +290,7 @@
case 'l': g_string_append (lc_time_format, "h"); break; /* Approx */
case 'M': g_string_append (lc_time_format, "mm"); break;
case 'p': g_string_append (lc_time_format, "AM/PM"); break;
+ case 'P': g_string_append (lc_time_format, "am/pm"); break;
case 'r': g_string_append (lc_time_format, "hh:mm:ss AM/PM"); break;
case 'S': g_string_append (lc_time_format, "ss"); break;
case 'T': g_string_append (lc_time_format, "hh:mm:ss"); break;
@@ -394,6 +398,31 @@
return month_first;
}
+/**
+ * go_locale_24h :
+ *
+ * Returns: TRUE if the locale uses a 24h clock, FALSE otherwise.
+ */
+gboolean
+go_locale_24h (void)
+{
+ static gboolean locale_is_24h;
+
+ if (!locale_is_24h_cached) {
+ const GString *tf = go_locale_get_time_format ();
+
+ /* Crude. Figure out how to ask properly. */
+ locale_is_24h = !(strstr (tf->str, "AM/PM") ||
+ strstr (tf->str, "am/pm") ||
+ strstr (tf->str, "A/P") ||
+ strstr (tf->str, "a/p"));
+ locale_is_24h_cached = TRUE;
+ }
+
+ return locale_is_24h;
+}
+
+
/* Use comma as the arg separator unless the decimal point is a
* comma, in which case use a semi-colon
*/
Modified: trunk/goffice/utils/go-locale.h
==============================================================================
--- trunk/goffice/utils/go-locale.h (original)
+++ trunk/goffice/utils/go-locale.h Thu Mar 19 23:13:07 2009
@@ -38,6 +38,7 @@
GString const *go_locale_get_thousand (void);
GString const *go_locale_get_decimal (void);
int go_locale_month_before_day (void);
+gboolean go_locale_24h (void);
GString const *go_locale_get_date_format (void);
GString const *go_locale_get_time_format (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]