mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-14 00:06:24 +01:00
datetime: Fix coding style
This commit is contained in:
parent
0a59ab6e85
commit
2952e908e4
@ -1843,7 +1843,8 @@ g_date_time_printf (const GDateTime *datetime,
|
||||
tmp = g_utf8_offset_to_pointer (format, i);
|
||||
c = g_utf8_get_char (tmp);
|
||||
|
||||
switch (c) {
|
||||
switch (c)
|
||||
{
|
||||
case '%':
|
||||
if (!in_mod)
|
||||
{
|
||||
@ -1854,7 +1855,8 @@ g_date_time_printf (const GDateTime *datetime,
|
||||
default:
|
||||
if (in_mod)
|
||||
{
|
||||
switch (c) {
|
||||
switch (c)
|
||||
{
|
||||
case 'a':
|
||||
g_string_append (outstr, WEEKDAY_ABBR (datetime));
|
||||
break;
|
||||
@ -1868,12 +1870,10 @@ g_date_time_printf (const GDateTime *datetime,
|
||||
g_string_append (outstr, MONTH_FULL (datetime));
|
||||
break;
|
||||
case 'd':
|
||||
g_string_append_printf (outstr, "%02d",
|
||||
g_date_time_get_day_of_month (datetime));
|
||||
g_string_append_printf (outstr, "%02d", g_date_time_get_day_of_month (datetime));
|
||||
break;
|
||||
case 'e':
|
||||
g_string_append_printf (outstr, "%2d",
|
||||
g_date_time_get_day_of_month (datetime));
|
||||
g_string_append_printf (outstr, "%2d", g_date_time_get_day_of_month (datetime));
|
||||
break;
|
||||
case 'F':
|
||||
g_string_append_printf (outstr, "%d-%02d-%02d",
|
||||
@ -1885,42 +1885,34 @@ g_date_time_printf (const GDateTime *datetime,
|
||||
g_string_append (outstr, MONTH_ABBR (datetime));
|
||||
break;
|
||||
case 'H':
|
||||
g_string_append_printf (outstr, "%02d",
|
||||
g_date_time_get_hour (datetime));
|
||||
g_string_append_printf (outstr, "%02d", g_date_time_get_hour (datetime));
|
||||
break;
|
||||
case 'I':
|
||||
if (g_date_time_get_hour (datetime) == 0)
|
||||
g_string_append (outstr, "12");
|
||||
else
|
||||
g_string_append_printf (outstr, "%02d",
|
||||
g_date_time_get_hour (datetime) % 12);
|
||||
g_string_append_printf (outstr, "%02d", g_date_time_get_hour (datetime) % 12);
|
||||
break;
|
||||
case 'j':
|
||||
g_string_append_printf (outstr, "%03d",
|
||||
g_date_time_get_day_of_year (datetime));
|
||||
g_string_append_printf (outstr, "%03d", g_date_time_get_day_of_year (datetime));
|
||||
break;
|
||||
case 'k':
|
||||
g_string_append_printf (outstr, "%2d",
|
||||
g_date_time_get_hour (datetime));
|
||||
g_string_append_printf (outstr, "%2d", g_date_time_get_hour (datetime));
|
||||
break;
|
||||
case 'l':
|
||||
if (g_date_time_get_hour (datetime) == 0)
|
||||
g_string_append (outstr, "12");
|
||||
else
|
||||
g_string_append_printf (outstr, "%2d",
|
||||
g_date_time_get_hour (datetime) % 12);
|
||||
g_string_append_printf (outstr, "%2d", g_date_time_get_hour (datetime) % 12);
|
||||
break;
|
||||
case 'm':
|
||||
g_string_append_printf (outstr, "%02d",
|
||||
g_date_time_get_month (datetime));
|
||||
g_string_append_printf (outstr, "%02d", g_date_time_get_month (datetime));
|
||||
break;
|
||||
case 'M':
|
||||
g_string_append_printf (outstr, "%02d",
|
||||
g_date_time_get_minute (datetime));
|
||||
g_string_append_printf (outstr, "%02d", g_date_time_get_minute (datetime));
|
||||
break;
|
||||
case 'N':
|
||||
g_string_append_printf (outstr, "%"G_GUINT64_FORMAT,
|
||||
datetime->usec % USEC_PER_SECOND);
|
||||
g_string_append_printf (outstr, "%"G_GUINT64_FORMAT, datetime->usec % USEC_PER_SECOND);
|
||||
break;
|
||||
case 'p':
|
||||
g_string_append (outstr, GET_AMPM (datetime, FALSE));
|
||||
@ -1928,7 +1920,8 @@ g_date_time_printf (const GDateTime *datetime,
|
||||
case 'P':
|
||||
g_string_append (outstr, GET_AMPM (datetime, TRUE));
|
||||
break;
|
||||
case 'r': {
|
||||
case 'r':
|
||||
{
|
||||
gint hour = g_date_time_get_hour (datetime) % 12;
|
||||
if (hour == 0)
|
||||
hour = 12;
|
||||
@ -1937,54 +1930,50 @@ g_date_time_printf (const GDateTime *datetime,
|
||||
g_date_time_get_minute (datetime),
|
||||
g_date_time_get_second (datetime),
|
||||
GET_AMPM (datetime, FALSE));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'R':
|
||||
g_string_append_printf (outstr, "%02d:%02d",
|
||||
g_date_time_get_hour (datetime),
|
||||
g_date_time_get_minute (datetime));
|
||||
break;
|
||||
case 's':
|
||||
g_string_append_printf (outstr, "%" G_GINT64_FORMAT,
|
||||
g_date_time_to_epoch (datetime));
|
||||
g_string_append_printf (outstr, "%" G_GINT64_FORMAT, g_date_time_to_epoch (datetime));
|
||||
break;
|
||||
case 'S':
|
||||
g_string_append_printf (outstr, "%02d",
|
||||
g_date_time_get_second (datetime));
|
||||
g_string_append_printf (outstr, "%02d", g_date_time_get_second (datetime));
|
||||
break;
|
||||
case 't':
|
||||
g_string_append_c (outstr, '\t');
|
||||
break;
|
||||
case 'u':
|
||||
g_string_append_printf (outstr, "%d",
|
||||
g_date_time_get_day_of_week (datetime));
|
||||
g_string_append_printf (outstr, "%d", g_date_time_get_day_of_week (datetime));
|
||||
break;
|
||||
case 'W':
|
||||
g_string_append_printf (outstr, "%d",
|
||||
g_date_time_get_day_of_year (datetime) / 7);
|
||||
g_string_append_printf (outstr, "%d", g_date_time_get_day_of_year (datetime) / 7);
|
||||
break;
|
||||
case 'x': {
|
||||
case 'x':
|
||||
{
|
||||
tmp2 = GET_PREFERRED_DATE (datetime);
|
||||
g_string_append (outstr, tmp2);
|
||||
g_free (tmp2);
|
||||
break;
|
||||
}
|
||||
case 'X': {
|
||||
break;
|
||||
case 'X':
|
||||
{
|
||||
tmp2 = GET_PREFERRED_TIME (datetime);
|
||||
g_string_append (outstr, tmp2);
|
||||
g_free (tmp2);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'y':
|
||||
g_string_append_printf (outstr, "%02d",
|
||||
g_date_time_get_year (datetime) % 100);
|
||||
g_string_append_printf (outstr, "%02d", g_date_time_get_year (datetime) % 100);
|
||||
break;
|
||||
case 'Y':
|
||||
g_string_append_printf (outstr, "%d",
|
||||
g_date_time_get_year (datetime));
|
||||
g_string_append_printf (outstr, "%d", g_date_time_get_year (datetime));
|
||||
break;
|
||||
case 'Z':
|
||||
if (datetime->tz)
|
||||
if (datetime->tz != NULL)
|
||||
g_string_append_printf (outstr, "%s", datetime->tz->name);
|
||||
else
|
||||
g_string_append_printf (outstr, "UTC");
|
||||
@ -2005,10 +1994,7 @@ g_date_time_printf (const GDateTime *datetime,
|
||||
}
|
||||
}
|
||||
|
||||
tmp = outstr->str;
|
||||
g_string_free (outstr, FALSE);
|
||||
|
||||
return (gchar*)tmp;
|
||||
return g_string_free (outstr, FALSE);
|
||||
|
||||
bad_format:
|
||||
g_string_free (outstr, TRUE);
|
||||
|
Loading…
Reference in New Issue
Block a user