recorder: Use locale-dependent format for %d in filename

Currently %d hardcodes a date format of YYYYMMDD, use the preferred
format for the current locale instead.

https://bugzilla.gnome.org/show_bug.cgi?id=670753
This commit is contained in:
Florian Müllner 2012-02-24 18:05:29 +01:00
parent e322d98886
commit 914441218a

View File

@ -1214,16 +1214,18 @@ recorder_open_outfile (ShellRecorder *recorder)
break;
case 'd':
{
/* Appends date as YYYYMMDD */
GDate date;
GTimeVal now;
g_get_current_time (&now);
g_date_clear (&date, 1);
g_date_set_time_val (&date, &now);
g_string_append_printf (filename, "%04d%02d%02d",
g_date_get_year (&date),
g_date_get_month (&date),
g_date_get_day (&date));
/* Appends date according to locale */
GDateTime *datetime = g_date_time_new_now_local ();
char *date_str = g_date_time_format (datetime, "%0x");
char *s;
for (s = date_str; *s; s++)
if (G_IS_DIR_SEPARATOR (*s))
*s = '-';
g_string_append (filename, date_str);
g_free (date_str);
g_date_time_unref (datetime);
}
break;
case 'u':