From: Bill Erickson Date: Tue, 29 Sep 2015 16:10:53 +0000 (-0400) Subject: LP#838525 libdbi DATE types translated via gmtime X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=2c42d4cb515d7b35b95bd6b5b6b3b2ac3aec9fe3;p=evergreen%2Fmasslnc.git LP#838525 libdbi DATE types translated via gmtime libdbi assumes a date (w/ no time or timezone) is GMT. Parse the date via gmtime() instead of localtime() to ensure the date returned to the caller matches the date in the DB. Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/c-apps/oils_execsql.c b/Open-ILS/src/c-apps/oils_execsql.c index 4c10ddc596..7491dd3ff9 100644 --- a/Open-ILS/src/c-apps/oils_execsql.c +++ b/Open-ILS/src/c-apps/oils_execsql.c @@ -166,7 +166,7 @@ static jsonObject* get_date_column( dbi_result result, int col_idx ) { gmtime_r( ×tamp, &gmdt ); strftime( timestring, sizeof( timestring ), "%T", &gmdt ); } else if( !( attr & DBI_DATETIME_TIME )) { - localtime_r( ×tamp, &gmdt ); + gmtime_r( ×tamp, &gmdt ); strftime( timestring, sizeof( timestring ), "%F", &gmdt ); } else { localtime_r( ×tamp, &gmdt ); diff --git a/Open-ILS/src/c-apps/oils_sql.c b/Open-ILS/src/c-apps/oils_sql.c index 0d3205cd9e..8169f42d5f 100644 --- a/Open-ILS/src/c-apps/oils_sql.c +++ b/Open-ILS/src/c-apps/oils_sql.c @@ -6683,7 +6683,7 @@ static jsonObject* oilsMakeFieldmapperFromResult( dbi_result result, osrfHash* m gmtime_r( &_tmp_dt, &gmdt ); strftime( dt_string, sizeof( dt_string ), "%T", &gmdt ); } else if( !( attr & DBI_DATETIME_TIME )) { - localtime_r( &_tmp_dt, &gmdt ); + gmtime_r( &_tmp_dt, &gmdt ); strftime( dt_string, sizeof( dt_string ), "%04Y-%m-%d", &gmdt ); } else { localtime_r( &_tmp_dt, &gmdt ); @@ -6769,7 +6769,7 @@ static jsonObject* oilsMakeJSONFromResult( dbi_result result ) { gmtime_r( &_tmp_dt, &gmdt ); strftime( dt_string, sizeof( dt_string ), "%T", &gmdt ); } else if( !( attr & DBI_DATETIME_TIME )) { - localtime_r( &_tmp_dt, &gmdt ); + gmtime_r( &_tmp_dt, &gmdt ); strftime( dt_string, sizeof( dt_string ), "%04Y-%m-%d", &gmdt ); } else { localtime_r( &_tmp_dt, &gmdt );