From: Galen Charlton Date: Wed, 3 Feb 2016 22:50:58 +0000 (-0500) Subject: LP#1485374: call tzset() after setting timezone X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d44bef742856f5c62729af002746b1cd4a2a1f4c;p=working%2FEvergreen.git LP#1485374: call tzset() after setting timezone Testing shows this to be needed to make strftime() return the time in the client's time zone. This is a bit confusing, however, as strftime per POSIX should be acting as if it always calls tzset() when doing formatting that involves the local timezone. Signed-off-by: Galen Charlton Signed-off-by: Jason Stephenson --- diff --git a/Open-ILS/src/c-apps/oils_sql.c b/Open-ILS/src/c-apps/oils_sql.c index 9ea52f6620..c33a3af2a6 100644 --- a/Open-ILS/src/c-apps/oils_sql.c +++ b/Open-ILS/src/c-apps/oils_sql.c @@ -859,6 +859,7 @@ int beginTransaction( osrfMethodContext* ctx ) { if (tz) { setenv("TZ",tz,1); + tzset(); dbi_result tz_res = dbi_conn_queryf( writehandle, "SET LOCAL timezone TO '%s'; -- cstore", tz ); if( !tz_res ) { osrfLogError( OSRF_LOG_MARK, "%s: Error setting timezone %s", modulename, tz); @@ -871,6 +872,7 @@ int beginTransaction( osrfMethodContext* ctx ) { } } else { unsetenv("TZ"); + tzset(); dbi_result res = dbi_conn_queryf( writehandle, "SET timezone TO DEFAULT; -- no tz" ); if( !res ) { osrfLogError( OSRF_LOG_MARK, "%s: Error resetting timezone", modulename); @@ -5890,6 +5892,7 @@ static jsonObject* doFieldmapperSearch( osrfMethodContext* ctx, osrfHash* class_ if (!getXactId(ctx)) { if (tz) { setenv("TZ",tz,1); + tzset(); dbi_result tz_res = dbi_conn_queryf( writehandle, "SET timezone TO '%s'; -- cstore", tz ); if( !tz_res ) { osrfLogError( OSRF_LOG_MARK, "%s: Error setting timezone %s", modulename, tz); @@ -5904,6 +5907,7 @@ static jsonObject* doFieldmapperSearch( osrfMethodContext* ctx, osrfHash* class_ } } else { unsetenv("TZ"); + tzset(); dbi_result res = dbi_conn_queryf( writehandle, "SET timezone TO DEFAULT; -- cstore" ); if( !res ) { osrfLogError( OSRF_LOG_MARK, "%s: Error resetting timezone", modulename);