derick Sat Jan 26 16:26:56 2008 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/date/tests bug40743.phpt bug41599.phpt bug42910.phpt
bug43003.phpt bug43527.phpt bug43808.phpt
Modified files:
/php-src NEWS
/php-src/ext/date php_date.c
/php-src/ext/date/lib parse_date.c tm2unixtime.c
Log:
- MFH Bugfixes:
- Fixed bug #43808 (date_create never fails (even when it should)).
- Fixed bug #43527 (DateTime created from a timestamp reports
environment
timezone).
- Fixed bug #43003 (Invalid timezone reported for DateTime objects
constructed using a timestamp).
- Fixed bug #42190 (Constructing DateTime with TimeZone Indicator
invalidates DateTimeZone).
- Fixed bug #41599 (setTime() fails after modify() is used).
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.1059&r2=1.2027.2.547.2.1060&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.1059 php-src/NEWS:1.2027.2.547.2.1060
--- php-src/NEWS:1.2027.2.547.2.1059 Wed Jan 23 01:22:57 2008
+++ php-src/NEWS Sat Jan 26 16:26:33 2008
@@ -16,6 +16,7 @@
in mysql_connect()). (Hannes)
- Fixed bug #43863 (str_word_count() breaks on cyrillic "ya" in locale cp1251).
(phprus at gmail dot com, Tony)
+- Fixed bug #43808 (date_create never fails (even when it should)). (Derick)
- Fixed bug #43793 (zlib filter is unable to auto-detect gzip/zlib file
headers).
(Greg)
- Fixed bug #43703 (Signature compatibility check broken). (Dmitry)
@@ -32,6 +33,8 @@
- Fixed bug #43580 (removed bogus declaration of a non-existent php_is_url()
function). (Ilia)
- Fixed bug #43533 (escapeshellarg('') returns null). (Ilia)
+- Fixed bug #43527 (DateTime created from a timestamp reports environment
+ timezone). (Derick)
- Fixed bug #43522 (stream_get_line() eats additional characters). (Felipe,
Ilia, Tony)
- Fixed bug #43497 (OCI8 XML/getClobVal aka temporary LOBs leak UGA memory).
@@ -57,6 +60,8 @@
(Jani)
- Fixed bug #43301 (mb_ereg*_replace() crashes when replacement string is
invalid PHP expression and 'e' option is used). (Jani)
+- Fixed bug #43003 (Invalid timezone reported for DateTime objects constructed
+ using a timestamp). (Derick)
- Fixed bug #43295 (crash because of uninitialized SG(sapi_headers).mimetype).
(Dmitry)
- Fixed bug #43293 (Multiple segfaults in getopt()). (Hannes)
@@ -87,6 +92,9 @@
- Fixed bug #42272 (var_export() incorrectly escapes char(0)). (Derick)
- Fixed bug #42261 (Incorrect lengths for date and boolean data types).
(Ilia)
+- Fixed bug #42190 (Constructing DateTime with TimeZone Indicator invalidates
+ DateTimeZone). (Derick)
+- Fixed bug #41599 (setTime() fails after modify() is used). (Derick)
- Fixed bug #38468 (Unexpected creation of cycle). (Dmitry)
08 Nov 2007, PHP 5.2.5
http://cvs.php.net/viewvc.cgi/php-src/ext/date/php_date.c?r1=1.43.2.45.2.53&r2=1.43.2.45.2.54&diff_format=u
Index: php-src/ext/date/php_date.c
diff -u php-src/ext/date/php_date.c:1.43.2.45.2.53
php-src/ext/date/php_date.c:1.43.2.45.2.54
--- php-src/ext/date/php_date.c:1.43.2.45.2.53 Mon Dec 31 07:20:05 2007
+++ php-src/ext/date/php_date.c Sat Jan 26 16:26:33 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_date.c,v 1.43.2.45.2.53 2007/12/31 07:20:05 sebastian Exp $ */
+/* $Id: php_date.c,v 1.43.2.45.2.54 2008/01/26 16:26:33 derick Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -266,7 +266,18 @@
struct _php_timezone_obj {
zend_object std;
- timelib_tzinfo *tz;
+ int initialized;
+ int type;
+ union {
+ timelib_tzinfo *tz; // TIMELIB_ZONETYPE_ID;
+ timelib_sll utc_offset; // TIMELIB_ZONETYPE_OFFSET
+ struct // TIMELIB_ZONETYPE_ABBR
+ {
+ timelib_sll utc_offset;
+ char *abbr;
+ int dst;
+ } z;
+ } tzi;
};
#define DATE_SET_CONTEXT \
@@ -808,7 +819,26 @@
);
break;
case 'T': length = slprintf(buffer, 32, "%s", localtime
? offset->abbr : "GMT"); break;
- case 'e': length = slprintf(buffer, 32, "%s", localtime
? t->tz_info->name : "UTC"); break;
+ case 'e': if (!localtime) {
+ length = slprintf(buffer, 32,
"%s", "UTC");
+ } else {
+ switch (t->zone_type) {
+ case
TIMELIB_ZONETYPE_ID:
+ length =
slprintf(buffer, 32, "%s", t->tz_info->name);
+ break;
+ case
TIMELIB_ZONETYPE_ABBR:
+ length =
slprintf(buffer, 32, "%s", offset->abbr);
+ break;
+ case
TIMELIB_ZONETYPE_OFFSET:
+ length =
slprintf(buffer, 32, "%c%02d:%02d",
+
((offset->offset < 0) ? '-' : '+'),
+
abs(offset->offset / 3600),
+
abs((offset->offset % 3600) / 60)
+
);
+ break;
+ }
+ }
+ break;
case 'Z': length = slprintf(buffer, 32, "%d", localtime
? offset->offset : 0); break;
/* full date/time */
@@ -1086,7 +1116,7 @@
now = timelib_time_ctor();
initial_ts = emalloc(25);
- snprintf(initial_ts, 24, "@%ld", preset_ts);
+ snprintf(initial_ts, 24, "@%ld UTC", preset_ts);
t = timelib_strtotime(initial_ts, strlen(initial_ts), NULL,
DATE_TIMEZONEDB); /* we ignore the error here, as this should never fail */
timelib_update_ts(t, tzi);
now->tz_info = tzi;
@@ -1590,7 +1620,21 @@
zend_object_value new_ov = date_object_new_timezone_ex(old_obj->std.ce,
&new_obj TSRMLS_CC);
zend_objects_clone_members(&new_obj->std, new_ov, &old_obj->std,
Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC);
- new_obj->tz = old_obj->tz;
+ new_obj->type = old_obj->type;
+ new_obj->initialized = 1;
+ switch (new_obj->type) {
+ case TIMELIB_ZONETYPE_ID:
+ new_obj->tzi.tz = old_obj->tzi.tz;
+ break;
+ case TIMELIB_ZONETYPE_OFFSET:
+ new_obj->tzi.utc_offset = old_obj->tzi.utc_offset;
+ break;
+ case TIMELIB_ZONETYPE_ABBR:
+ new_obj->tzi.z.utc_offset = old_obj->tzi.z.utc_offset;
+ new_obj->tzi.z.dst = old_obj->tzi.z.dst;
+ new_obj->tzi.z.abbr = old_obj->tzi.z.abbr;
+ break;
+ }
return new_ov;
}
@@ -1614,6 +1658,9 @@
{
php_timezone_obj *intern = (php_timezone_obj *)object;
+ if (intern->type == TIMELIB_ZONETYPE_ABBR) {
+ free(intern->tzi.z.abbr);
+ }
zend_object_std_dtor(&intern->std TSRMLS_CC);
efree(object);
}
@@ -1632,12 +1679,14 @@
return object;
}
-static void date_initialize(php_date_obj *dateobj, /*const*/ char *time_str,
int time_str_len, zval *timezone_object TSRMLS_DC)
+static int date_initialize(php_date_obj *dateobj, /*const*/ char *time_str,
int time_str_len, zval *timezone_object, int ctor TSRMLS_DC)
{
timelib_time *now;
timelib_tzinfo *tzi;
timelib_error_container *err = NULL;
- int free_tzi = 0;
+ int free_tzi = 0, type = TIMELIB_ZONETYPE_ID, new_dst;
+ char *new_abbr;
+ timelib_sll new_offset;
if (dateobj->time) {
if (dateobj->time->tz_info) {
@@ -1647,7 +1696,7 @@
}
dateobj->time = timelib_strtotime(time_str_len ? time_str : "now",
time_str_len ? time_str_len : sizeof("now") -1, &err, DATE_TIMEZONEDB);
if (err) {
- if (err->error_count) {
+ if (ctor && err && err->error_count) {
/* spit out the first library error message, at least */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to
parse time string (%s) at position %d (%c): %s", time_str,
err->error_messages[0].position, err->error_messages[0].character,
err->error_messages[0].message);
@@ -1655,12 +1704,35 @@
timelib_error_container_dtor(err);
}
+
+ if (ctor && err && err->error_count) {
+ /* spit out the first library error message, at least */
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to parse
time string (%s) at position %d (%c): %s", time_str,
+ err->error_messages[0].position,
err->error_messages[0].character, err->error_messages[0].message);
+ }
+ if (err && err->error_count) {
+ return 0;
+ }
+
if (timezone_object) {
php_timezone_obj *tzobj;
tzobj = (php_timezone_obj *)
zend_object_store_get_object(timezone_object TSRMLS_CC);
- tzi = timelib_tzinfo_clone(tzobj->tz);
- free_tzi = 1;
+ switch (tzobj->type) {
+ case TIMELIB_ZONETYPE_ID:
+ tzi = timelib_tzinfo_clone(tzobj->tzi.tz);
+ free_tzi = 1;
+ break;
+ case TIMELIB_ZONETYPE_OFFSET:
+ new_offset = tzobj->tzi.utc_offset;
+ break;
+ case TIMELIB_ZONETYPE_ABBR:
+ new_offset = tzobj->tzi.z.utc_offset;
+ new_dst = tzobj->tzi.z.dst;
+ new_abbr = strdup(tzobj->tzi.z.abbr);
+ break;
+ }
+ type = tzobj->type;
} else if (dateobj->time->tz_info) {
tzi = timelib_tzinfo_clone(dateobj->time->tz_info);
free_tzi = 1;
@@ -1669,8 +1741,20 @@
}
now = timelib_time_ctor();
- now->tz_info = tzi;
- now->zone_type = TIMELIB_ZONETYPE_ID;
+ now->zone_type = type;
+ switch (type) {
+ case TIMELIB_ZONETYPE_ID:
+ now->tz_info = tzi;
+ break;
+ case TIMELIB_ZONETYPE_OFFSET:
+ now->z = new_offset;
+ break;
+ case TIMELIB_ZONETYPE_ABBR:
+ now->z = new_offset;
+ now->dst = new_dst;
+ now->tz_abbr = new_abbr;
+ break;
+ }
timelib_unixtime2local(now, (timelib_sll) time(NULL));
timelib_fill_holes(dateobj->time, now, 0);
@@ -1678,13 +1762,15 @@
dateobj->time->have_weekday_relative = dateobj->time->have_relative = 0;
- if (now->tz_info != tzi) {
+ if (type == TIMELIB_ZONETYPE_ID && now->tz_info != tzi) {
timelib_tzinfo_dtor(now->tz_info);
}
if (free_tzi) {
timelib_tzinfo_dtor(tzi);
}
- timelib_time_dtor(now);
+ timelib_time_dtor(now);
+
+ return 1;
}
/* {{{ proto DateTime date_create([string time[, DateTimeZone object]])
@@ -1701,7 +1787,9 @@
}
date_instantiate(date_ce_date, return_value TSRMLS_CC);
- date_initialize(zend_object_store_get_object(return_value TSRMLS_CC),
time_str, time_str_len, timezone_object TSRMLS_CC);
+ if (!date_initialize(zend_object_store_get_object(return_value
TSRMLS_CC), time_str, time_str_len, timezone_object, 0 TSRMLS_CC)) {
+ RETURN_FALSE;
+ }
}
/* }}} */
@@ -1716,7 +1804,7 @@
php_set_error_handling(EH_THROW, NULL TSRMLS_CC);
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO",
&time_str, &time_str_len, &timezone_object, date_ce_timezone)) {
- date_initialize(zend_object_store_get_object(getThis()
TSRMLS_CC), time_str, time_str_len, timezone_object TSRMLS_CC);
+ date_initialize(zend_object_store_get_object(getThis()
TSRMLS_CC), time_str, time_str_len, timezone_object, 1 TSRMLS_CC);
}
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
}
@@ -1889,10 +1977,24 @@
}
dateobj = (php_date_obj *) zend_object_store_get_object(object
TSRMLS_CC);
DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
- if (dateobj->time->is_localtime && dateobj->time->tz_info) {
+ if (dateobj->time->is_localtime/* && dateobj->time->tz_info*/) {
date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *)
zend_object_store_get_object(return_value TSRMLS_CC);
- tzobj->tz = timelib_tzinfo_clone(dateobj->time->tz_info);
+ tzobj->initialized = 1;
+ tzobj->type = dateobj->time->zone_type;
+ switch (dateobj->time->zone_type) {
+ case TIMELIB_ZONETYPE_ID:
+ tzobj->tzi.tz = dateobj->time->tz_info;
+ break;
+ case TIMELIB_ZONETYPE_OFFSET:
+ tzobj->tzi.utc_offset = dateobj->time->z;
+ break;
+ case TIMELIB_ZONETYPE_ABBR:
+ tzobj->tzi.z.utc_offset = dateobj->time->z;
+ tzobj->tzi.z.dst = dateobj->time->dst;
+ tzobj->tzi.z.abbr =
strdup(dateobj->time->tz_abbr);
+ break;
+ }
} else {
RETURN_FALSE;
}
@@ -1915,10 +2017,13 @@
dateobj = (php_date_obj *) zend_object_store_get_object(object
TSRMLS_CC);
DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
tzobj = (php_timezone_obj *)
zend_object_store_get_object(timezone_object TSRMLS_CC);
+ if (tzobj->type != TIMELIB_ZONETYPE_ID) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can only do this
for zones with ID for now");
+ }
if (dateobj->time->tz_info) {
timelib_tzinfo_dtor(dateobj->time->tz_info);
}
- timelib_set_timezone(dateobj->time, timelib_tzinfo_clone(tzobj->tz));
+ timelib_set_timezone(dateobj->time,
timelib_tzinfo_clone(tzobj->tzi.tz));
timelib_unixtime2local(dateobj->time, dateobj->time->sse);
}
/* }}} */
@@ -1937,10 +2042,20 @@
}
dateobj = (php_date_obj *) zend_object_store_get_object(object
TSRMLS_CC);
DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
- if (dateobj->time->is_localtime && dateobj->time->tz_info) {
- offset = timelib_get_time_zone_info(dateobj->time->sse,
dateobj->time->tz_info);
- RETVAL_LONG(offset->offset);
- timelib_time_offset_dtor(offset);
+ if (dateobj->time->is_localtime/* && dateobj->time->tz_info*/) {
+ switch (dateobj->time->zone_type) {
+ case TIMELIB_ZONETYPE_ID:
+ offset =
timelib_get_time_zone_info(dateobj->time->sse, dateobj->time->tz_info);
+ RETVAL_LONG(offset->offset);
+ timelib_time_offset_dtor(offset);
+ break;
+ case TIMELIB_ZONETYPE_OFFSET:
+ RETVAL_LONG(dateobj->time->z * -60);
+ break;
+ case TIMELIB_ZONETYPE_ABBR:
+ RETVAL_LONG((dateobj->time->z - (60 *
dateobj->time->dst)) * -60);
+ break;
+ }
return;
} else {
RETURN_LONG(0);
@@ -2042,6 +2157,7 @@
char *tz;
int tz_len;
timelib_tzinfo *tzi = NULL;
+ php_timezone_obj *tzobj;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &tz, &tz_len)
== FAILURE) {
RETURN_FALSE;
@@ -2049,7 +2165,9 @@
if (SUCCESS != timezone_initialize(&tzi, tz TSRMLS_CC)) {
RETURN_FALSE;
}
- ((php_timezone_obj *)
zend_object_store_get_object(date_instantiate(date_ce_timezone, return_value
TSRMLS_CC) TSRMLS_CC))->tz = tzi;
+ tzobj = zend_object_store_get_object(date_instantiate(date_ce_timezone,
return_value TSRMLS_CC) TSRMLS_CC);
+ tzobj->type = TIMELIB_ZONETYPE_ID;
+ tzobj->tzi.tz = tzi;
}
/* }}} */
@@ -2061,11 +2179,15 @@
char *tz;
int tz_len;
timelib_tzinfo *tzi = NULL;
+ php_timezone_obj *tzobj;
php_set_error_handling(EH_THROW, NULL TSRMLS_CC);
if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
&tz, &tz_len)) {
if (SUCCESS == timezone_initialize(&tzi, tz TSRMLS_CC)) {
- ((php_timezone_obj *)
zend_object_store_get_object(getThis() TSRMLS_CC))->tz = tzi;
+ tzobj = zend_object_store_get_object(getThis()
TSRMLS_CC);
+ tzobj->type = TIMELIB_ZONETYPE_ID;
+ tzobj->tzi.tz = tzi;
+ tzobj->initialized = 1;
} else {
ZVAL_NULL(getThis());
}
@@ -2086,9 +2208,28 @@
RETURN_FALSE;
}
tzobj = (php_timezone_obj *) zend_object_store_get_object(object
TSRMLS_CC);
- DATE_CHECK_INITIALIZED(tzobj->tz, DateTimeZone);
+ DATE_CHECK_INITIALIZED(tzobj->initialized, DateTimeZone);
+
+ switch (tzobj->type) {
+ case TIMELIB_ZONETYPE_ID:
+ RETURN_STRING(tzobj->tzi.tz->name, 1);
+ break;
+ case TIMELIB_ZONETYPE_OFFSET: {
+ char *tmpstr = emalloc(sizeof("UTC+05:00"));
+ timelib_sll utc_offset = tzobj->tzi.utc_offset;
+
+ snprintf(tmpstr, sizeof("+05:00"), "%c%02d:%02d",
+ utc_offset > 0 ? '-' : '+',
+ abs(utc_offset / 60),
+ abs((utc_offset % 60)));
- RETURN_STRING(tzobj->tz->name, 1);
+ RETURN_STRING(tmpstr, 0);
+ }
+ break;
+ case TIMELIB_ZONETYPE_ABBR:
+ RETURN_STRING(tzobj->tzi.z.abbr, 1);
+ break;
+ }
}
/* }}} */
@@ -2130,11 +2271,11 @@
RETURN_FALSE;
}
tzobj = (php_timezone_obj *) zend_object_store_get_object(object
TSRMLS_CC);
- DATE_CHECK_INITIALIZED(tzobj->tz, DateTimeZone);
+ DATE_CHECK_INITIALIZED(tzobj->initialized, DateTimeZone);
dateobj = (php_date_obj *) zend_object_store_get_object(dateobject
TSRMLS_CC);
DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
- offset = timelib_get_time_zone_info(dateobj->time->sse, tzobj->tz);
+ offset = timelib_get_time_zone_info(dateobj->time->sse, tzobj->tzi.tz);
RETVAL_LONG(offset->offset);
timelib_time_offset_dtor(offset);
}
@@ -2153,17 +2294,20 @@
RETURN_FALSE;
}
tzobj = (php_timezone_obj *) zend_object_store_get_object(object
TSRMLS_CC);
- DATE_CHECK_INITIALIZED(tzobj->tz, DateTimeZone);
+ DATE_CHECK_INITIALIZED(tzobj->initialized, DateTimeZone);
+ if (tzobj->type != TIMELIB_ZONETYPE_ID) {
+ RETURN_FALSE;
+ }
array_init(return_value);
- for (i = 0; i < tzobj->tz->timecnt; ++i) {
+ for (i = 0; i < tzobj->tzi.tz->timecnt; ++i) {
MAKE_STD_ZVAL(element);
array_init(element);
- add_assoc_long(element, "ts", tzobj->tz->trans[i]);
- add_assoc_string(element, "time",
php_format_date(DATE_FORMAT_ISO8601, 13, tzobj->tz->trans[i], 0 TSRMLS_CC), 0);
- add_assoc_long(element, "offset",
tzobj->tz->type[tzobj->tz->trans_idx[i]].offset);
- add_assoc_bool(element, "isdst",
tzobj->tz->type[tzobj->tz->trans_idx[i]].isdst);
- add_assoc_string(element, "abbr",
&tzobj->tz->timezone_abbr[tzobj->tz->type[tzobj->tz->trans_idx[i]].abbr_idx],
1);
+ add_assoc_long(element, "ts", tzobj->tzi.tz->trans[i]);
+ add_assoc_string(element, "time",
php_format_date(DATE_FORMAT_ISO8601, 13, tzobj->tzi.tz->trans[i], 0 TSRMLS_CC),
0);
+ add_assoc_long(element, "offset",
tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].offset);
+ add_assoc_bool(element, "isdst",
tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].isdst);
+ add_assoc_string(element, "abbr",
&tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].abbr_idx],
1);
add_next_index_zval(return_value, element);
}
http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/parse_date.c?r1=1.29.2.30.2.14&r2=1.29.2.30.2.15&diff_format=u
Index: php-src/ext/date/lib/parse_date.c
diff -u php-src/ext/date/lib/parse_date.c:1.29.2.30.2.14
php-src/ext/date/lib/parse_date.c:1.29.2.30.2.15
--- php-src/ext/date/lib/parse_date.c:1.29.2.30.2.14 Thu Jul 12 18:59:55 2007
+++ php-src/ext/date/lib/parse_date.c Sat Jan 26 16:26:33 2008
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.12.1 on Thu Jul 12 19:32:22 2007 */
+/* Generated by re2c 0.12.1 on Sat Jan 26 16:10:48 2008 */
#line 1 "ext/date/lib/parse_date.re"
/*
+----------------------------------------------------------------------+
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: parse_date.c,v 1.29.2.30.2.14 2007/07/12 18:59:55 derick Exp $ */
+/* $Id: parse_date.c,v 1.29.2.30.2.15 2008/01/26 16:26:33 derick Exp $ */
#include "timelib.h"
http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/tm2unixtime.c?r1=1.13.2.3.2.3&r2=1.13.2.3.2.4&diff_format=u
Index: php-src/ext/date/lib/tm2unixtime.c
diff -u php-src/ext/date/lib/tm2unixtime.c:1.13.2.3.2.3
php-src/ext/date/lib/tm2unixtime.c:1.13.2.3.2.4
--- php-src/ext/date/lib/tm2unixtime.c:1.13.2.3.2.3 Mon Dec 31 07:20:05 2007
+++ php-src/ext/date/lib/tm2unixtime.c Sat Jan 26 16:26:47 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: tm2unixtime.c,v 1.13.2.3.2.3 2007/12/31 07:20:05 sebastian Exp $ */
+/* $Id: tm2unixtime.c,v 1.13.2.3.2.4 2008/01/26 16:26:47 derick Exp $ */
#include "timelib.h"
@@ -98,6 +98,7 @@
} else {
time->d -= (7 - (abs(time->relative.weekday) - current_dow));
}
+ time->have_weekday_relative = 0;
}
static void do_normalize(timelib_time* time)
@@ -130,6 +131,7 @@
do_normalize(time);
memset(&(time->relative), 0, sizeof(time->relative));
+ time->have_relative = 0;
}
static void do_adjust_special_weekday(timelib_time* time)
http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/bug40743.phpt?view=markup&rev=1.1
Index: php-src/ext/date/tests/bug40743.phpt
+++ php-src/ext/date/tests/bug40743.phpt
--TEST--
Bug #40743 (DateTime ignores the TimeZone object passed to the constructor)
--FILE--
<?php
$dt = new DateTime('@1200506699', new DateTimeZone('Europe/Berlin'));
echo $dt->format(DATE_RFC822), "\n";
echo $dt->format('T e Z'), "\n";
echo "-----\n";
date_default_timezone_set('America/New_York');
$dt = new DateTime('16 Jan 08 13:04:59');
echo $dt->format(DATE_RFC822 . " e T O U"), "\n";
$dt = new DateTime('@1200506699');
echo $dt->format(DATE_RFC822 . " e T O U"), "\n";
$dt = new DateTime('@1200506699');
$dt->setTimezone( new DateTimeZone( 'America/New_York' ) );
echo $dt->format(DATE_RFC822 . " e T O U"), "\n";
$dt = new DateTime('@1200506699', new DateTimeZone('Europe/Berlin'));
echo $dt->format(DATE_RFC822 . " e T O U"), "\n";
$dt = new DateTime('16 Jan 08 13:04:59 America/Chicago');
echo $dt->format(DATE_RFC822 . " e T O U"), "\n";
$dt = new DateTime('16 Jan 08 13:04:59 America/Chicago', new
DateTimeZone('Europe/Berlin'));
echo $dt->format(DATE_RFC822 . " e T O U"), "\n";
?>
--EXPECT--
Wed, 16 Jan 08 18:04:59 +0000
GMT+0000 +00:00 0
-----
Wed, 16 Jan 08 13:04:59 -0500 America/New_York EST -0500 1200506699
Wed, 16 Jan 08 18:04:59 +0000 +00:00 GMT+0000 +0000 1200506699
Wed, 16 Jan 08 13:04:59 -0500 America/New_York EST -0500 1200506699
Wed, 16 Jan 08 18:04:59 +0000 +00:00 GMT+0000 +0000 1200506699
Wed, 16 Jan 08 13:04:59 -0600 America/Chicago CST -0600 1200510299
Wed, 16 Jan 08 13:04:59 -0600 America/Chicago CST -0600 1200510299
http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/bug41599.phpt?view=markup&rev=1.1
Index: php-src/ext/date/tests/bug41599.phpt
+++ php-src/ext/date/tests/bug41599.phpt
--TEST--
Bug #41599 (setTime() fails after modify() is used)
--FILE--
<?php
date_default_timezone_set('Europe/London');
$start = new DateTime('2008-01-17 last Monday');
echo $start->format('Y-m-d H:i:s'),PHP_EOL;
//good
$start->modify('Tuesday');
echo $start->format('Y-m-d H:i:s'),PHP_EOL;
//good
$start->setTime(4, 0, 0);
echo $start->format('Y-m-d H:i:s'),PHP_EOL;
//jumped to next Sunday
$start->setTime(8, 0, 0);
echo $start->format('Y-m-d H:i:s'),PHP_EOL;
//jumped to next Sunday again
?>
--EXPECT--
2008-01-14 00:00:00
2008-01-15 00:00:00
2008-01-15 04:00:00
2008-01-15 08:00:00
http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/bug42910.phpt?view=markup&rev=1.1
Index: php-src/ext/date/tests/bug42910.phpt
+++ php-src/ext/date/tests/bug42910.phpt
--TEST--
Bug #42910 (Constructing DateTime with TimeZone Indicator invalidates
DateTimeZone)
--FILE--
<?php
date_default_timezone_set('America/Los_Angeles');
$foo = new DateTime('2007-03-11');
$bar = new DateTime('2007-03-11T00:00:00-0800');
print $foo->format(DateTime::ISO8601) . ' - ' .
$foo->getTimezone()->getName() . ' - ' . $foo->format('U') . "\r\n";
print $bar->format(DateTime::ISO8601) . ' - ' .
$bar->getTimezone()->getName() . ' - ' . $bar->format('U') . "\r\n";
$foo->setDate(2007, 03, 12);
$bar->setDate(2007, 03, 12);
print $foo->format(DateTime::ISO8601) . ' - ' .
$foo->getTimezone()->getName() . ' - ' . $foo->format('U') . "\r\n";
print $bar->format(DateTime::ISO8601) . ' - ' .
$bar->getTimezone()->getName() . ' - ' . $bar->format('U') . "\r\n";
// --------------
date_default_timezone_set('Australia/Sydney');
$date= date_create('2007-11-04 12:00:00+0200');
var_dump(date_format($date, 'O e'));
?>
--EXPECT--
2007-03-11T00:00:00-0800 - America/Los_Angeles - 1173600000
2007-03-11T00:00:00-0800 - -08:00 - 1173600000
2007-03-12T00:00:00-0700 - America/Los_Angeles - 1173682800
2007-03-12T00:00:00-0800 - -08:00 - 1173686400
string(12) "+0200 +02:00"
--UEXPECT--
2007-03-11T00:00:00-0800 - America/Los_Angeles - 1173600000
2007-03-11T00:00:00-0800 - -08:00 - 1173600000
2007-03-12T00:00:00-0700 - America/Los_Angeles - 1173682800
2007-03-12T00:00:00-0800 - -08:00 - 1173686400
unicode(12) "+0200 +02:00"
http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/bug43003.phpt?view=markup&rev=1.1
Index: php-src/ext/date/tests/bug43003.phpt
+++ php-src/ext/date/tests/bug43003.phpt
--TEST--
Bug #43003 (Invalid timezone reported for DateTime objects constructed using a
timestamp)
--FILE--
<?php
$oDateTest = new DateTime("@0", new DateTimeZone(date_default_timezone_get()));
echo $oDateTest->getTimezone()->getName().": " . $oDateTest->format("Y-m-d
H:i:s")."\n";
$oDateTest->setTimezone(new DateTimeZone("UTC"));
echo $oDateTest->getTimezone()->getName().": " . $oDateTest->format("Y-m-d
H:i:s")."\n";
$oDateTest->setTimezone(new DateTimeZone(date_default_timezone_get()));
echo $oDateTest->getTimezone()->getName().": " . $oDateTest->format("Y-m-d
H:i:s")."\n";
$oDateTest = new DateTime("@0");
echo $oDateTest->getTimezone()->getName().": " . $oDateTest->format("Y-m-d
H:i:s")."\n";
$oDateTest->setTimezone( new DateTimeZone(date_default_timezone_get()));
echo $oDateTest->getTimezone()->getName().": " . $oDateTest->format("Y-m-d
H:i:s")."\n";
?>
--EXPECT--
+00:00: 1970-01-01 00:00:00
UTC: 1970-01-01 00:00:00
Europe/Oslo: 1970-01-01 01:00:00
+00:00: 1970-01-01 00:00:00
Europe/Oslo: 1970-01-01 01:00:00
http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/bug43527.phpt?view=markup&rev=1.1
Index: php-src/ext/date/tests/bug43527.phpt
+++ php-src/ext/date/tests/bug43527.phpt
--TEST--
Bug #43527 (DateTime created from a timestamp reports environment timezone)
--FILE--
<?php
date_default_timezone_set("Etc/GMT+1");
$datetime = new DateTime('Fri, 07 Dec 2007 19:05:14 +1000');
echo $datetime->getTimezone()->getName(), "\n";
?>
--EXPECT--
+10:00
http://cvs.php.net/viewvc.cgi/php-src/ext/date/tests/bug43808.phpt?view=markup&rev=1.1
Index: php-src/ext/date/tests/bug43808.phpt
+++ php-src/ext/date/tests/bug43808.phpt
--TEST--
Bug #43808 (date_create never fails (even when it should))
--FILE--
<?php
$date = date_create('asdfasdf');
if ($date instanceof DateTime) {
echo "this is wrong, should be bool";
}
var_dump( $date );
var_dump( DateTime::getLastErrors() );
var_dump( date_get_last_errors() );
?>
--EXPECT--
bool(false)
array(4) {
["warning_count"]=>
int(1)
["warnings"]=>
array(1) {
[6]=>
string(29) "Double timezone specification"
}
["error_count"]=>
int(1)
["errors"]=>
array(1) {
[0]=>
string(47) "The timezone could not be found in the database"
}
}
array(4) {
["warning_count"]=>
int(1)
["warnings"]=>
array(1) {
[6]=>
string(29) "Double timezone specification"
}
["error_count"]=>
int(1)
["errors"]=>
array(1) {
[0]=>
string(47) "The timezone could not be found in the database"
}
}
--UEXPECT--
bool(false)
array(4) {
[u"warning_count"]=>
int(1)
[u"warnings"]=>
array(1) {
[6]=>
string(29) "Double timezone specification"
}
[u"error_count"]=>
int(1)
[u"errors"]=>
array(1) {
[0]=>
string(47) "The timezone could not be found in the database"
}
}
array(4) {
[u"warning_count"]=>
int(1)
[u"warnings"]=>
array(1) {
[6]=>
string(29) "Double timezone specification"
}
[u"error_count"]=>
int(1)
[u"errors"]=>
array(1) {
[0]=>
string(47) "The timezone could not be found in the database"
}
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php