datetime: factor out fallback AM/PM function

We will reuse this.

https://bugzilla.gnome.org/show_bug.cgi?id=761889
This commit is contained in:
Cosimo Cecchi 2017-04-01 17:15:41 -07:00
parent 9163306de2
commit 62edcf03d3

View File

@ -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,