summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-18 10:30:41 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-18 10:30:41 +0000
commit4bc16691279e98ecdb3e19ff23902be671d46307 (patch)
tree020365f1dbb98ccbb1dec6ec33f2b36bc26e6d03 /time.c
parenta22232cd938a1d3df8f940463fb68700de124a19 (diff)
reduce tzset
* time.c (rb_localtime_r): call tzset() only after TZ environment variable is changed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/time.c b/time.c
index 10ec0f2a36..b49db04172 100644
--- a/time.c
+++ b/time.c
@@ -647,12 +647,18 @@ static struct vtm *localtimew(wideval_t timew, struct vtm *result);
static int leap_year_p(long y);
#define leap_year_v_p(y) leap_year_p(NUM2LONG(modv((y), INT2FIX(400))))
+int ruby_tz_update;
+
static struct tm *
rb_localtime_r(const time_t *t, struct tm *result)
{
#if defined __APPLE__ && defined __LP64__
if (*t != (time_t)(int)*t) return NULL;
#endif
+ if (!ruby_tz_update) {
+ ruby_tz_update = 1;
+ tzset();
+ }
#ifdef HAVE_GMTIME_R
result = localtime_r(t, result);
#else
@@ -678,7 +684,7 @@ rb_localtime_r(const time_t *t, struct tm *result)
#endif
return result;
}
-#define LOCALTIME(tm, result) (tzset(),rb_localtime_r((tm), &(result)))
+#define LOCALTIME(tm, result) rb_localtime_r((tm), &(result))
#ifndef HAVE_STRUCT_TM_TM_GMTOFF
static struct tm *