summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hash.c14
-rw-r--r--time.c11
2 files changed, 14 insertions, 11 deletions
diff --git a/hash.c b/hash.c
index 6b3f844095..0b3745cf6e 100644
--- a/hash.c
+++ b/hash.c
@@ -4711,6 +4711,17 @@ env_delete(VALUE name)
nam = env_name(name);
val = getenv(nam);
+
+ /*
+ * ENV['TZ'] = nil has a special meaning.
+ * TZ is no longer considered up-to-date and ruby call tzset() as needed.
+ * It could be useful if sysadmin change /etc/localtime.
+ * This hack might works only on Linux glibc.
+ */
+ if (ENVMATCH(nam, TZ_ENV)) {
+ ruby_tz_uptodate_p = FALSE;
+ }
+
if (val) {
VALUE value = env_str_new2(val);
@@ -4718,9 +4729,6 @@ env_delete(VALUE name)
if (ENVMATCH(nam, PATH_ENV)) {
RB_GC_GUARD(name);
}
- else if (ENVMATCH(nam, TZ_ENV)) {
- ruby_tz_uptodate_p = false;
- }
return value;
}
return Qnil;
diff --git a/time.c b/time.c
index 3cb5a060f9..137d5e0f9f 100644
--- a/time.c
+++ b/time.c
@@ -3139,15 +3139,10 @@ find_time_t(struct tm *tptr, int utc_p, time_t *tp)
find_dst = 0 < tptr->tm_isdst;
-#if defined(HAVE_MKTIME)
- tm0 = *tptr;
- if (!utc_p && (guess = mktime(&tm0)) != -1) {
- tm = GUESS(&guess);
- if (tm && tmcmp(tptr, tm) == 0) {
- goto found;
- }
+ /* /etc/localtime might be changed. reload it. */
+ if (!ruby_tz_uptodate_p) {
+ tzset();
}
-#endif
tm0 = *tptr;
if (tm0.tm_mon < 0) {