From 914441218a9e4787662910f513ea2cd097ca0e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 24 Feb 2012 18:05:29 +0100 Subject: [PATCH] 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 --- src/shell-recorder.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/shell-recorder.c b/src/shell-recorder.c index 5b7b54f5b..7a8e27e15 100644 --- a/src/shell-recorder.c +++ b/src/shell-recorder.c @@ -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':