mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
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:
parent
a437c5e768
commit
e8120dc4ce
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user