datetime: Show 12 instead of 0 for 12h hour format

The 12h mode hour format is computed by taking the
24h mode hour format modulo 12.

The conversion results in 12 noon getting erroneously
converted to 0.

This commit makes noon get the same special handling
as midnight.
This commit is contained in:
Ray Strode 2011-01-17 14:15:18 -05:00
parent a437c5e768
commit e8120dc4ce

View File

@ -2297,7 +2297,7 @@ g_date_time_format (GDateTime *datetime,
g_string_append_printf (outstr, "%02d", g_date_time_get_hour (datetime));
break;
case 'I':
if (g_date_time_get_hour (datetime) == 0)
if ((g_date_time_get_hour (datetime) % 12) == 0)
g_string_append (outstr, "12");
else
g_string_append_printf (outstr, "%02d", g_date_time_get_hour (datetime) % 12);
@ -2309,7 +2309,7 @@ g_date_time_format (GDateTime *datetime,
g_string_append_printf (outstr, "%2d", g_date_time_get_hour (datetime));
break;
case 'l':
if (g_date_time_get_hour (datetime) == 0)
if ((g_date_time_get_hour (datetime) % 12) == 0)
g_string_append (outstr, "12");
else
g_string_append_printf (outstr, "%2d", g_date_time_get_hour (datetime) % 12);