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

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

index f4e887f837a769792073c6ec93911d6b8f4ff3f1..99b9059fbf425b769273471ce470bbd2bbb5073f 100644 (file)
@@ -365,7 +365,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 a564fc7a2497cb79d958ef3f83fa72b0ae8cf431..17c6d884c14fb0ea9dc7f9da01d0bcf9704120b5 100644 (file)
@@ -100,5 +100,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/bug34304.phpt b/ext/date/tests/bug34304.phpt
new file mode 100644 (file)
index 0000000..a2b26a1
--- /dev/null
@@ -0,0 +1,11 @@
+--TEST--
+Bug #34304 ()
+--FILE--
+<?php
+date_default_timezone_set("UTC");
+echo date('o\-\WW\-N', strtotime('2 January 2005')), "\n";
+echo date('o\-\WW\-N', strtotime('9 January 2005')), "\n";
+?>
+--EXPECT--
+2004-W53-7
+2005-W01-7
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 67be1a03e5ccf2187bd07038794fc83d792e6340..350a4c21d6651ec5753a97abb5dcc037c59ef02a 100644 (file)
@@ -1,5 +1,7 @@
 --TEST--
 date_create() function [3]
+--SKIPIF--
+<?php if (!function_exists('date_create')) echo "SKIP"; ?>
 --FILE--
 <?php
 date_default_timezone_set("GMT");
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];