From 6925192aff91524e4c9ae4f3ef847095e4029e17 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Sat, 22 Feb 2014 18:08:19 +0100 Subject: [PATCH] Bug 497831 - Can't change the date of a transaction with certain locales This patch fixes the issue for the cs_CZ locale. --- src/libqof/qof/gnc-date.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/libqof/qof/gnc-date.c b/src/libqof/qof/gnc-date.c index 49738b7916..2bfbf7d100 100644 --- a/src/libqof/qof/gnc-date.c +++ b/src/libqof/qof/gnc-date.c @@ -1121,10 +1121,30 @@ qof_scan_date_internal (const char *buff, int *day, int *month, int *year, if (buff[0] != '\0') { struct tm thetime; + gchar *format = g_strdup (GNC_D_FMT); + gchar *stripped_format = g_strdup (GNC_D_FMT); + gint counter = 0, stripped_counter = 0; + + /* strptime can't handle the - format modifier + * let's strip it out of the format before using it + */ + while (format[counter] != '\0') + { + stripped_format[stripped_counter] = format[counter]; + if ((format[counter] == '%') && (format[counter+1] == '-')) + counter++; // skip - format modifier + + counter++; + stripped_counter++; + } + stripped_format[stripped_counter] = '\0'; + g_free (format); + /* Parse time string. */ memset(&thetime, -1, sizeof(struct tm)); - strptime (buff, GNC_D_FMT, &thetime); + strptime (buff, stripped_format, &thetime); + g_free (stripped_format); if (third_field) {