]> granicus.if.org Git - php/commitdiff
- Fixed bug #35143 (gettimeofday() ignores current time zone).
authorDerick Rethans <derick@php.net>
Sun, 20 Nov 2005 20:14:24 +0000 (20:14 +0000)
committerDerick Rethans <derick@php.net>
Sun, 20 Nov 2005 20:14:24 +0000 (20:14 +0000)
- Fixed tests due to class constants patch.

NEWS
ext/date/php_date.c
ext/date/php_date.h
ext/date/tests/bug35143.phpt [new file with mode: 0644]
ext/date/tests/date_create-2.phpt
ext/date/tests/date_modify-1.phpt
ext/date/tests/date_modify-2.phpt
ext/standard/microtime.c

diff --git a/NEWS b/NEWS
index 7c19886d806287d32ef9795c0558987ef5e9943e..1e03755015067250771d06836067ccd8480d10fd 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ PHP                                                                        NEWS
 - Fixed bug #35273 (Error in mapping soap - java types). (Dmitry)
 - Fixed bug #35243 (php_mblen() crashes when compiled with thread-safety
   on Linux). (Patch: shulmanb at il dot ibm dot com, Jani)
+- Fixed bug #35143 (gettimeofday() ignores current time zone). (Derick)
 - Fixed bug #33153 (crash in mssql_next result). (Frank)
 - Fixed bug #33963 (mssql_bind() fails on input parameters). (Frank)
 - Fixed bug #33201 (Crash when fetching some data types). (Frank)
index 51ffbc98603f84384dc4a7dd2eba0de45e2a9084..73ec1a069e6314517cfd9361ef86dcf2ad3f7427 100644 (file)
@@ -363,7 +363,7 @@ php_win_std_time:
        return "UTC";
 }
 
-static timelib_tzinfo *get_timezone_info(TSRMLS_D)
+PHPAPI timelib_tzinfo *get_timezone_info(TSRMLS_D)
 {
        char *tz;
        timelib_tzinfo *tzi;
index f68628df3a5d19395826fbf09d23a4d9991ecab5..08a03931d4d107020a6c2a1cc98ef0cb4e5edca9 100644 (file)
@@ -99,5 +99,6 @@ PHPAPI char *php_format_date(char *format, int format_len, time_t ts, int localt
 
 /* Mechanism to set new TZ database */
 PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb);
+PHPAPI timelib_tzinfo *get_timezone_info(TSRMLS_D);
 
 #endif /* PHP_DATE_H */
diff --git a/ext/date/tests/bug35143.phpt b/ext/date/tests/bug35143.phpt
new file mode 100644 (file)
index 0000000..02b0072
--- /dev/null
@@ -0,0 +1,21 @@
+--TEST--
+Bug #35143 (gettimeofday() ignores current time zone)
+--FILE--
+<?php
+date_default_timezone_set("UTC");
+
+var_dump(date_default_timezone_get());
+var_dump(gettimeofday());
+?>
+--EXPECTF--
+string(3) "UTC"
+array(4) {
+  ["sec"]=>
+  int(%d)
+  ["usec"]=>
+  int(%d)
+  ["minuteswest"]=>
+  int(0)
+  ["dsttime"]=>
+  int(0)
+}
index e3bb1b334808d94c08574353f18360f613eb4a45..d7c785e22877a884501e7e85300a8f3d18a44666 100644 (file)
@@ -6,7 +6,7 @@ date_create() function [2]
 <?php
 date_default_timezone_set("GMT");
 $d = date_create("2005-07-18 22:10:00 +0400");
-echo $d->format(DATE_RFC822), "\n";
+echo $d->format(date::RFC822), "\n";
 ?>
 --EXPECT--
 Mon, 18 Jul 2005 22:10:00 GMT+0400
index b931553d1980e5018f3cbf214dbb6ca6000415d7..dc03f5ff9c9f03be5df912dff964e38927497e74 100644 (file)
@@ -6,20 +6,20 @@ date_modify() function [1]
 <?php
 date_default_timezone_set("Pacific/Kwajalein");
 $ts = date_create("Thu Aug 19 1993 23:59:59");
-echo date_format($ts, DATE_RFC822), "\n";
+echo date_format($ts, date::RFC822), "\n";
 $ts->modify("+1 second");
-echo date_format($ts, DATE_RFC822), "\n";
+echo date_format($ts, date::RFC822), "\n";
 
 date_default_timezone_set("Europe/Amsterdam");
 $ts = date_create("Sun Mar 27 01:59:59 2005");
-echo date_format($ts, DATE_RFC822), "\n";
+echo date_format($ts, date::RFC822), "\n";
 $ts->modify("+1 second");
-echo date_format($ts, DATE_RFC822), "\n";
+echo date_format($ts, date::RFC822), "\n";
 
 $ts = date_create("Sun Oct 30 01:59:59 2005");
-echo date_format($ts, DATE_RFC822), "\n";
+echo date_format($ts, date::RFC822), "\n";
 $ts->modify("+ 1 hour 1 second");
-echo date_format($ts, DATE_RFC822), "\n";
+echo date_format($ts, date::RFC822), "\n";
 ?>
 --EXPECT--
 Thu, 19 Aug 1993 23:59:59 KWAT
index da22316af03dbc0dba47c617db437575a3e53a3c..9bf7a5d2d602a217193dba9e917e77ad1bb8c50e 100644 (file)
@@ -6,9 +6,9 @@ date_modify() function [2]
 <?php
 date_default_timezone_set("GMT");
 $d = date_create("2005-07-18 22:10:00 +0400");
-echo date_format($d, DATE_RFC822), "\n";
+echo date_format($d, date::RFC822), "\n";
 date_modify($d, "+1 hour");
-echo date_format($d, DATE_RFC822), "\n";
+echo date_format($d, date::RFC822), "\n";
 ?>
 --EXPECT--
 Mon, 18 Jul 2005 22:10:00 GMT+0400
index 5550be3a088a3dcc7b46e52eb10c89cb28a7297d..504bd6ceedd24ee1b0360a4933021150bbf2ea0c 100644 (file)
@@ -43,6 +43,7 @@
 #include <errno.h>
 
 #include "microtime.h"
+#include "ext/date/php_date.h"
 
 #define NUL  '\0'
 #define MICRO_IN_SEC 1000000.00
@@ -68,15 +69,18 @@ static void _php_gettimeofday(INTERNAL_FUNCTION_PARAMETERS, int mode)
        }
 
        if (mode) {
+               timelib_time_offset *offset;
+
+               offset = timelib_get_time_zone_info(tp.tv_sec, get_timezone_info(TSRMLS_C));
+                               
                array_init(return_value);
                add_assoc_long(return_value, "sec", tp.tv_sec);
                add_assoc_long(return_value, "usec", tp.tv_usec);
-#ifdef PHP_WIN32
-               add_assoc_long(return_value, "minuteswest", tz.tz_minuteswest/SEC_IN_MIN);
-#else
-               add_assoc_long(return_value, "minuteswest", tz.tz_minuteswest);
-#endif                 
-               add_assoc_long(return_value, "dsttime", tz.tz_dsttime);
+
+               add_assoc_long(return_value, "minuteswest", -offset->offset / SEC_IN_MIN);
+               add_assoc_long(return_value, "dsttime", offset->is_dst);
+
+               timelib_time_offset_dtor(offset);
        } else {
                char ret[100];