mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
- MF51: Fixed bug #35143 (gettimeofday() ignores current time zone).
- MF51: Fixed tests due to class constants patch.
This commit is contained in:
parent
7ad4fb0c27
commit
d732859624
9 changed files with 55 additions and 16 deletions
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
11
ext/date/tests/bug34304.phpt
Normal file
11
ext/date/tests/bug34304.phpt
Normal file
|
@ -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
|
21
ext/date/tests/bug35143.phpt
Normal file
21
ext/date/tests/bug35143.phpt
Normal file
|
@ -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)
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue