From b6ee19828bca56e6dd70f8f11fb47f429701d598 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 3 Feb 2016 17:50:58 -0500 Subject: [PATCH] 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 --- Open-ILS/src/c-apps/oils_sql.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Open-ILS/src/c-apps/oils_sql.c b/Open-ILS/src/c-apps/oils_sql.c index a17a60f48b..63323e288b 100644 --- a/Open-ILS/src/c-apps/oils_sql.c +++ b/Open-ILS/src/c-apps/oils_sql.c @@ -856,6 +856,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); @@ -868,6 +869,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); @@ -5887,6 +5889,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); @@ -5901,6 +5904,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); -- 2.11.0