[glib] datetime: factor out fallback AM/PM function



commit 62edcf03d3b0a799c8a02167b8a44d8b03d40c8b
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sat Apr 1 17:15:41 2017 -0700

    datetime: factor out fallback AM/PM function
    
    We will reuse this.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=761889

 glib/gdatetime.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/glib/gdatetime.c b/glib/gdatetime.c
index 4b6f999..0bb5cbc 100644
--- a/glib/gdatetime.c
+++ b/glib/gdatetime.c
@@ -194,11 +194,7 @@ static const gint month_item[2][12] =
 
 #else
 
-#define GET_AMPM(d)          ((g_date_time_get_hour (d) < 12)  \
-                                       /* Translators: 'before midday' indicator */ \
-                                ? C_("GDateTime", "AM") \
-                                  /* Translators: 'after midday' indicator */ \
-                                : C_("GDateTime", "PM"))
+#define GET_AMPM(d)          (get_fallback_ampm (g_date_time_get_hour (d)))
 
 /* Translators: this is the preferred format for expressing the date and the time */
 #define PREFERRED_DATE_TIME_FMT C_("GDateTime", "%a %b %e %H:%M:%S %Y")
@@ -347,6 +343,18 @@ get_weekday_name_abbr (gint day)
 
 #endif  /* HAVE_LANGINFO_TIME */
 
+/* Format AM/PM indicator if the locale does not have a localized version. */
+static const gchar *
+get_fallback_ampm (gint hour)
+{
+  if (hour < 12)
+    /* Translators: 'before midday' indicator */
+    return C_("GDateTime", "AM");
+  else
+    /* Translators: 'after midday' indicator */
+    return C_("GDateTime", "PM");
+}
+
 static inline gint
 ymd_to_days (gint year,
              gint month,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]