com php-src: Fix bug 61685 putenv('TZ=UTC') doesn 't update timezone for localtime(): ext/calen dar/tests/unixtojd.phpt
| From: | Anatoliy Belsky | Date: | Sat, 28 Apr 2012 09:42:42 +0000 |
| Subject: | com php-src: Fix bug 61685 putenv('TZ=UTC') doesn 't update timezone for localtime(): ext/calen dar/tests/unixtojd.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-68880@lists.php.net to get a copy of this message | ||
Commit: dc6d283b1c277c2c99a794d17a2e2540a9f2e60e
Author: Matt Ficken <mattficken@php.net> Sat, 28 Apr 2012 11:42:42 +0200
Committer: Anatoliy Belsky <ab@php.net> Sat, 28 Apr 2012 11:42:42 +0200
Parents: 4daab0abecd5ee583c005d8e7b6affc08af8639d
Branches: PHP-5.3 PHP-5.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=dc6d283b1c277c2c99a794d17a2e2540a9f2e60e
Log:
Fix bug 61685 putenv('TZ=UTC') doesn't update timezone for localtime()
Bugs:
https://bugs.php.net/61685
Changed paths:
M ext/calendar/tests/unixtojd.phpt
Diff:
diff --git a/ext/calendar/tests/unixtojd.phpt b/ext/calendar/tests/unixtojd.phpt
index 11edde5..4eeb1ca 100644
--- a/ext/calendar/tests/unixtojd.phpt
+++ b/ext/calendar/tests/unixtojd.phpt
@@ -2,9 +2,34 @@
unixtojd()
--SKIPIF--
<?php include 'skipif.inc'; ?>
+--ENV--
+TZ=UTC
--FILE--
<?php
+// this line has no impact on test output on Windows
putenv('TZ=UTC');
+// getenv('TZ') returns 'UTC' here
+// putenv (basic_functions.c) does call tzset() when the env var being put is 'TZ'
+// -adding a call direct to GetEnvironmentVariableA just before tzset() is called to check the
value of 'TZ' returns 'UTC'
+// putting a call to date_default_timezone_set() here doesn't help
+//
+// on Windows, the only thing that gets this test to pass is to put TZ=UTC in --ENV-- section
+// -since putenv() is written to call tzset() when env var is TZ, I assume that
putenv("TZ=UTC") is intended to work
+// and should work on all platforms(including Windows).
+// easter_date.phpt passes
+// -doesn't use --ENV-- section
+// -uses --INI-- section with date.timezone=UTC
+// -uses putenv('TZ=UTC')
+// date.timezone=UTC
+// -if ommitted from easter_date.phpt, outputs DATE_TZ_ERRMSG warning
+// -easter_date() calls mktime() and localtime()
+// -whereas unixtojd(1000000000) calls localtime(1000000000)
+// -if ommitted from unixtojd.phpt, does NOT output DATE_TZ_ERRMSG
+//
+// unixtojd() calls php_localtime_r() which for Pacific timezone systems, returns a time -8 hours
+// -this incorrect localtime is passed to the julian date conversion (GregorianToSDN) function
which works (probably correctly)
+// but returns -1 day from expected because its input is -1 from expected
+
echo unixtojd(40000). "\n";
echo unixtojd(1000000000). "\n";
echo unixtojd(1152459009). "\n";