gnucash maint: Bug 791848 - GC 2.6.x does not handle ISO dates introduced with GC 2.7
John Ralls
jralls at code.gnucash.org
Sat Dec 23 19:42:56 EST 2017
Updated via https://github.com/Gnucash/gnucash/commit/44c51f43 (commit)
from https://github.com/Gnucash/gnucash/commit/a28bcdf1 (commit)
commit 44c51f433b0a07e44d1485cac5c16537031703ba
Author: John Ralls <jralls at ceridwen.us>
Date: Sat Dec 23 16:42:43 2017 -0800
Bug 791848 - GC 2.6.x does not handle ISO dates introduced with GC 2.7
Enable reading ISO-formatted dates, recognize GNC_FEATURE_SQLITE3_ISO_DATES.
diff --git a/src/backend/sql/gnc-backend-sql.c b/src/backend/sql/gnc-backend-sql.c
index 7d169d1..76aa181 100644
--- a/src/backend/sql/gnc-backend-sql.c
+++ b/src/backend/sql/gnc-backend-sql.c
@@ -1855,7 +1855,9 @@ typedef Timespec (*TimespecAccessFunc)( const gpointer );
typedef void (*TimespecSetterFunc)( const gpointer, Timespec );
#define TIMESPEC_STR_FORMAT "%04d%02d%02d%02d%02d%02d"
+#define TIMESPEC_ALT_FORMAT "%04d-%02d%-02d %02d:%02d:%02d"
#define TIMESPEC_COL_SIZE (4+2+2+2+2+2)
+#define TIMESPEC_ALT_COL_SIZE (4+3+3+3+3+3)
/* This is required because we're passing be->timespace_format to
* g_strdup_printf.
@@ -1926,22 +1928,24 @@ load_timespec( const GncSqlBackend* be, GncSqlRow* row,
else if (G_VALUE_HOLDS_STRING (val))
{
const gchar* s = g_value_get_string( val );
- if ( s != NULL )
+ if ( s != NULL && strlen(s) == TIMESPEC_COL_SIZE)
+ {
+ gchar* buf;
+ buf = g_strdup_printf( "%c%c%c%c-%c%c-%c%c %c%c:%c%c:%c%c",
+ s[0], s[1], s[2], s[3],
+ s[4], s[5],
+ s[6], s[7],
+ s[8], s[9],
+ s[10], s[11],
+ s[12], s[13] );
+ ts = gnc_iso8601_to_timespec_gmt( buf );
+ g_free( buf );
+ isOK = TRUE;
+ }
+ else if (! g_str_has_prefix (s, "0000-00-00"))
{
- if (! g_str_has_prefix (s, "0000-00-00"))
- {
- gchar* buf;
- buf = g_strdup_printf( "%c%c%c%c-%c%c-%c%c %c%c:%c%c:%c%c",
- s[0], s[1], s[2], s[3],
- s[4], s[5],
- s[6], s[7],
- s[8], s[9],
- s[10], s[11],
- s[12], s[13] );
- ts = gnc_iso8601_to_timespec_gmt( buf );
- g_free( buf );
- }
- isOK = TRUE;
+ ts = gnc_iso8601_to_timespec_gmt (s);
+ isOK = TRUE;
}
}
else
diff --git a/src/core-utils/gnc-features.c b/src/core-utils/gnc-features.c
index 1cc495a..03c9418 100644
--- a/src/core-utils/gnc-features.c
+++ b/src/core-utils/gnc-features.c
@@ -46,6 +46,7 @@ static gncFeature known_features[] =
{ GNC_FEATURE_KVP_EXTRA_DATA, "Extra data for addresses, jobs or invoice entries (requires at least GnuCash 2.6.4)" },
{ GNC_FEATURE_GUID_BAYESIAN, "Use account GUID as key for Bayesian data (requires at least GnuCash 2.6.12)" },
{ GNC_FEATURE_GUID_FLAT_BAYESIAN, "Use account GUID as key for bayesian data and store KVP flat (requires at least GnuCash 2.6.19)" },
+ { GNC_FEATURE_SQLITE3_ISO_DATES, "Use ISO formatted date-time strings in SQLite3 databases (requires at least GnuCash 2.6.20)"},
{ NULL },
};
diff --git a/src/core-utils/gnc-features.h b/src/core-utils/gnc-features.h
index a7ed421..df4b590 100644
--- a/src/core-utils/gnc-features.h
+++ b/src/core-utils/gnc-features.h
@@ -46,6 +46,7 @@
#define GNC_FEATURE_KVP_EXTRA_DATA "Extra data in addresses, jobs or invoice entries"
#define GNC_FEATURE_GUID_BAYESIAN "Account GUID based Bayesian data"
#define GNC_FEATURE_GUID_FLAT_BAYESIAN "Account GUID based bayesian with flat KVP"
+#define GNC_FEATURE_SQLITE3_ISO_DATES "ISO-8601 formatted date strings in SQLite3 databases."
/** @} */
Summary of changes:
src/backend/sql/gnc-backend-sql.c | 34 +++++++++++++++++++---------------
src/core-utils/gnc-features.c | 1 +
src/core-utils/gnc-features.h | 1 +
3 files changed, 21 insertions(+), 15 deletions(-)
More information about the gnucash-changes
mailing list