summaryrefslogtreecommitdiff
path: root/ext/date
diff options
context:
space:
mode:
Diffstat (limited to 'ext/date')
-rw-r--r--ext/date/TODO1
-rw-r--r--ext/date/lib/parse_date.c234
-rw-r--r--ext/date/lib/parse_date.re38
-rw-r--r--ext/date/lib/parse_iso_intervals.c71
-rw-r--r--ext/date/lib/parse_iso_intervals.re35
-rw-r--r--ext/date/lib/timelib.c34
-rw-r--r--ext/date/lib/timelib.h2
-rw-r--r--ext/date/lib/tm2unixtime.c75
-rw-r--r--ext/date/php_date.c754
-rw-r--r--ext/date/php_date.h17
-rw-r--r--ext/date/tests/014.phpt6
-rw-r--r--ext/date/tests/DatePeriod_wrong_constructor.phpt4
-rw-r--r--ext/date/tests/DateTimeZone_clone_basic1.phpt12
-rw-r--r--ext/date/tests/DateTimeZone_clone_basic2.phpt24
-rw-r--r--ext/date/tests/DateTimeZone_clone_basic3.phpt30
-rw-r--r--ext/date/tests/DateTimeZone_construct_basic.phpt18
-rw-r--r--ext/date/tests/DateTimeZone_serialize_type_1.phpt35
-rw-r--r--ext/date/tests/DateTimeZone_serialize_type_2.phpt35
-rw-r--r--ext/date/tests/DateTimeZone_serialize_type_3.phpt (renamed from ext/date/tests/DateTimeZone_serialize.phpt)20
-rw-r--r--ext/date/tests/DateTimeZone_verify.phpt28
-rw-r--r--ext/date/tests/bug60774.phpt44
-rw-r--r--ext/date/tests/bug61642.phpt62
-rw-r--r--ext/date/tests/bug65184.phpt28
-rw-r--r--ext/date/tests/bug65502.phpt12
-rw-r--r--ext/date/tests/bug65548.phpt34
-rw-r--r--ext/date/tests/date_format_error.phpt6
-rw-r--r--ext/date/tests/date_format_variation1.phpt60
-rw-r--r--ext/date/tests/date_offset_get_error.phpt10
-rw-r--r--ext/date/tests/date_offset_get_variation1.phpt60
-rw-r--r--ext/date/tests/date_period-immutable.phpt56
-rw-r--r--ext/date/tests/date_time_immutable-inherited.phpt25
-rw-r--r--ext/date/tests/date_time_immutable.phpt167
-rw-r--r--ext/date/tests/date_timestamp_get.phpt2
-rw-r--r--ext/date/tests/date_timezone_get_error.phpt12
-rw-r--r--ext/date/tests/date_timezone_get_variation1.phpt62
-rw-r--r--ext/date/tests/timezone_open_basic1.phpt18
36 files changed, 1579 insertions, 552 deletions
diff --git a/ext/date/TODO b/ext/date/TODO
index 4b1237c4a9..a585b05516 100644
--- a/ext/date/TODO
+++ b/ext/date/TODO
@@ -1,6 +1,5 @@
- Port over my 200 test cases to .phpt format.
- Write an error handler for unexpected characters while parsing dates.
- Cache lookups for timezone information.
-- Optimize parsing @ with a negative timestamp.
- Make sure that date_default_timezone_set() validates the passed timezone
identifier.
diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c
index f510a665e8..0e99e231d6 100644
--- a/ext/date/lib/parse_date.c
+++ b/ext/date/lib/parse_date.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Sun Aug 25 14:46:08 2013 */
+/* Generated by re2c 0.13.5 on Sun Aug 25 15:12:48 2013 */
#line 1 "ext/date/lib/parse_date.re"
/*
+----------------------------------------------------------------------+
@@ -170,8 +170,6 @@ typedef struct _timelib_relunit {
int multiplier;
} timelib_relunit;
-#define HOUR(a) (int)(a * 60)
-
/* The timezone table. */
const static timelib_tz_lookup_table timelib_timezone_lookup[] = {
#include "timezonemap.h"
@@ -532,39 +530,6 @@ static timelib_ull timelib_get_unsigned_nr(char **ptr, int max_length)
return dir * timelib_get_nr(ptr, max_length);
}
-static long timelib_parse_tz_cor(char **ptr)
-{
- char *begin = *ptr, *end;
- long tmp;
-
- while (isdigit(**ptr) || **ptr == ':') {
- ++*ptr;
- }
- end = *ptr;
- switch (end - begin) {
- case 1:
- case 2:
- return HOUR(strtol(begin, NULL, 10));
- break;
- case 3:
- case 4:
- if (begin[1] == ':') {
- tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 2, NULL, 10);
- return tmp;
- } else if (begin[2] == ':') {
- tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
- return tmp;
- } else {
- tmp = strtol(begin, NULL, 10);
- return HOUR(tmp / 100) + tmp % 100;
- }
- case 5:
- tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
- return tmp;
- }
- return 0;
-}
-
static timelib_sll timelib_lookup_relative_text(char **ptr, int *behavior)
{
char *word;
@@ -872,11 +837,11 @@ static int scan(Scanner *s, timelib_tz_get_wrapper tz_get_wrapper)
std:
s->tok = cursor;
s->len = 0;
-#line 998 "ext/date/lib/parse_date.re"
+#line 963 "ext/date/lib/parse_date.re"
-#line 880 "ext/date/lib/parse_date.c"
+#line 845 "ext/date/lib/parse_date.c"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
@@ -996,7 +961,7 @@ std:
}
yy2:
YYDEBUG(2, *YYCURSOR);
-#line 1084 "ext/date/lib/parse_date.re"
+#line 1049 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("firstdayof | lastdayof");
TIMELIB_INIT;
@@ -1012,7 +977,7 @@ yy2:
TIMELIB_DEINIT;
return TIMELIB_LF_DAY_OF_MONTH;
}
-#line 1016 "ext/date/lib/parse_date.c"
+#line 981 "ext/date/lib/parse_date.c"
yy3:
YYDEBUG(3, *YYCURSOR);
++YYCURSOR;
@@ -1035,7 +1000,7 @@ yy3:
}
yy4:
YYDEBUG(4, *YYCURSOR);
-#line 1678 "ext/date/lib/parse_date.re"
+#line 1643 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("tzcorrection | tz");
@@ -1048,7 +1013,7 @@ yy4:
TIMELIB_DEINIT;
return TIMELIB_TIMEZONE;
}
-#line 1052 "ext/date/lib/parse_date.c"
+#line 1017 "ext/date/lib/parse_date.c"
yy5:
YYDEBUG(5, *YYCURSOR);
yych = *++YYCURSOR;
@@ -1359,12 +1324,12 @@ yy12:
if (yych <= '9') goto yy1385;
yy13:
YYDEBUG(13, *YYCURSOR);
-#line 1773 "ext/date/lib/parse_date.re"
+#line 1738 "ext/date/lib/parse_date.re"
{
add_error(s, "Unexpected character");
goto std;
}
-#line 1368 "ext/date/lib/parse_date.c"
+#line 1333 "ext/date/lib/parse_date.c"
yy14:
YYDEBUG(14, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2421,11 +2386,11 @@ yy49:
if (yych <= '9') goto yy55;
yy50:
YYDEBUG(50, *YYCURSOR);
-#line 1762 "ext/date/lib/parse_date.re"
+#line 1727 "ext/date/lib/parse_date.re"
{
goto std;
}
-#line 2429 "ext/date/lib/parse_date.c"
+#line 2394 "ext/date/lib/parse_date.c"
yy51:
YYDEBUG(51, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2434,12 +2399,12 @@ yy52:
YYDEBUG(52, *YYCURSOR);
++YYCURSOR;
YYDEBUG(53, *YYCURSOR);
-#line 1767 "ext/date/lib/parse_date.re"
+#line 1732 "ext/date/lib/parse_date.re"
{
s->pos = cursor; s->line++;
goto std;
}
-#line 2443 "ext/date/lib/parse_date.c"
+#line 2408 "ext/date/lib/parse_date.c"
yy54:
YYDEBUG(54, *YYCURSOR);
yych = *++YYCURSOR;
@@ -2826,7 +2791,7 @@ yy72:
if (yych == 's') goto yy74;
yy73:
YYDEBUG(73, *YYCURSOR);
-#line 1746 "ext/date/lib/parse_date.re"
+#line 1711 "ext/date/lib/parse_date.re"
{
timelib_ull i;
DEBUG_OUTPUT("relative");
@@ -2841,7 +2806,7 @@ yy73:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 2845 "ext/date/lib/parse_date.c"
+#line 2810 "ext/date/lib/parse_date.c"
yy74:
YYDEBUG(74, *YYCURSOR);
yych = *++YYCURSOR;
@@ -3603,7 +3568,7 @@ yy166:
}
yy167:
YYDEBUG(167, *YYCURSOR);
-#line 1609 "ext/date/lib/parse_date.re"
+#line 1574 "ext/date/lib/parse_date.re"
{
const timelib_relunit* relunit;
DEBUG_OUTPUT("daytext");
@@ -3620,7 +3585,7 @@ yy167:
TIMELIB_DEINIT;
return TIMELIB_WEEKDAY;
}
-#line 3624 "ext/date/lib/parse_date.c"
+#line 3589 "ext/date/lib/parse_date.c"
yy168:
YYDEBUG(168, *YYCURSOR);
yych = *++YYCURSOR;
@@ -4140,7 +4105,7 @@ yy193:
}
yy194:
YYDEBUG(194, *YYCURSOR);
-#line 1668 "ext/date/lib/parse_date.re"
+#line 1633 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("monthtext");
TIMELIB_INIT;
@@ -4149,7 +4114,7 @@ yy194:
TIMELIB_DEINIT;
return TIMELIB_DATE_TEXT;
}
-#line 4153 "ext/date/lib/parse_date.c"
+#line 4118 "ext/date/lib/parse_date.c"
yy195:
YYDEBUG(195, *YYCURSOR);
++YYCURSOR;
@@ -4200,7 +4165,7 @@ yy198:
}
yy199:
YYDEBUG(199, *YYCURSOR);
-#line 1414 "ext/date/lib/parse_date.re"
+#line 1379 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("datetextual | datenoyear");
@@ -4213,7 +4178,7 @@ yy199:
TIMELIB_DEINIT;
return TIMELIB_DATE_TEXT;
}
-#line 4217 "ext/date/lib/parse_date.c"
+#line 4182 "ext/date/lib/parse_date.c"
yy200:
YYDEBUG(200, *YYCURSOR);
yyaccept = 6;
@@ -4482,7 +4447,7 @@ yy222:
}
yy223:
YYDEBUG(223, *YYCURSOR);
-#line 1716 "ext/date/lib/parse_date.re"
+#line 1681 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("dateshortwithtimeshort | dateshortwithtimelong | dateshortwithtimelongtz");
@@ -4511,7 +4476,7 @@ yy223:
TIMELIB_DEINIT;
return TIMELIB_SHORTDATE_WITH_TIME;
}
-#line 4515 "ext/date/lib/parse_date.c"
+#line 4480 "ext/date/lib/parse_date.c"
yy224:
YYDEBUG(224, *YYCURSOR);
yyaccept = 7;
@@ -5209,7 +5174,7 @@ yy278:
YYDEBUG(278, *YYCURSOR);
++YYCURSOR;
YYDEBUG(279, *YYCURSOR);
-#line 1692 "ext/date/lib/parse_date.re"
+#line 1657 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("dateshortwithtimeshort12 | dateshortwithtimelong12");
TIMELIB_INIT;
@@ -5232,7 +5197,7 @@ yy278:
TIMELIB_DEINIT;
return TIMELIB_SHORTDATE_WITH_TIME;
}
-#line 5236 "ext/date/lib/parse_date.c"
+#line 5201 "ext/date/lib/parse_date.c"
yy280:
YYDEBUG(280, *YYCURSOR);
yych = *++YYCURSOR;
@@ -5410,7 +5375,7 @@ yy294:
++YYCURSOR;
yy295:
YYDEBUG(295, *YYCURSOR);
-#line 1386 "ext/date/lib/parse_date.re"
+#line 1351 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("datenoday");
@@ -5423,7 +5388,7 @@ yy295:
TIMELIB_DEINIT;
return TIMELIB_DATE_NO_DAY;
}
-#line 5427 "ext/date/lib/parse_date.c"
+#line 5392 "ext/date/lib/parse_date.c"
yy296:
YYDEBUG(296, *YYCURSOR);
yych = *++YYCURSOR;
@@ -6643,7 +6608,7 @@ yy362:
if (yych <= '9') goto yy365;
yy364:
YYDEBUG(364, *YYCURSOR);
-#line 1530 "ext/date/lib/parse_date.re"
+#line 1495 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("pgtextshort");
@@ -6656,7 +6621,7 @@ yy364:
TIMELIB_DEINIT;
return TIMELIB_PG_TEXT;
}
-#line 6660 "ext/date/lib/parse_date.c"
+#line 6625 "ext/date/lib/parse_date.c"
yy365:
YYDEBUG(365, *YYCURSOR);
yych = *++YYCURSOR;
@@ -7294,7 +7259,7 @@ yy392:
}
yy393:
YYDEBUG(393, *YYCURSOR);
-#line 1588 "ext/date/lib/parse_date.re"
+#line 1553 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("ago");
TIMELIB_INIT;
@@ -7314,7 +7279,7 @@ yy393:
TIMELIB_DEINIT;
return TIMELIB_AGO;
}
-#line 7318 "ext/date/lib/parse_date.c"
+#line 7283 "ext/date/lib/parse_date.c"
yy394:
YYDEBUG(394, *YYCURSOR);
yyaccept = 5;
@@ -9064,7 +9029,7 @@ yy454:
++YYCURSOR;
yy455:
YYDEBUG(455, *YYCURSOR);
-#line 1291 "ext/date/lib/parse_date.re"
+#line 1256 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("iso8601date4 | iso8601date2 | iso8601dateslash | dateslash");
TIMELIB_INIT;
@@ -9075,7 +9040,7 @@ yy455:
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
-#line 9079 "ext/date/lib/parse_date.c"
+#line 9044 "ext/date/lib/parse_date.c"
yy456:
YYDEBUG(456, *YYCURSOR);
yyaccept = 0;
@@ -9635,7 +9600,7 @@ yy475:
}
yy476:
YYDEBUG(476, *YYCURSOR);
-#line 1428 "ext/date/lib/parse_date.re"
+#line 1393 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("datenoyearrev");
TIMELIB_INIT;
@@ -9646,7 +9611,7 @@ yy476:
TIMELIB_DEINIT;
return TIMELIB_DATE_TEXT;
}
-#line 9650 "ext/date/lib/parse_date.c"
+#line 9615 "ext/date/lib/parse_date.c"
yy477:
YYDEBUG(477, *YYCURSOR);
yyaccept = 10;
@@ -9787,7 +9752,7 @@ yy488:
YYDEBUG(488, *YYCURSOR);
++YYCURSOR;
YYDEBUG(489, *YYCURSOR);
-#line 1146 "ext/date/lib/parse_date.re"
+#line 1111 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("timetiny12 | timeshort12 | timelong12");
TIMELIB_INIT;
@@ -9803,7 +9768,7 @@ yy488:
TIMELIB_DEINIT;
return TIMELIB_TIME12;
}
-#line 9807 "ext/date/lib/parse_date.c"
+#line 9772 "ext/date/lib/parse_date.c"
yy490:
YYDEBUG(490, *YYCURSOR);
yyaccept = 11;
@@ -9816,7 +9781,7 @@ yy490:
}
yy491:
YYDEBUG(491, *YYCURSOR);
-#line 1183 "ext/date/lib/parse_date.re"
+#line 1148 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("timeshort24 | timelong24 | iso8601long");
@@ -9841,7 +9806,7 @@ yy491:
TIMELIB_DEINIT;
return TIMELIB_TIME24_WITH_ZONE;
}
-#line 9845 "ext/date/lib/parse_date.c"
+#line 9810 "ext/date/lib/parse_date.c"
yy492:
YYDEBUG(492, *YYCURSOR);
yyaccept = 11;
@@ -10151,7 +10116,7 @@ yy523:
YYDEBUG(523, *YYCURSOR);
++YYCURSOR;
YYDEBUG(524, *YYCURSOR);
-#line 1163 "ext/date/lib/parse_date.re"
+#line 1128 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("mssqltime");
TIMELIB_INIT;
@@ -10170,7 +10135,7 @@ yy523:
TIMELIB_DEINIT;
return TIMELIB_TIME24_WITH_ZONE;
}
-#line 10174 "ext/date/lib/parse_date.c"
+#line 10139 "ext/date/lib/parse_date.c"
yy525:
YYDEBUG(525, *YYCURSOR);
yyaccept = 11;
@@ -10276,7 +10241,7 @@ yy534:
if (yych <= '9') goto yy541;
yy535:
YYDEBUG(535, *YYCURSOR);
-#line 1345 "ext/date/lib/parse_date.re"
+#line 1310 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("datefull");
@@ -10290,7 +10255,7 @@ yy535:
TIMELIB_DEINIT;
return TIMELIB_DATE_FULL;
}
-#line 10294 "ext/date/lib/parse_date.c"
+#line 10259 "ext/date/lib/parse_date.c"
yy536:
YYDEBUG(536, *YYCURSOR);
yych = *++YYCURSOR;
@@ -11027,7 +10992,7 @@ yy605:
YYDEBUG(606, *YYCURSOR);
++YYCURSOR;
YYDEBUG(607, *YYCURSOR);
-#line 1360 "ext/date/lib/parse_date.re"
+#line 1325 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("pointed date YYYY");
TIMELIB_INIT;
@@ -11038,7 +11003,7 @@ yy605:
TIMELIB_DEINIT;
return TIMELIB_DATE_FULL_POINTED;
}
-#line 11042 "ext/date/lib/parse_date.c"
+#line 11007 "ext/date/lib/parse_date.c"
yy608:
YYDEBUG(608, *YYCURSOR);
yyaccept = 11;
@@ -11074,7 +11039,7 @@ yy611:
if (yych <= '9') goto yy605;
yy612:
YYDEBUG(612, *YYCURSOR);
-#line 1372 "ext/date/lib/parse_date.re"
+#line 1337 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("pointed date YY");
@@ -11087,7 +11052,7 @@ yy612:
TIMELIB_DEINIT;
return TIMELIB_DATE_FULL_POINTED;
}
-#line 11091 "ext/date/lib/parse_date.c"
+#line 11056 "ext/date/lib/parse_date.c"
yy613:
YYDEBUG(613, *YYCURSOR);
yyaccept = 11;
@@ -11728,7 +11693,7 @@ yy656:
}
yy657:
YYDEBUG(657, *YYCURSOR);
-#line 1331 "ext/date/lib/parse_date.re"
+#line 1296 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("gnudateshort");
@@ -11741,7 +11706,7 @@ yy657:
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
-#line 11745 "ext/date/lib/parse_date.c"
+#line 11710 "ext/date/lib/parse_date.c"
yy658:
YYDEBUG(658, *YYCURSOR);
yyaccept = 13;
@@ -11847,7 +11812,7 @@ yy666:
}
yy667:
YYDEBUG(667, *YYCURSOR);
-#line 1275 "ext/date/lib/parse_date.re"
+#line 1240 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("americanshort | american");
@@ -11862,7 +11827,7 @@ yy667:
TIMELIB_DEINIT;
return TIMELIB_AMERICAN;
}
-#line 11866 "ext/date/lib/parse_date.c"
+#line 11831 "ext/date/lib/parse_date.c"
yy668:
YYDEBUG(668, *YYCURSOR);
yyaccept = 14;
@@ -12095,7 +12060,7 @@ yy700:
if (yych <= ':') goto yy704;
yy701:
YYDEBUG(701, *YYCURSOR);
-#line 1558 "ext/date/lib/parse_date.re"
+#line 1523 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("clf");
@@ -12115,7 +12080,7 @@ yy701:
TIMELIB_DEINIT;
return TIMELIB_CLF;
}
-#line 12119 "ext/date/lib/parse_date.c"
+#line 12084 "ext/date/lib/parse_date.c"
yy702:
YYDEBUG(702, *YYCURSOR);
yych = *++YYCURSOR;
@@ -12667,7 +12632,7 @@ yy763:
}
yy764:
YYDEBUG(764, *YYCURSOR);
-#line 1303 "ext/date/lib/parse_date.re"
+#line 1268 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("iso8601date2");
@@ -12680,7 +12645,7 @@ yy764:
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
-#line 12684 "ext/date/lib/parse_date.c"
+#line 12649 "ext/date/lib/parse_date.c"
yy765:
YYDEBUG(765, *YYCURSOR);
yych = *++YYCURSOR;
@@ -12719,7 +12684,7 @@ yy771:
YYDEBUG(771, *YYCURSOR);
++YYCURSOR;
YYDEBUG(772, *YYCURSOR);
-#line 1544 "ext/date/lib/parse_date.re"
+#line 1509 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("pgtextreverse");
@@ -12732,7 +12697,7 @@ yy771:
TIMELIB_DEINIT;
return TIMELIB_PG_TEXT;
}
-#line 12736 "ext/date/lib/parse_date.c"
+#line 12701 "ext/date/lib/parse_date.c"
yy773:
YYDEBUG(773, *YYCURSOR);
yych = *++YYCURSOR;
@@ -12870,7 +12835,7 @@ yy783:
}
yy784:
YYDEBUG(784, *YYCURSOR);
-#line 1579 "ext/date/lib/parse_date.re"
+#line 1544 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("year4");
TIMELIB_INIT;
@@ -12878,7 +12843,7 @@ yy784:
TIMELIB_DEINIT;
return TIMELIB_CLF;
}
-#line 12882 "ext/date/lib/parse_date.c"
+#line 12847 "ext/date/lib/parse_date.c"
yy785:
YYDEBUG(785, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13029,7 +12994,7 @@ yy793:
}
yy794:
YYDEBUG(794, *YYCURSOR);
-#line 1400 "ext/date/lib/parse_date.re"
+#line 1365 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("datenodayrev");
@@ -13042,7 +13007,7 @@ yy794:
TIMELIB_DEINIT;
return TIMELIB_DATE_NO_DAY;
}
-#line 13046 "ext/date/lib/parse_date.c"
+#line 13011 "ext/date/lib/parse_date.c"
yy795:
YYDEBUG(795, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13257,7 +13222,7 @@ yy814:
if (yych <= '7') goto yy817;
yy815:
YYDEBUG(815, *YYCURSOR);
-#line 1511 "ext/date/lib/parse_date.re"
+#line 1476 "ext/date/lib/parse_date.re"
{
timelib_sll w, d;
DEBUG_OUTPUT("isoweek");
@@ -13275,7 +13240,7 @@ yy815:
TIMELIB_DEINIT;
return TIMELIB_ISO_WEEK;
}
-#line 13279 "ext/date/lib/parse_date.c"
+#line 13244 "ext/date/lib/parse_date.c"
yy816:
YYDEBUG(816, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13285,7 +13250,7 @@ yy817:
YYDEBUG(817, *YYCURSOR);
++YYCURSOR;
YYDEBUG(818, *YYCURSOR);
-#line 1492 "ext/date/lib/parse_date.re"
+#line 1457 "ext/date/lib/parse_date.re"
{
timelib_sll w, d;
DEBUG_OUTPUT("isoweekday");
@@ -13303,7 +13268,7 @@ yy817:
TIMELIB_DEINIT;
return TIMELIB_ISO_WEEK;
}
-#line 13307 "ext/date/lib/parse_date.c"
+#line 13272 "ext/date/lib/parse_date.c"
yy819:
YYDEBUG(819, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13367,7 +13332,7 @@ yy821:
}
yy822:
YYDEBUG(822, *YYCURSOR);
-#line 1478 "ext/date/lib/parse_date.re"
+#line 1443 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("pgydotd");
@@ -13380,7 +13345,7 @@ yy822:
TIMELIB_DEINIT;
return TIMELIB_PG_YEARDAY;
}
-#line 13384 "ext/date/lib/parse_date.c"
+#line 13349 "ext/date/lib/parse_date.c"
yy823:
YYDEBUG(823, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13483,7 +13448,7 @@ yy842:
++YYCURSOR;
yy843:
YYDEBUG(843, *YYCURSOR);
-#line 1452 "ext/date/lib/parse_date.re"
+#line 1417 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("xmlrpc | xmlrpcnocolon | soap | wddx | exif");
@@ -13508,7 +13473,7 @@ yy843:
TIMELIB_DEINIT;
return TIMELIB_XMLRPC_SOAP;
}
-#line 13512 "ext/date/lib/parse_date.c"
+#line 13477 "ext/date/lib/parse_date.c"
yy844:
YYDEBUG(844, *YYCURSOR);
yych = *++YYCURSOR;
@@ -13770,7 +13735,7 @@ yy848:
}
yy849:
YYDEBUG(849, *YYCURSOR);
-#line 1440 "ext/date/lib/parse_date.re"
+#line 1405 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("datenocolon");
TIMELIB_INIT;
@@ -13781,7 +13746,7 @@ yy849:
TIMELIB_DEINIT;
return TIMELIB_DATE_NOCOLON;
}
-#line 13785 "ext/date/lib/parse_date.c"
+#line 13750 "ext/date/lib/parse_date.c"
yy850:
YYDEBUG(850, *YYCURSOR);
yych = *++YYCURSOR;
@@ -14701,7 +14666,7 @@ yy973:
if (yych <= '9') goto yy996;
yy974:
YYDEBUG(974, *YYCURSOR);
-#line 1317 "ext/date/lib/parse_date.re"
+#line 1282 "ext/date/lib/parse_date.re"
{
int length = 0;
DEBUG_OUTPUT("gnudateshorter");
@@ -14714,7 +14679,7 @@ yy974:
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
-#line 14718 "ext/date/lib/parse_date.c"
+#line 14683 "ext/date/lib/parse_date.c"
yy975:
YYDEBUG(975, *YYCURSOR);
yyaccept = 22;
@@ -15723,7 +15688,7 @@ yy1066:
}
yy1068:
YYDEBUG(1068, *YYCURSOR);
-#line 1209 "ext/date/lib/parse_date.re"
+#line 1174 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("gnunocolon");
TIMELIB_INIT;
@@ -15745,7 +15710,7 @@ yy1068:
TIMELIB_DEINIT;
return TIMELIB_GNU_NOCOLON;
}
-#line 15749 "ext/date/lib/parse_date.c"
+#line 15714 "ext/date/lib/parse_date.c"
yy1069:
YYDEBUG(1069, *YYCURSOR);
yych = *++YYCURSOR;
@@ -15837,7 +15802,7 @@ yy1075:
}
yy1076:
YYDEBUG(1076, *YYCURSOR);
-#line 1255 "ext/date/lib/parse_date.re"
+#line 1220 "ext/date/lib/parse_date.re"
{
int tz_not_found;
DEBUG_OUTPUT("iso8601nocolon");
@@ -15856,7 +15821,7 @@ yy1076:
TIMELIB_DEINIT;
return TIMELIB_ISO_NOCOLON;
}
-#line 15860 "ext/date/lib/parse_date.c"
+#line 15825 "ext/date/lib/parse_date.c"
yy1077:
YYDEBUG(1077, *YYCURSOR);
yyaccept = 25;
@@ -16754,7 +16719,7 @@ yy1117:
}
yy1118:
YYDEBUG(1118, *YYCURSOR);
-#line 1651 "ext/date/lib/parse_date.re"
+#line 1616 "ext/date/lib/parse_date.re"
{
timelib_sll i;
int behavior = 0;
@@ -16770,7 +16735,7 @@ yy1118:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 16774 "ext/date/lib/parse_date.c"
+#line 16739 "ext/date/lib/parse_date.c"
yy1119:
YYDEBUG(1119, *YYCURSOR);
++YYCURSOR;
@@ -16821,7 +16786,7 @@ yy1126:
YYDEBUG(1126, *YYCURSOR);
++YYCURSOR;
YYDEBUG(1127, *YYCURSOR);
-#line 1124 "ext/date/lib/parse_date.re"
+#line 1089 "ext/date/lib/parse_date.re"
{
timelib_sll i;
int behavior = 0;
@@ -16842,7 +16807,7 @@ yy1126:
TIMELIB_DEINIT;
return TIMELIB_WEEK_DAY_OF_MONTH;
}
-#line 16846 "ext/date/lib/parse_date.c"
+#line 16811 "ext/date/lib/parse_date.c"
yy1128:
YYDEBUG(1128, *YYCURSOR);
yyaccept = 26;
@@ -16950,7 +16915,7 @@ yy1141:
}
yy1142:
YYDEBUG(1142, *YYCURSOR);
-#line 1627 "ext/date/lib/parse_date.re"
+#line 1592 "ext/date/lib/parse_date.re"
{
timelib_sll i;
int behavior = 0;
@@ -16973,7 +16938,7 @@ yy1142:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 16977 "ext/date/lib/parse_date.c"
+#line 16942 "ext/date/lib/parse_date.c"
yy1143:
YYDEBUG(1143, *YYCURSOR);
yych = *++YYCURSOR;
@@ -19650,7 +19615,7 @@ yy1294:
goto yy1298;
yy1295:
YYDEBUG(1295, *YYCURSOR);
-#line 1101 "ext/date/lib/parse_date.re"
+#line 1066 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("backof | frontof");
TIMELIB_INIT;
@@ -19672,7 +19637,7 @@ yy1295:
TIMELIB_DEINIT;
return TIMELIB_LF_DAY_OF_MONTH;
}
-#line 19676 "ext/date/lib/parse_date.c"
+#line 19641 "ext/date/lib/parse_date.c"
yy1296:
YYDEBUG(1296, *YYCURSOR);
yyaccept = 28;
@@ -21363,7 +21328,7 @@ yy1385:
if (yych <= '9') goto yy1385;
yy1387:
YYDEBUG(1387, *YYCURSOR);
-#line 1058 "ext/date/lib/parse_date.re"
+#line 1023 "ext/date/lib/parse_date.re"
{
timelib_ull i;
@@ -21388,7 +21353,7 @@ yy1387:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 21392 "ext/date/lib/parse_date.c"
+#line 21357 "ext/date/lib/parse_date.c"
yy1388:
YYDEBUG(1388, *YYCURSOR);
yych = *++YYCURSOR;
@@ -21824,7 +21789,7 @@ yy1416:
++YYCURSOR;
yy1417:
YYDEBUG(1417, *YYCURSOR);
-#line 1046 "ext/date/lib/parse_date.re"
+#line 1011 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("tomorrow");
TIMELIB_INIT;
@@ -21835,7 +21800,7 @@ yy1417:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 21839 "ext/date/lib/parse_date.c"
+#line 21804 "ext/date/lib/parse_date.c"
yy1418:
YYDEBUG(1418, *YYCURSOR);
yych = *++YYCURSOR;
@@ -21870,7 +21835,7 @@ yy1419:
}
yy1420:
YYDEBUG(1420, *YYCURSOR);
-#line 1036 "ext/date/lib/parse_date.re"
+#line 1001 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("midnight | today");
TIMELIB_INIT;
@@ -21879,7 +21844,7 @@ yy1420:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 21883 "ext/date/lib/parse_date.c"
+#line 21848 "ext/date/lib/parse_date.c"
yy1421:
YYDEBUG(1421, *YYCURSOR);
yych = *++YYCURSOR;
@@ -23891,7 +23856,7 @@ yy1499:
}
yy1500:
YYDEBUG(1500, *YYCURSOR);
-#line 1015 "ext/date/lib/parse_date.re"
+#line 980 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("now");
TIMELIB_INIT;
@@ -23899,7 +23864,7 @@ yy1500:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 23903 "ext/date/lib/parse_date.c"
+#line 23868 "ext/date/lib/parse_date.c"
yy1501:
YYDEBUG(1501, *YYCURSOR);
yych = *++YYCURSOR;
@@ -24038,7 +24003,7 @@ yy1507:
}
yy1508:
YYDEBUG(1508, *YYCURSOR);
-#line 1024 "ext/date/lib/parse_date.re"
+#line 989 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("noon");
TIMELIB_INIT;
@@ -24049,7 +24014,7 @@ yy1508:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 24053 "ext/date/lib/parse_date.c"
+#line 24018 "ext/date/lib/parse_date.c"
yy1509:
YYDEBUG(1509, *YYCURSOR);
yyaccept = 0;
@@ -24582,7 +24547,7 @@ yy1530:
++YYCURSOR;
yy1531:
YYDEBUG(1531, *YYCURSOR);
-#line 1003 "ext/date/lib/parse_date.re"
+#line 968 "ext/date/lib/parse_date.re"
{
DEBUG_OUTPUT("yesterday");
TIMELIB_INIT;
@@ -24593,7 +24558,7 @@ yy1531:
TIMELIB_DEINIT;
return TIMELIB_RELATIVE;
}
-#line 24597 "ext/date/lib/parse_date.c"
+#line 24562 "ext/date/lib/parse_date.c"
yy1532:
YYDEBUG(1532, *YYCURSOR);
yyaccept = 0;
@@ -24766,7 +24731,7 @@ yy1537:
goto yy1531;
}
}
-#line 1777 "ext/date/lib/parse_date.re"
+#line 1742 "ext/date/lib/parse_date.re"
}
@@ -24825,6 +24790,7 @@ timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container
in.tzdb = tzdb;
in.time->is_localtime = 0;
in.time->zone_type = 0;
+ in.time->relative.days = TIMELIB_UNSET;
do {
t = scan(&in, tz_get_wrapper);
@@ -25124,7 +25090,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
break;
case '\\': /* escaped char */
- fptr++;
+ ++fptr;
if (*ptr == *fptr) {
++ptr;
} else {
diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re
index df33508f50..6d91d9ada9 100644
--- a/ext/date/lib/parse_date.re
+++ b/ext/date/lib/parse_date.re
@@ -168,8 +168,6 @@ typedef struct _timelib_relunit {
int multiplier;
} timelib_relunit;
-#define HOUR(a) (int)(a * 60)
-
/* The timezone table. */
const static timelib_tz_lookup_table timelib_timezone_lookup[] = {
#include "timezonemap.h"
@@ -530,39 +528,6 @@ static timelib_ull timelib_get_unsigned_nr(char **ptr, int max_length)
return dir * timelib_get_nr(ptr, max_length);
}
-static long timelib_parse_tz_cor(char **ptr)
-{
- char *begin = *ptr, *end;
- long tmp;
-
- while (isdigit(**ptr) || **ptr == ':') {
- ++*ptr;
- }
- end = *ptr;
- switch (end - begin) {
- case 1:
- case 2:
- return HOUR(strtol(begin, NULL, 10));
- break;
- case 3:
- case 4:
- if (begin[1] == ':') {
- tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 2, NULL, 10);
- return tmp;
- } else if (begin[2] == ':') {
- tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
- return tmp;
- } else {
- tmp = strtol(begin, NULL, 10);
- return HOUR(tmp / 100) + tmp % 100;
- }
- case 5:
- tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
- return tmp;
- }
- return 0;
-}
-
static timelib_sll timelib_lookup_relative_text(char **ptr, int *behavior)
{
char *word;
@@ -1832,6 +1797,7 @@ timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container
in.tzdb = tzdb;
in.time->is_localtime = 0;
in.time->zone_type = 0;
+ in.time->relative.days = TIMELIB_UNSET;
do {
t = scan(&in, tz_get_wrapper);
@@ -2131,7 +2097,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
break;
case '\\': /* escaped char */
- fptr++;
+ ++fptr;
if (*ptr == *fptr) {
++ptr;
} else {
diff --git a/ext/date/lib/parse_iso_intervals.c b/ext/date/lib/parse_iso_intervals.c
index 480ea38d91..e669c855a4 100644
--- a/ext/date/lib/parse_iso_intervals.c
+++ b/ext/date/lib/parse_iso_intervals.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Wed Nov 27 11:10:58 2013 */
+/* Generated by re2c 0.13.5 on Wed Nov 27 11:14:23 2013 */
#line 1 "ext/date/lib/parse_iso_intervals.re"
/*
+----------------------------------------------------------------------+
@@ -104,8 +104,6 @@ typedef struct Scanner {
int have_end_date;
} Scanner;
-#define HOUR(a) (int)(a * 60)
-
static void add_warning(Scanner *s, char *error)
{
s->errors->warning_count++;
@@ -178,39 +176,6 @@ static timelib_ull timelib_get_unsigned_nr(char **ptr, int max_length)
return dir * timelib_get_nr(ptr, max_length);
}
-static long timelib_parse_tz_cor(char **ptr)
-{
- char *begin = *ptr, *end;
- long tmp;
-
- while (isdigit(**ptr) || **ptr == ':') {
- ++*ptr;
- }
- end = *ptr;
- switch (end - begin) {
- case 1:
- case 2:
- return HOUR(strtol(begin, NULL, 10));
- break;
- case 3:
- case 4:
- if (begin[1] == ':') {
- tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 2, NULL, 10);
- return tmp;
- } else if (begin[2] == ':') {
- tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
- return tmp;
- } else {
- tmp = strtol(begin, NULL, 10);
- return HOUR(tmp / 100) + tmp % 100;
- }
- case 5:
- tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
- return tmp;
- }
- return 0;
-}
-
static void timelib_eat_spaces(char **ptr)
{
while (**ptr == ' ' || **ptr == '\t') {
@@ -283,11 +248,11 @@ static int scan(Scanner *s)
std:
s->tok = cursor;
s->len = 0;
-#line 311 "ext/date/lib/parse_iso_intervals.re"
+#line 276 "ext/date/lib/parse_iso_intervals.re"
-#line 291 "ext/date/lib/parse_iso_intervals.c"
+#line 256 "ext/date/lib/parse_iso_intervals.c"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
@@ -357,12 +322,12 @@ std:
if (yych <= '9') goto yy98;
yy3:
YYDEBUG(3, *YYCURSOR);
-#line 424 "ext/date/lib/parse_iso_intervals.re"
+#line 389 "ext/date/lib/parse_iso_intervals.re"
{
add_error(s, "Unexpected character");
goto std;
}
-#line 366 "ext/date/lib/parse_iso_intervals.c"
+#line 331 "ext/date/lib/parse_iso_intervals.c"
yy4:
YYDEBUG(4, *YYCURSOR);
yyaccept = 0;
@@ -379,7 +344,7 @@ yy5:
if (yych == 'T') goto yy14;
yy6:
YYDEBUG(6, *YYCURSOR);
-#line 351 "ext/date/lib/parse_iso_intervals.re"
+#line 316 "ext/date/lib/parse_iso_intervals.re"
{
timelib_sll nr;
int in_time = 0;
@@ -420,26 +385,26 @@ yy6:
TIMELIB_DEINIT;
return TIMELIB_PERIOD;
}
-#line 424 "ext/date/lib/parse_iso_intervals.c"
+#line 389 "ext/date/lib/parse_iso_intervals.c"
yy7:
YYDEBUG(7, *YYCURSOR);
++YYCURSOR;
YYDEBUG(8, *YYCURSOR);
-#line 413 "ext/date/lib/parse_iso_intervals.re"
+#line 378 "ext/date/lib/parse_iso_intervals.re"
{
goto std;
}
-#line 433 "ext/date/lib/parse_iso_intervals.c"
+#line 398 "ext/date/lib/parse_iso_intervals.c"
yy9:
YYDEBUG(9, *YYCURSOR);
++YYCURSOR;
YYDEBUG(10, *YYCURSOR);
-#line 418 "ext/date/lib/parse_iso_intervals.re"
+#line 383 "ext/date/lib/parse_iso_intervals.re"
{
s->pos = cursor; s->line++;
goto std;
}
-#line 443 "ext/date/lib/parse_iso_intervals.c"
+#line 408 "ext/date/lib/parse_iso_intervals.c"
yy11:
YYDEBUG(11, *YYCURSOR);
yych = *++YYCURSOR;
@@ -769,7 +734,7 @@ yy51:
YYDEBUG(57, *YYCURSOR);
++YYCURSOR;
YYDEBUG(58, *YYCURSOR);
-#line 393 "ext/date/lib/parse_iso_intervals.re"
+#line 358 "ext/date/lib/parse_iso_intervals.re"
{
DEBUG_OUTPUT("combinedrep");
TIMELIB_INIT;
@@ -788,7 +753,7 @@ yy51:
TIMELIB_DEINIT;
return TIMELIB_PERIOD;
}
-#line 792 "ext/date/lib/parse_iso_intervals.c"
+#line 757 "ext/date/lib/parse_iso_intervals.c"
yy59:
YYDEBUG(59, *YYCURSOR);
yych = *++YYCURSOR;
@@ -917,7 +882,7 @@ yy83:
YYDEBUG(83, *YYCURSOR);
++YYCURSOR;
YYDEBUG(84, *YYCURSOR);
-#line 327 "ext/date/lib/parse_iso_intervals.re"
+#line 292 "ext/date/lib/parse_iso_intervals.re"
{
timelib_time *current;
@@ -940,7 +905,7 @@ yy83:
TIMELIB_DEINIT;
return TIMELIB_ISO_DATE;
}
-#line 944 "ext/date/lib/parse_iso_intervals.c"
+#line 909 "ext/date/lib/parse_iso_intervals.c"
yy85:
YYDEBUG(85, *YYCURSOR);
yych = *++YYCURSOR;
@@ -1018,7 +983,7 @@ yy98:
if (yych <= '9') goto yy98;
yy100:
YYDEBUG(100, *YYCURSOR);
-#line 316 "ext/date/lib/parse_iso_intervals.re"
+#line 281 "ext/date/lib/parse_iso_intervals.re"
{
DEBUG_OUTPUT("recurrences");
TIMELIB_INIT;
@@ -1028,9 +993,9 @@ yy100:
s->have_recurrences = 1;
return TIMELIB_PERIOD;
}
-#line 1032 "ext/date/lib/parse_iso_intervals.c"
+#line 997 "ext/date/lib/parse_iso_intervals.c"
}
-#line 428 "ext/date/lib/parse_iso_intervals.re"
+#line 393 "ext/date/lib/parse_iso_intervals.re"
}
#ifdef PHP_WIN32
diff --git a/ext/date/lib/parse_iso_intervals.re b/ext/date/lib/parse_iso_intervals.re
index c5e9f677ba..cbbf8781bf 100644
--- a/ext/date/lib/parse_iso_intervals.re
+++ b/ext/date/lib/parse_iso_intervals.re
@@ -102,8 +102,6 @@ typedef struct Scanner {
int have_end_date;
} Scanner;
-#define HOUR(a) (int)(a * 60)
-
static void add_warning(Scanner *s, char *error)
{
s->errors->warning_count++;
@@ -176,39 +174,6 @@ static timelib_ull timelib_get_unsigned_nr(char **ptr, int max_length)
return dir * timelib_get_nr(ptr, max_length);
}
-static long timelib_parse_tz_cor(char **ptr)
-{
- char *begin = *ptr, *end;
- long tmp;
-
- while (isdigit(**ptr) || **ptr == ':') {
- ++*ptr;
- }
- end = *ptr;
- switch (end - begin) {
- case 1:
- case 2:
- return HOUR(strtol(begin, NULL, 10));
- break;
- case 3:
- case 4:
- if (begin[1] == ':') {
- tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 2, NULL, 10);
- return tmp;
- } else if (begin[2] == ':') {
- tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
- return tmp;
- } else {
- tmp = strtol(begin, NULL, 10);
- return HOUR(tmp / 100) + tmp % 100;
- }
- case 5:
- tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
- return tmp;
- }
- return 0;
-}
-
static void timelib_eat_spaces(char **ptr)
{
while (**ptr == ' ' || **ptr == '\t') {
diff --git a/ext/date/lib/timelib.c b/ext/date/lib/timelib.c
index 2f457a9882..84354e300f 100644
--- a/ext/date/lib/timelib.c
+++ b/ext/date/lib/timelib.c
@@ -30,6 +30,8 @@
#define TIMELIB_LLABS(y) (y < 0 ? (y * -1) : y)
+#define HOUR(a) (int)(a * 60)
+
timelib_time* timelib_time_ctor(void)
{
timelib_time *t;
@@ -284,3 +286,35 @@ void timelib_dump_rel_time(timelib_rel_time *d)
printf("\n");
}
+long timelib_parse_tz_cor(char **ptr)
+{
+ char *begin = *ptr, *end;
+ long tmp;
+
+ while (isdigit(**ptr) || **ptr == ':') {
+ ++*ptr;
+ }
+ end = *ptr;
+ switch (end - begin) {
+ case 1:
+ case 2:
+ return HOUR(strtol(begin, NULL, 10));
+ break;
+ case 3:
+ case 4:
+ if (begin[1] == ':') {
+ tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 2, NULL, 10);
+ return tmp;
+ } else if (begin[2] == ':') {
+ tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
+ return tmp;
+ } else {
+ tmp = strtol(begin, NULL, 10);
+ return HOUR(tmp / 100) + tmp % 100;
+ }
+ case 5:
+ tmp = HOUR(strtol(begin, NULL, 10)) + strtol(begin + 3, NULL, 10);
+ return tmp;
+ }
+ return 0;
+}
diff --git a/ext/date/lib/timelib.h b/ext/date/lib/timelib.h
index 2acb765e63..3f8e1254ef 100644
--- a/ext/date/lib/timelib.h
+++ b/ext/date/lib/timelib.h
@@ -73,6 +73,7 @@ timelib_time *timelib_parse_from_format(char *format, char *s, int len, timelib_
void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options);
char *timelib_timezone_id_from_abbr(const char *abbr, long gmtoffset, int isdst);
const timelib_tz_lookup_table *timelib_timezone_abbreviations_list(void);
+long timelib_parse_tz_cor(char**);
/* From parse_iso_intervals.re */
void timelib_strtointerval(char *s, int len,
@@ -129,6 +130,7 @@ void timelib_dump_date(timelib_time *d, int options);
void timelib_dump_rel_time(timelib_rel_time *d);
void timelib_decimal_hour_to_hms(double h, int *hour, int *min, int *sec);
+long timelib_parse_tz_cor(char **ptr);
/* from astro.c */
double timelib_ts_to_juliandate(timelib_sll ts);
diff --git a/ext/date/lib/tm2unixtime.c b/ext/date/lib/tm2unixtime.c
index e15a38150c..23fe202ba9 100644
--- a/ext/date/lib/tm2unixtime.c
+++ b/ext/date/lib/tm2unixtime.c
@@ -220,55 +220,52 @@ static void do_adjust_relative(timelib_time* time)
static void do_adjust_special_weekday(timelib_time* time)
{
- timelib_sll current_dow, count;
+ timelib_sll count, dow, rem;
count = time->relative.special.amount;
+ dow = timelib_day_of_week(time->y, time->m, time->d);
- current_dow = timelib_day_of_week(time->y, time->m, time->d);
- if (count == 0) {
- /* skip over saturday and sunday */
- if (current_dow == 6) {
- time->d += 2;
- }
- /* skip over sunday */
- if (current_dow == 0) {
- time->d += 1;
- }
- } else if (count > 0) {
- /* skip over saturday and sunday */
- if (current_dow == 5) {
- time->d += 2;
- }
- /* skip over sunday */
- if (current_dow == 6) {
+ /* Add increments of 5 weekdays as a week, leaving the DOW unchanged. */
+ time->d += (count / 5) * 7;
+
+ /* Deal with the remainder. */
+ rem = (count % 5);
+
+ if (count > 0) {
+ if (rem == 0) {
+ /* Head back to Friday if we stop on the weekend. */
+ if (dow == 0) {
+ time->d -= 2;
+ } else if (dow == 6) {
+ time->d -= 1;
+ }
+ } else if (dow == 6) {
+ /* We ended up on Saturday, but there's still work to do, so move
+ * to Sunday and continue from there. */
time->d += 1;
- }
- /* add increments of 5 weekdays as a week */
- time->d += (count / 5) * 7;
- /* if current DOW plus the remainder > 5, add two days */
- current_dow = timelib_day_of_week(time->y, time->m, time->d);
- time->d += (count % 5);
- if ((count % 5) + current_dow > 5) {
+ } else if (dow + rem > 5) {
+ /* We're on a weekday, but we're going past Friday, so skip right
+ * over the weekend. */
time->d += 2;
}
- } else if (count < 0) {
- /* skip over sunday and saturday */
- if (current_dow == 1) {
- time->d -= 2;
- }
- /* skip over satruday */
- if (current_dow == 0 ) {
+ } else {
+ /* Completely mirror the forward direction. This also covers the 0
+ * case, since if we start on the weekend, we want to move forward as
+ * if we stopped there while going backwards. */
+ if (rem == 0) {
+ if (dow == 6) {
+ time->d += 2;
+ } else if (dow == 0) {
+ time->d += 1;
+ }
+ } else if (dow == 0) {
time->d -= 1;
- }
- /* subtract increments of 5 weekdays as a week */
- time->d += (count / 5) * 7;
- /* if current DOW minus the remainder < 0, subtract two days */
- current_dow = timelib_day_of_week(time->y, time->m, time->d);
- time->d += (count % 5);
- if ((count % 5) + current_dow < 1) {
+ } else if (dow + rem < 1) {
time->d -= 2;
}
}
+
+ time->d += rem;
}
static void do_adjust_special(timelib_time* time)
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 2bb555a68b..742a2f60c3 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -399,7 +399,9 @@ const zend_function_entry date_functions[] = {
/* Advanced Interface */
PHP_FE(date_create, arginfo_date_create)
+ PHP_FE(date_create_immutable, arginfo_date_create)
PHP_FE(date_create_from_format, arginfo_date_create_from_format)
+ PHP_FE(date_create_immutable_from_format, arginfo_date_create_from_format)
PHP_FE(date_parse, arginfo_date_parse)
PHP_FE(date_parse_from_format, arginfo_date_parse_from_format)
PHP_FE(date_get_last_errors, arginfo_date_get_last_errors)
@@ -442,6 +444,16 @@ const zend_function_entry date_functions[] = {
PHP_FE_END
};
+static const zend_function_entry date_funcs_interface[] = {
+ PHP_ABSTRACT_ME(DateTimeInterface, format, arginfo_date_method_format)
+ PHP_ABSTRACT_ME(DateTimeInterface, getTimezone, arginfo_date_method_timezone_get)
+ PHP_ABSTRACT_ME(DateTimeInterface, getOffset, arginfo_date_method_offset_get)
+ PHP_ABSTRACT_ME(DateTimeInterface, getTimestamp, arginfo_date_method_timestamp_get)
+ PHP_ABSTRACT_ME(DateTimeInterface, diff, arginfo_date_method_diff)
+ PHP_ABSTRACT_ME(DateTimeInterface, __wakeup, NULL)
+ PHP_FE_END
+};
+
const zend_function_entry date_funcs_date[] = {
PHP_ME(DateTime, __construct, arginfo_date_create, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
PHP_ME(DateTime, __wakeup, NULL, ZEND_ACC_PUBLIC)
@@ -464,8 +476,32 @@ const zend_function_entry date_funcs_date[] = {
PHP_FE_END
};
+const zend_function_entry date_funcs_immutable[] = {
+ PHP_ME(DateTimeImmutable, __construct, arginfo_date_create, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
+ PHP_ME(DateTime, __wakeup, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(DateTimeImmutable, __set_state, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+ PHP_ME_MAPPING(createFromFormat, date_create_immutable_from_format, arginfo_date_create_from_format, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+ PHP_ME_MAPPING(getLastErrors, date_get_last_errors, arginfo_date_get_last_errors, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+ PHP_ME_MAPPING(format, date_format, arginfo_date_method_format, 0)
+ PHP_ME_MAPPING(getTimezone, date_timezone_get, arginfo_date_method_timezone_get, 0)
+ PHP_ME_MAPPING(getOffset, date_offset_get, arginfo_date_method_offset_get, 0)
+ PHP_ME_MAPPING(getTimestamp, date_timestamp_get, arginfo_date_method_timestamp_get, 0)
+ PHP_ME_MAPPING(diff, date_diff, arginfo_date_method_diff, 0)
+ PHP_ME(DateTimeImmutable, modify, arginfo_date_method_modify, 0)
+ PHP_ME(DateTimeImmutable, add, arginfo_date_method_add, 0)
+ PHP_ME(DateTimeImmutable, sub, arginfo_date_method_sub, 0)
+ PHP_ME(DateTimeImmutable, setTimezone, arginfo_date_method_timezone_set, 0)
+ PHP_ME(DateTimeImmutable, setTime, arginfo_date_method_time_set, 0)
+ PHP_ME(DateTimeImmutable, setDate, arginfo_date_method_date_set, 0)
+ PHP_ME(DateTimeImmutable, setISODate, arginfo_date_method_isodate_set, 0)
+ PHP_ME(DateTimeImmutable, setTimestamp, arginfo_date_method_timestamp_set, 0)
+ PHP_FE_END
+};
+
const zend_function_entry date_funcs_timezone[] = {
PHP_ME(DateTimeZone, __construct, arginfo_timezone_open, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
+ PHP_ME(DateTimeZone, __wakeup, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(DateTimeZone, __set_state, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME_MAPPING(getName, timezone_name_get, arginfo_timezone_method_name_get, 0)
PHP_ME_MAPPING(getOffset, timezone_offset_get, arginfo_timezone_method_offset_get, 0)
PHP_ME_MAPPING(getTransitions, timezone_transitions_get, arginfo_timezone_method_transitions_get, 0)
@@ -524,6 +560,7 @@ PHP_INI_END()
/* }}} */
zend_class_entry *date_ce_date, *date_ce_timezone, *date_ce_interval, *date_ce_period;
+zend_class_entry *date_ce_immutable, *date_ce_interface;
PHPAPI zend_class_entry *php_date_get_date_ce(void)
@@ -531,12 +568,18 @@ PHPAPI zend_class_entry *php_date_get_date_ce(void)
return date_ce_date;
}
+PHPAPI zend_class_entry *php_date_get_immutable_ce(void)
+{
+ return date_ce_immutable;
+}
+
PHPAPI zend_class_entry *php_date_get_timezone_ce(void)
{
return date_ce_timezone;
}
static zend_object_handlers date_object_handlers_date;
+static zend_object_handlers date_object_handlers_immutable;
static zend_object_handlers date_object_handlers_timezone;
static zend_object_handlers date_object_handlers_interval;
static zend_object_handlers date_object_handlers_period;
@@ -587,6 +630,8 @@ static HashTable *date_object_get_gc_interval(zval *object, zval ***table, int *
static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC);
static HashTable *date_object_get_gc_period(zval *object, zval ***table, int *n TSRMLS_DC);
static HashTable *date_object_get_properties_period(zval *object TSRMLS_DC);
+static HashTable *date_object_get_properties_timezone(zval *object TSRMLS_DC);
+static HashTable *date_object_get_gc_timezone(zval *object, zval ***table, int *n TSRMLS_DC);
zval *date_interval_read_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC);
void date_interval_write_property(zval *object, zval *member, zval *value, const zend_literal *key TSRMLS_DC);
@@ -771,7 +816,6 @@ PHP_RSHUTDOWN_FUNCTION(date)
#define SUNFUNCS_RET_STRING 1
#define SUNFUNCS_RET_DOUBLE 2
-
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(date)
{
@@ -1385,7 +1429,6 @@ PHPAPI signed long php_parse_date(char *string, signed long *now)
}
/* }}} */
-
/* {{{ proto int strtotime(string time [, int now ])
Convert string representation of date and time to a timestamp */
PHP_FUNCTION(strtotime)
@@ -1446,7 +1489,6 @@ PHP_FUNCTION(strtotime)
}
/* }}} */
-
/* {{{ php_mktime - (gm)mktime helper */
PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
{
@@ -1555,7 +1597,6 @@ PHP_FUNCTION(gmmktime)
}
/* }}} */
-
/* {{{ proto bool checkdate(int month, int day, int year)
Returns true(1) if it is a valid date in gregorian calendar */
PHP_FUNCTION(checkdate)
@@ -1582,7 +1623,7 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
long timestamp = 0;
struct tm ta;
int max_reallocs = 5;
- size_t buf_len = 64, real_len;
+ size_t buf_len = 256, real_len;
timelib_time *ts;
timelib_tzinfo *tzi;
timelib_time_offset *offset = NULL;
@@ -1635,6 +1676,9 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
#endif
}
+ /* VS2012 crt has a bug where strftime crash with %z and %Z format when the
+ initial buffer is too small. See
+ http://connect.microsoft.com/VisualStudio/feedback/details/759720/vs2012-strftime-crash-with-z-formatting-code */
buf = (char *) emalloc(buf_len);
while ((real_len=strftime(buf, buf_len, format, &ta))==buf_len || real_len==0) {
buf_len *= 2;
@@ -1643,6 +1687,13 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
break;
}
}
+#if defined(PHP_WIN32) && _MSC_VER >= 1700
+ /* VS2012 strftime() returns number of characters, not bytes.
+ See VC++11 bug id 766205. */
+ if (real_len > 0) {
+ real_len = strlen(buf);
+ }
+#endif
timelib_time_dtor(ts);
if (!gmt) {
@@ -1855,7 +1906,7 @@ static void date_period_it_current_data(zend_object_iterator *iter, zval ***data
/* Create new object */
MAKE_STD_ZVAL(iterator->current);
- php_date_instantiate(date_ce_date, iterator->current TSRMLS_CC);
+ php_date_instantiate(object->start_ce, iterator->current TSRMLS_CC);
newdateobj = (php_date_obj *) zend_object_store_get_object(iterator->current TSRMLS_CC);
newdateobj->time = timelib_time_ctor();
*newdateobj->time = *it_time;
@@ -1872,11 +1923,10 @@ static void date_period_it_current_data(zend_object_iterator *iter, zval ***data
/* {{{ date_period_it_current_key */
-static int date_period_it_current_key(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
+static void date_period_it_current_key(zend_object_iterator *iter, zval *key TSRMLS_DC)
{
- date_period_it *iterator = (date_period_it *)iter;
- *int_key = iterator->current_index;
- return HASH_KEY_IS_LONG;
+ date_period_it *iterator = (date_period_it *)iter;
+ ZVAL_LONG(key, iterator->current_index);
}
/* }}} */
@@ -1941,7 +1991,10 @@ zend_object_iterator *date_object_period_get_iterator(zend_class_entry *ce, zval
static void date_register_classes(TSRMLS_D)
{
- zend_class_entry ce_date, ce_timezone, ce_interval, ce_period;
+ zend_class_entry ce_date, ce_immutable, ce_timezone, ce_interval, ce_period, ce_interface;
+
+ INIT_CLASS_ENTRY(ce_interface, "DateTimeInterface", date_funcs_interface);
+ date_ce_interface = zend_register_internal_interface(&ce_interface TSRMLS_CC);
INIT_CLASS_ENTRY(ce_date, "DateTime", date_funcs_date);
ce_date.create_object = date_object_new_date;
@@ -1951,6 +2004,7 @@ static void date_register_classes(TSRMLS_D)
date_object_handlers_date.compare_objects = date_object_compare_date;
date_object_handlers_date.get_properties = date_object_get_properties;
date_object_handlers_date.get_gc = date_object_get_gc;
+ zend_class_implements(date_ce_date TSRMLS_CC, 1, date_ce_interface);
#define REGISTER_DATE_CLASS_CONST_STRING(const_name, value) \
zend_declare_class_constant_stringl(date_ce_date, const_name, sizeof(const_name)-1, value, sizeof(value)-1 TSRMLS_CC);
@@ -1967,12 +2021,22 @@ static void date_register_classes(TSRMLS_D)
REGISTER_DATE_CLASS_CONST_STRING("RSS", DATE_FORMAT_RFC1123);
REGISTER_DATE_CLASS_CONST_STRING("W3C", DATE_FORMAT_RFC3339);
+ INIT_CLASS_ENTRY(ce_immutable, "DateTimeImmutable", date_funcs_immutable);
+ ce_immutable.create_object = date_object_new_date;
+ date_ce_immutable = zend_register_internal_class_ex(&ce_immutable, NULL, NULL TSRMLS_CC);
+ memcpy(&date_object_handlers_immutable, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ date_object_handlers_immutable.clone_obj = date_object_clone_date;
+ date_object_handlers_immutable.compare_objects = date_object_compare_date;
+ date_object_handlers_immutable.get_properties = date_object_get_properties;
+ zend_class_implements(date_ce_immutable TSRMLS_CC, 1, date_ce_interface);
INIT_CLASS_ENTRY(ce_timezone, "DateTimeZone", date_funcs_timezone);
ce_timezone.create_object = date_object_new_timezone;
date_ce_timezone = zend_register_internal_class_ex(&ce_timezone, NULL, NULL TSRMLS_CC);
memcpy(&date_object_handlers_timezone, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
date_object_handlers_timezone.clone_obj = date_object_clone_timezone;
+ date_object_handlers_timezone.get_properties = date_object_get_properties_timezone;
+ date_object_handlers_timezone.get_gc = date_object_get_gc_timezone;
#define REGISTER_TIMEZONE_CLASS_CONST_STRING(const_name, value) \
zend_declare_class_constant_long(date_ce_timezone, const_name, sizeof(const_name)-1, value TSRMLS_CC);
@@ -2072,29 +2136,36 @@ static zend_object_value date_object_clone_date(zval *this_ptr TSRMLS_DC)
return new_ov;
}
+static zval* date_clone_immutable(zval *object TSRMLS_DC)
+{
+ zval *new_object;
+
+ ALLOC_ZVAL(new_object);
+ Z_OBJVAL_P(new_object) = date_object_clone_date(object TSRMLS_CC);
+ Z_SET_REFCOUNT_P(new_object, 1);
+ Z_SET_ISREF_P(new_object);
+ Z_TYPE_P(new_object) = IS_OBJECT;
+
+ return new_object;
+}
+
static int date_object_compare_date(zval *d1, zval *d2 TSRMLS_DC)
{
- if (Z_TYPE_P(d1) == IS_OBJECT && Z_TYPE_P(d2) == IS_OBJECT &&
- instanceof_function(Z_OBJCE_P(d1), date_ce_date TSRMLS_CC) &&
- instanceof_function(Z_OBJCE_P(d2), date_ce_date TSRMLS_CC)) {
- php_date_obj *o1 = zend_object_store_get_object(d1 TSRMLS_CC);
- php_date_obj *o2 = zend_object_store_get_object(d2 TSRMLS_CC);
+ php_date_obj *o1 = zend_object_store_get_object(d1 TSRMLS_CC);
+ php_date_obj *o2 = zend_object_store_get_object(d2 TSRMLS_CC);
- if (!o1->time || !o2->time) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Trying to compare an incomplete DateTime object");
- return 1;
- }
- if (!o1->time->sse_uptodate) {
- timelib_update_ts(o1->time, o1->time->tz_info);
- }
- if (!o2->time->sse_uptodate) {
- timelib_update_ts(o2->time, o2->time->tz_info);
- }
-
- return (o1->time->sse == o2->time->sse) ? 0 : ((o1->time->sse < o2->time->sse) ? -1 : 1);
+ if (!o1->time || !o2->time) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Trying to compare an incomplete DateTime or DateTimeImmutable object");
+ return 1;
+ }
+ if (!o1->time->sse_uptodate) {
+ timelib_update_ts(o1->time, o1->time->tz_info);
+ }
+ if (!o2->time->sse_uptodate) {
+ timelib_update_ts(o2->time, o2->time->tz_info);
}
- return 1;
+ return (o1->time->sse == o2->time->sse) ? 0 : ((o1->time->sse < o2->time->sse) ? -1 : 1);
}
static HashTable *date_object_get_gc(zval *object, zval ***table, int *n TSRMLS_DC)
@@ -2104,6 +2175,14 @@ static HashTable *date_object_get_gc(zval *object, zval ***table, int *n TSRMLS_
return zend_std_get_properties(object TSRMLS_CC);
}
+static HashTable *date_object_get_gc_timezone(zval *object, zval ***table, int *n TSRMLS_DC)
+{
+
+ *table = NULL;
+ *n = 0;
+ return zend_std_get_properties(object TSRMLS_CC);
+}
+
static HashTable *date_object_get_properties(zval *object TSRMLS_DC)
{
HashTable *props;
@@ -2212,6 +2291,50 @@ static zend_object_value date_object_clone_timezone(zval *this_ptr TSRMLS_DC)
return new_ov;
}
+static HashTable *date_object_get_properties_timezone(zval *object TSRMLS_DC)
+{
+ HashTable *props;
+ zval *zv;
+ php_timezone_obj *tzobj;
+
+
+ tzobj = (php_timezone_obj *) zend_object_store_get_object(object TSRMLS_CC);
+
+ props = zend_std_get_properties(object TSRMLS_CC);
+
+ if (!tzobj->initialized) {
+ return props;
+ }
+
+ MAKE_STD_ZVAL(zv);
+ ZVAL_LONG(zv, tzobj->type);
+ zend_hash_update(props, "timezone_type", 14, &zv, sizeof(zv), NULL);
+
+ MAKE_STD_ZVAL(zv);
+ switch (tzobj->type) {
+ case TIMELIB_ZONETYPE_ID:
+ ZVAL_STRING(zv, tzobj->tzi.tz->name, 1);
+ break;
+ case TIMELIB_ZONETYPE_OFFSET: {
+ char *tmpstr = emalloc(sizeof("UTC+05:00"));
+
+ snprintf(tmpstr, sizeof("+05:00"), "%c%02d:%02d",
+ tzobj->tzi.utc_offset > 0 ? '-' : '+',
+ abs(tzobj->tzi.utc_offset / 60),
+ abs((tzobj->tzi.utc_offset % 60)));
+
+ ZVAL_STRING(zv, tmpstr, 0);
+ }
+ break;
+ case TIMELIB_ZONETYPE_ABBR:
+ ZVAL_STRING(zv, tzobj->tzi.z.abbr, 1);
+ break;
+ }
+ zend_hash_update(props, "timezone", 9, &zv, sizeof(zv), NULL);
+
+ return props;
+}
+
static inline zend_object_value date_object_new_interval_ex(zend_class_entry *class_type, php_interval_obj **ptr TSRMLS_DC)
{
php_interval_obj *intern;
@@ -2516,6 +2639,26 @@ PHP_FUNCTION(date_create)
}
/* }}} */
+/* {{{ proto DateTime date_create_immutable([string time[, DateTimeZone object]])
+ Returns new DateTime object
+*/
+PHP_FUNCTION(date_create_immutable)
+{
+ zval *timezone_object = NULL;
+ char *time_str = NULL;
+ int time_str_len = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO!", &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ php_date_instantiate(date_ce_immutable, return_value TSRMLS_CC);
+ if (!php_date_initialize(zend_object_store_get_object(return_value TSRMLS_CC), time_str, time_str_len, NULL, timezone_object, 0 TSRMLS_CC)) {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
/* {{{ proto DateTime date_create_from_format(string format, string time[, DateTimeZone object])
Returns new DateTime object formatted according to the specified format
*/
@@ -2536,6 +2679,26 @@ PHP_FUNCTION(date_create_from_format)
}
/* }}} */
+/* {{{ proto DateTime date_create_immutable_from_format(string format, string time[, DateTimeZone object])
+ Returns new DateTime object formatted according to the specified format
+*/
+PHP_FUNCTION(date_create_immutable_from_format)
+{
+ zval *timezone_object = NULL;
+ char *time_str = NULL, *format_str = NULL;
+ int time_str_len = 0, format_str_len = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|O", &format_str, &format_str_len, &time_str, &time_str_len, &timezone_object, date_ce_timezone) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ php_date_instantiate(date_ce_immutable, return_value TSRMLS_CC);
+ if (!php_date_initialize(zend_object_store_get_object(return_value TSRMLS_CC), time_str, time_str_len, format_str, timezone_object, 0 TSRMLS_CC)) {
+ RETURN_FALSE;
+ }
+}
+/* }}} */
+
/* {{{ proto DateTime::__construct([string time[, DateTimeZone object]])
Creates new DateTime object
*/
@@ -2554,6 +2717,24 @@ PHP_METHOD(DateTime, __construct)
}
/* }}} */
+/* {{{ proto DateTimeImmutable::__construct([string time[, DateTimeZone object]])
+ Creates new DateTimeImmutable object
+*/
+PHP_METHOD(DateTimeImmutable, __construct)
+{
+ zval *timezone_object = NULL;
+ char *time_str = NULL;
+ int time_str_len = 0;
+ zend_error_handling error_handling;
+
+ zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
+ if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sO!", &time_str, &time_str_len, &timezone_object, date_ce_timezone)) {
+ php_date_initialize(zend_object_store_get_object(getThis() TSRMLS_CC), time_str, time_str_len, NULL, timezone_object, 1 TSRMLS_CC);
+ }
+ zend_restore_error_handling(&error_handling TSRMLS_CC);
+}
+/* }}} */
+
static int php_date_initialize_from_hash(zval **return_value, php_date_obj **dateobj, HashTable *myht TSRMLS_DC)
{
zval **z_date = NULL;
@@ -2626,6 +2807,28 @@ PHP_METHOD(DateTime, __set_state)
}
/* }}} */
+/* {{{ proto DateTimeImmutable::__set_state()
+*/
+PHP_METHOD(DateTimeImmutable, __set_state)
+{
+ php_date_obj *dateobj;
+ zval *array;
+ HashTable *myht;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ myht = HASH_OF(array);
+
+ php_date_instantiate(date_ce_immutable, return_value TSRMLS_CC);
+ dateobj = (php_date_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
+ if (!php_date_initialize_from_hash(&return_value, &dateobj, myht TSRMLS_CC)) {
+ php_error(E_ERROR, "Invalid serialization data for DateTimeImmutable object");
+ }
+}
+/* }}} */
+
/* {{{ proto DateTime::__wakeup()
*/
PHP_METHOD(DateTime, __wakeup)
@@ -2794,7 +2997,7 @@ PHP_FUNCTION(date_parse_from_format)
}
/* }}} */
-/* {{{ proto string date_format(DateTime object, string format)
+/* {{{ proto string date_format(DateTimeInterface object, string format)
Returns date formatted according to given format
*/
PHP_FUNCTION(date_format)
@@ -2804,7 +3007,7 @@ PHP_FUNCTION(date_format)
char *format;
int format_len;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, date_ce_date, &format, &format_len) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, date_ce_interface, &format, &format_len) == FAILURE) {
RETURN_FALSE;
}
dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
@@ -2813,23 +3016,18 @@ PHP_FUNCTION(date_format)
}
/* }}} */
-/* {{{ proto DateTime date_modify(DateTime object, string modify)
- Alters the timestamp.
-*/
-PHP_FUNCTION(date_modify)
+static int php_date_modify(zval *object, char *modify, int modify_len TSRMLS_DC)
{
- zval *object;
php_date_obj *dateobj;
- char *modify;
- int modify_len;
timelib_time *tmp_time;
timelib_error_container *err = NULL;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, date_ce_date, &modify, &modify_len) == FAILURE) {
- RETURN_FALSE;
- }
dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
- DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
+
+ if (!(dateobj->time)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "The DateTime object has not been correctly initialized by its constructor");
+ return 0;
+ }
tmp_time = timelib_strtotime(modify, modify_len, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
@@ -2840,7 +3038,7 @@ PHP_FUNCTION(date_modify)
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to parse time string (%s) at position %d (%c): %s", modify,
err->error_messages[0].position, err->error_messages[0].character, err->error_messages[0].message);
timelib_time_dtor(tmp_time);
- RETURN_FALSE;
+ return 0;
}
memcpy(&dateobj->time->relative, &tmp_time->relative, sizeof(struct timelib_rel_time));
@@ -2876,50 +3074,125 @@ PHP_FUNCTION(date_modify)
timelib_update_ts(dateobj->time, NULL);
timelib_update_from_sse(dateobj->time);
dateobj->time->have_relative = 0;
+
+ return 1;
+}
- RETURN_ZVAL(object, 1, 0);
+/* {{{ proto DateTime date_modify(DateTime object, string modify)
+ Alters the timestamp.
+*/
+PHP_FUNCTION(date_modify)
+{
+ zval *object;
+ char *modify;
+ int modify_len;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, date_ce_date, &modify, &modify_len) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ if (php_date_modify(object, modify, modify_len TSRMLS_CC)) {
+ RETURN_ZVAL(object, 1, 0);
+ }
+
+ RETURN_FALSE;
}
/* }}} */
-/* {{{ proto DateTime date_add(DateTime object, DateInterval interval)
- Adds an interval to the current date in object.
+/* {{{ proto DateTimeImmutable::modify()
*/
-PHP_FUNCTION(date_add)
+PHP_METHOD(DateTimeImmutable, modify)
{
- zval *object, *interval;
- php_date_obj *dateobj;
- php_interval_obj *intobj;
- timelib_time *new_time;
+ zval *object, *new_object;
+ char *modify;
+ int modify_len;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_date, &interval, date_ce_interval) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &object, date_ce_immutable, &modify, &modify_len) == FAILURE) {
RETURN_FALSE;
}
+
+ new_object = date_clone_immutable(object TSRMLS_CC);
+ if (php_date_modify(new_object, modify, modify_len TSRMLS_CC)) {
+ RETURN_ZVAL(new_object, 0, 1);
+ }
+
+ RETURN_FALSE;
+}
+/* }}} */
+
+static void php_date_add(zval *object, zval *interval, zval *return_value TSRMLS_DC)
+{
+ php_date_obj *dateobj;
+ php_interval_obj *intobj;
+ int bias = 1;
+
dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
intobj = (php_interval_obj *) zend_object_store_get_object(interval TSRMLS_CC);
DATE_CHECK_INITIALIZED(intobj->initialized, DateInterval);
- new_time = timelib_add(dateobj->time, intobj->diff);
- timelib_time_dtor(dateobj->time);
- dateobj->time = new_time;
+ if (intobj->diff->have_weekday_relative || intobj->diff->have_special_relative) {
+ memcpy(&dateobj->time->relative, intobj->diff, sizeof(struct timelib_rel_time));
+ } else {
+ if (intobj->diff->invert) {
+ bias = -1;
+ }
+ memset(&dateobj->time->relative, 0, sizeof(struct timelib_rel_time));
+ dateobj->time->relative.y = intobj->diff->y * bias;
+ dateobj->time->relative.m = intobj->diff->m * bias;
+ dateobj->time->relative.d = intobj->diff->d * bias;
+ dateobj->time->relative.h = intobj->diff->h * bias;
+ dateobj->time->relative.i = intobj->diff->i * bias;
+ dateobj->time->relative.s = intobj->diff->s * bias;
+ }
+ dateobj->time->have_relative = 1;
+ dateobj->time->sse_uptodate = 0;
+
+ timelib_update_ts(dateobj->time, NULL);
+ timelib_update_from_sse(dateobj->time);
+ dateobj->time->have_relative = 0;
+}
+
+/* {{{ proto DateTime date_add(DateTime object, DateInterval interval)
+ Adds an interval to the current date in object.
+*/
+PHP_FUNCTION(date_add)
+{
+ zval *object, *interval;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_date, &interval, date_ce_interval) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ php_date_add(object, interval, return_value TSRMLS_CC);
RETURN_ZVAL(object, 1, 0);
}
/* }}} */
-/* {{{ proto DateTime date_sub(DateTime object, DateInterval interval)
- Subtracts an interval to the current date in object.
+/* {{{ proto DateTimeImmutable::add()
*/
-PHP_FUNCTION(date_sub)
+PHP_METHOD(DateTimeImmutable, add)
{
- zval *object, *interval;
- php_date_obj *dateobj;
- php_interval_obj *intobj;
- timelib_time *new_time;
+ zval *object, *interval, *new_object;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_date, &interval, date_ce_interval) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_immutable, &interval, date_ce_interval) == FAILURE) {
RETURN_FALSE;
}
+
+ new_object = date_clone_immutable(object TSRMLS_CC);
+ php_date_add(new_object, interval, return_value TSRMLS_CC);
+
+ RETURN_ZVAL(new_object, 0, 1);
+}
+/* }}} */
+
+static void php_date_sub(zval *object, zval *interval, zval *return_value TSRMLS_DC)
+{
+ php_date_obj *dateobj;
+ php_interval_obj *intobj;
+ int bias = 1;
+
dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
intobj = (php_interval_obj *) zend_object_store_get_object(interval TSRMLS_CC);
@@ -2930,15 +3203,61 @@ PHP_FUNCTION(date_sub)
return;
}
- new_time = timelib_sub(dateobj->time, intobj->diff);
- timelib_time_dtor(dateobj->time);
- dateobj->time = new_time;
+ if (intobj->diff->invert) {
+ bias = -1;
+ }
+
+ memset(&dateobj->time->relative, 0, sizeof(struct timelib_rel_time));
+ dateobj->time->relative.y = 0 - (intobj->diff->y * bias);
+ dateobj->time->relative.m = 0 - (intobj->diff->m * bias);
+ dateobj->time->relative.d = 0 - (intobj->diff->d * bias);
+ dateobj->time->relative.h = 0 - (intobj->diff->h * bias);
+ dateobj->time->relative.i = 0 - (intobj->diff->i * bias);
+ dateobj->time->relative.s = 0 - (intobj->diff->s * bias);
+ dateobj->time->have_relative = 1;
+ dateobj->time->sse_uptodate = 0;
+
+ timelib_update_ts(dateobj->time, NULL);
+ timelib_update_from_sse(dateobj->time);
+
+ dateobj->time->have_relative = 0;
+}
+
+/* {{{ proto DateTime date_sub(DateTime object, DateInterval interval)
+ Subtracts an interval to the current date in object.
+*/
+PHP_FUNCTION(date_sub)
+{
+ zval *object, *interval;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_date, &interval, date_ce_interval) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ php_date_sub(object, interval, return_value TSRMLS_CC);
RETURN_ZVAL(object, 1, 0);
}
/* }}} */
-/* {{{ proto DateTimeZone date_timezone_get(DateTime object)
+/* {{{ proto DateTimeImmutable::sub()
+*/
+PHP_METHOD(DateTimeImmutable, sub)
+{
+ zval *object, *interval, *new_object;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_immutable, &interval, date_ce_interval) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ new_object = date_clone_immutable(object TSRMLS_CC);
+ php_date_sub(new_object, interval, return_value TSRMLS_CC);
+
+ RETURN_ZVAL(new_object, 0, 1);
+}
+/* }}} */
+
+/* {{{ proto DateTimeZone date_timezone_get(DateTimeInterface object)
Return new DateTimeZone object relative to give DateTime
*/
PHP_FUNCTION(date_timezone_get)
@@ -2947,7 +3266,7 @@ PHP_FUNCTION(date_timezone_get)
php_date_obj *dateobj;
php_timezone_obj *tzobj;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, date_ce_date) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, date_ce_interface) == FAILURE) {
RETURN_FALSE;
}
dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
@@ -2976,19 +3295,11 @@ PHP_FUNCTION(date_timezone_get)
}
/* }}} */
-/* {{{ proto DateTime date_timezone_set(DateTime object, DateTimeZone object)
- Sets the timezone for the DateTime object.
-*/
-PHP_FUNCTION(date_timezone_set)
+static void php_date_timezone_set(zval *object, zval *timezone_object, zval *return_value TSRMLS_DC)
{
- zval *object;
- zval *timezone_object;
php_date_obj *dateobj;
php_timezone_obj *tzobj;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_date, &timezone_object, date_ce_timezone) == FAILURE) {
- RETURN_FALSE;
- }
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);
@@ -2998,12 +3309,45 @@ PHP_FUNCTION(date_timezone_set)
}
timelib_set_timezone(dateobj->time, tzobj->tzi.tz);
timelib_unixtime2local(dateobj->time, dateobj->time->sse);
+}
+
+/* {{{ proto DateTime date_timezone_set(DateTime object, DateTimeZone object)
+ Sets the timezone for the DateTime object.
+*/
+PHP_FUNCTION(date_timezone_set)
+{
+ zval *object;
+ zval *timezone_object;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_date, &timezone_object, date_ce_timezone) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ php_date_timezone_set(object, timezone_object, return_value TSRMLS_CC);
RETURN_ZVAL(object, 1, 0);
}
/* }}} */
-/* {{{ proto long date_offset_get(DateTime object)
+/* {{{ proto DateTimeImmutable::setTimezone()
+*/
+PHP_METHOD(DateTimeImmutable, setTimezone)
+{
+ zval *object, *new_object;
+ zval *timezone_object;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_immutable, &timezone_object, date_ce_timezone) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ new_object = date_clone_immutable(object TSRMLS_CC);
+ php_date_timezone_set(new_object, timezone_object, return_value TSRMLS_CC);
+
+ RETURN_ZVAL(new_object, 0, 1);
+}
+/* }}} */
+
+/* {{{ proto long date_offset_get(DateTimeInterface object)
Returns the DST offset.
*/
PHP_FUNCTION(date_offset_get)
@@ -3012,7 +3356,7 @@ PHP_FUNCTION(date_offset_get)
php_date_obj *dateobj;
timelib_time_offset *offset;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, date_ce_date) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, date_ce_interface) == FAILURE) {
RETURN_FALSE;
}
dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
@@ -3038,64 +3382,106 @@ PHP_FUNCTION(date_offset_get)
}
/* }}} */
-/* {{{ proto DateTime date_time_set(DateTime object, long hour, long minute[, long second])
- Sets the time.
-*/
-PHP_FUNCTION(date_time_set)
+static void php_date_time_set(zval *object, long h, long i, long s, zval *return_value TSRMLS_DC)
{
- zval *object;
php_date_obj *dateobj;
- long h, i, s = 0;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll|l", &object, date_ce_date, &h, &i, &s) == FAILURE) {
- RETURN_FALSE;
- }
dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
dateobj->time->h = h;
dateobj->time->i = i;
dateobj->time->s = s;
timelib_update_ts(dateobj->time, NULL);
+}
+
+/* {{{ proto DateTime date_time_set(DateTime object, long hour, long minute[, long second])
+ Sets the time.
+*/
+PHP_FUNCTION(date_time_set)
+{
+ zval *object;
+ long h, i, s = 0;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll|l", &object, date_ce_date, &h, &i, &s) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ php_date_time_set(object, h, i, s, return_value TSRMLS_CC);
RETURN_ZVAL(object, 1, 0);
}
/* }}} */
-/* {{{ proto DateTime date_date_set(DateTime object, long year, long month, long day)
- Sets the date.
+/* {{{ proto DateTimeImmutable::setTime()
*/
-PHP_FUNCTION(date_date_set)
+PHP_METHOD(DateTimeImmutable, setTime)
{
- zval *object;
- php_date_obj *dateobj;
- long y, m, d;
+ zval *object, *new_object;
+ long h, i, s = 0;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Olll", &object, date_ce_date, &y, &m, &d) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll|l", &object, date_ce_immutable, &h, &i, &s) == FAILURE) {
RETURN_FALSE;
}
+
+ new_object = date_clone_immutable(object TSRMLS_CC);
+ php_date_time_set(new_object, h, i, s, return_value TSRMLS_CC);
+
+ RETURN_ZVAL(new_object, 0, 1);
+}
+/* }}} */
+
+static void php_date_date_set(zval *object, long y, long m, long d, zval *return_value TSRMLS_DC)
+{
+ php_date_obj *dateobj;
+
dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
dateobj->time->y = y;
dateobj->time->m = m;
dateobj->time->d = d;
timelib_update_ts(dateobj->time, NULL);
+}
+
+/* {{{ proto DateTime date_date_set(DateTime object, long year, long month, long day)
+ Sets the date.
+*/
+PHP_FUNCTION(date_date_set)
+{
+ zval *object;
+ long y, m, d;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Olll", &object, date_ce_date, &y, &m, &d) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ php_date_date_set(object, y, m, d, return_value TSRMLS_CC);
RETURN_ZVAL(object, 1, 0);
}
/* }}} */
-/* {{{ proto DateTime date_isodate_set(DateTime object, long year, long week[, long day])
- Sets the ISO date.
+/* {{{ proto DateTimeImmutable::setDate()
*/
-PHP_FUNCTION(date_isodate_set)
+PHP_METHOD(DateTimeImmutable, setDate)
{
- zval *object;
- php_date_obj *dateobj;
- long y, w, d = 1;
+ zval *object, *new_object;
+ long y, m, d;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll|l", &object, date_ce_date, &y, &w, &d) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Olll", &object, date_ce_immutable, &y, &m, &d) == FAILURE) {
RETURN_FALSE;
}
+
+ new_object = date_clone_immutable(object TSRMLS_CC);
+ php_date_date_set(new_object, y, m, d, return_value TSRMLS_CC);
+
+ RETURN_ZVAL(new_object, 0, 1);
+}
+/* }}} */
+
+static void php_date_isodate_set(zval *object, long y, long w, long d, zval *return_value TSRMLS_DC)
+{
+ php_date_obj *dateobj;
+
dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
dateobj->time->y = y;
@@ -3106,33 +3492,91 @@ PHP_FUNCTION(date_isodate_set)
dateobj->time->have_relative = 1;
timelib_update_ts(dateobj->time, NULL);
+}
+
+/* {{{ proto DateTime date_isodate_set(DateTime object, long year, long week[, long day])
+ Sets the ISO date.
+*/
+PHP_FUNCTION(date_isodate_set)
+{
+ zval *object;
+ long y, w, d = 1;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll|l", &object, date_ce_date, &y, &w, &d) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ php_date_isodate_set(object, y, w, d, return_value TSRMLS_CC);
RETURN_ZVAL(object, 1, 0);
}
/* }}} */
-/* {{{ proto DateTime date_timestamp_set(DateTime object, long unixTimestamp)
- Sets the date and time based on an Unix timestamp.
+/* {{{ proto DateTimeImmutable::setISODate()
*/
-PHP_FUNCTION(date_timestamp_set)
+PHP_METHOD(DateTimeImmutable, setISODate)
{
- zval *object;
- php_date_obj *dateobj;
- long timestamp;
+ zval *object, *new_object;
+ long y, w, d = 1;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &object, date_ce_date, &timestamp) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oll|l", &object, date_ce_immutable, &y, &w, &d) == FAILURE) {
RETURN_FALSE;
}
+
+ new_object = date_clone_immutable(object TSRMLS_CC);
+ php_date_isodate_set(new_object, y, w, d, return_value TSRMLS_CC);
+
+ RETURN_ZVAL(new_object, 0, 1);
+}
+/* }}} */
+
+static void php_date_timestamp_set(zval *object, long timestamp, zval *return_value TSRMLS_DC)
+{
+ php_date_obj *dateobj;
+
dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
timelib_unixtime2local(dateobj->time, (timelib_sll)timestamp);
timelib_update_ts(dateobj->time, NULL);
+}
+
+/* {{{ proto DateTime date_timestamp_set(DateTime object, long unixTimestamp)
+ Sets the date and time based on an Unix timestamp.
+*/
+PHP_FUNCTION(date_timestamp_set)
+{
+ zval *object;
+ long timestamp;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &object, date_ce_date, &timestamp) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ php_date_timestamp_set(object, timestamp, return_value TSRMLS_CC);
RETURN_ZVAL(object, 1, 0);
}
/* }}} */
-/* {{{ proto long date_timestamp_get(DateTime object)
+/* {{{ proto DateTimeImmutable::setTimestamp()
+*/
+PHP_METHOD(DateTimeImmutable, setTimestamp)
+{
+ zval *object, *new_object;
+ long timestamp;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Ol", &object, date_ce_immutable, &timestamp) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ new_object = date_clone_immutable(object TSRMLS_CC);
+ php_date_timestamp_set(new_object, timestamp, return_value TSRMLS_CC);
+
+ RETURN_ZVAL(new_object, 0, 1);
+}
+/* }}} */
+
+/* {{{ proto long date_timestamp_get(DateTimeInterface object)
Gets the Unix timestamp.
*/
PHP_FUNCTION(date_timestamp_get)
@@ -3142,7 +3586,7 @@ PHP_FUNCTION(date_timestamp_get)
long timestamp;
int error;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, date_ce_date) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &object, date_ce_interface) == FAILURE) {
RETURN_FALSE;
}
dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
@@ -3257,6 +3701,85 @@ PHP_METHOD(DateTimeZone, __construct)
}
/* }}} */
+static int php_date_timezone_initialize_from_hash(zval **return_value, php_timezone_obj **tzobj, HashTable *myht TSRMLS_DC)
+{
+ zval **z_timezone = NULL;
+ zval **z_timezone_type = NULL;
+ timelib_tzinfo *tzi;
+
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
+ convert_to_long(*z_timezone_type);
+ switch (Z_LVAL_PP(z_timezone_type)) {
+ case TIMELIB_ZONETYPE_OFFSET: {
+ char *offset, *offset_start;
+
+ offset = emalloc(sizeof(char) * (Z_STRLEN_PP(z_timezone) + 1));
+ memmove(offset, Z_STRVAL_PP(z_timezone), Z_STRLEN_PP(z_timezone)+1);
+ offset_start = offset;
+
+ ++offset;
+ if(*offset_start == '+'){
+ (*tzobj)->tzi.utc_offset = -1 * timelib_parse_tz_cor(&offset);
+ } else {
+ (*tzobj)->tzi.utc_offset = timelib_parse_tz_cor(&offset);
+ }
+ efree(offset_start);
+ (*tzobj)->type = TIMELIB_ZONETYPE_OFFSET;
+ (*tzobj)->initialized = 1;
+ return SUCCESS;
+ break;
+ }
+ case TIMELIB_ZONETYPE_ABBR:
+ case TIMELIB_ZONETYPE_ID:
+ if (SUCCESS == timezone_initialize(&tzi, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
+ (*tzobj)->type = TIMELIB_ZONETYPE_ID;
+ (*tzobj)->tzi.tz = tzi;
+ (*tzobj)->initialized = 1;
+ return SUCCESS;
+ }
+ }
+ }
+ }
+ return FAILURE;
+}
+
+/* {{{ proto DateTimeZone::__set_state()
+ * */
+PHP_METHOD(DateTimeZone, __set_state)
+{
+ php_timezone_obj *tzobj;
+ zval *array;
+ HashTable *myht;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) == FAILURE) {
+ RETURN_FALSE;
+ }
+
+ myht = HASH_OF(array);
+
+ php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
+ tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
+ php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+}
+/* }}} */
+
+/* {{{ proto DateTimeZone::__wakeup()
+ * */
+PHP_METHOD(DateTimeZone, __wakeup)
+{
+ zval *object = getThis();
+ php_timezone_obj *tzobj;
+ HashTable *myht;
+
+ tzobj = (php_timezone_obj *) zend_object_store_get_object(object TSRMLS_CC);
+
+ myht = Z_OBJPROP_P(object);
+
+ php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+}
+/* }}} */
+
/* {{{ proto string timezone_name_get(DateTimeZone object)
Returns the name of the timezone.
*/
@@ -3872,10 +4395,10 @@ PHP_METHOD(DatePeriod, __construct)
zend_error_handling error_handling;
zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "OOl|l", &start, date_ce_date, &interval, date_ce_interval, &recurrences, &options) == FAILURE) {
- if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "OOO|l", &start, date_ce_date, &interval, date_ce_interval, &end, date_ce_date, &options) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "OOl|l", &start, date_ce_interface, &interval, date_ce_interval, &recurrences, &options) == FAILURE) {
+ if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "OOO|l", &start, date_ce_interface, &interval, date_ce_interval, &end, date_ce_date, &options) == FAILURE) {
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &isostr, &isostr_len, &options) == FAILURE) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "This constructor accepts either (DateTime, DateInterval, int) OR (DateTime, DateInterval, DateTime) OR (string) as arguments.");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "This constructor accepts either (DateTimeInterface, DateInterval, int) OR (DateTimeInterface, DateInterval, DateTime) OR (string) as arguments.");
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
@@ -3903,6 +4426,7 @@ PHP_METHOD(DatePeriod, __construct)
if (dpobj->end) {
timelib_update_ts(dpobj->end, NULL);
}
+ dpobj->start_ce = date_ce_date;
} else {
/* init */
intobj = (php_interval_obj *) zend_object_store_get_object(interval TSRMLS_CC);
@@ -3918,6 +4442,7 @@ PHP_METHOD(DatePeriod, __construct)
clone->tz_info = dateobj->time->tz_info;
}
dpobj->start = clone;
+ dpobj->start_ce = Z_OBJCE_P(start);
/* interval */
dpobj->interval = timelib_rel_time_clone(intobj->diff);
@@ -4377,6 +4902,7 @@ static int php_date_period_initialize_from_hash(php_period_obj *period_obj, Hash
php_date_obj *date_obj;
date_obj = zend_object_store_get_object(*ht_entry TSRMLS_CC);
period_obj->start = timelib_time_clone(date_obj->time);
+ period_obj->start_ce = Z_OBJCE_PP(ht_entry);
} else if (Z_TYPE_PP(ht_entry) != IS_NULL) {
return 0;
}
diff --git a/ext/date/php_date.h b/ext/date/php_date.h
index be0df38b69..536629a25f 100644
--- a/ext/date/php_date.h
+++ b/ext/date/php_date.h
@@ -51,7 +51,9 @@ PHP_METHOD(DateTime, __construct);
PHP_METHOD(DateTime, __wakeup);
PHP_METHOD(DateTime, __set_state);
PHP_FUNCTION(date_create);
+PHP_FUNCTION(date_create_immutable);
PHP_FUNCTION(date_create_from_format);
+PHP_FUNCTION(date_create_immutable_from_format);
PHP_FUNCTION(date_parse);
PHP_FUNCTION(date_parse_from_format);
PHP_FUNCTION(date_get_last_errors);
@@ -70,7 +72,20 @@ PHP_FUNCTION(date_isodate_set);
PHP_FUNCTION(date_timestamp_set);
PHP_FUNCTION(date_timestamp_get);
+PHP_METHOD(DateTimeImmutable, __construct);
+PHP_METHOD(DateTimeImmutable, __set_state);
+PHP_METHOD(DateTimeImmutable, modify);
+PHP_METHOD(DateTimeImmutable, add);
+PHP_METHOD(DateTimeImmutable, sub);
+PHP_METHOD(DateTimeImmutable, setTimezone);
+PHP_METHOD(DateTimeImmutable, setTime);
+PHP_METHOD(DateTimeImmutable, setDate);
+PHP_METHOD(DateTimeImmutable, setISODate);
+PHP_METHOD(DateTimeImmutable, setTimestamp);
+
PHP_METHOD(DateTimeZone, __construct);
+PHP_METHOD(DateTimeZone, __wakeup);
+PHP_METHOD(DateTimeZone, __set_state);
PHP_FUNCTION(timezone_open);
PHP_FUNCTION(timezone_name_get);
PHP_FUNCTION(timezone_name_from_abbr);
@@ -131,6 +146,7 @@ struct _php_timezone_obj {
int dst;
} z;
} tzi;
+ HashTable *props;
};
struct _php_interval_obj {
@@ -143,6 +159,7 @@ struct _php_interval_obj {
struct _php_period_obj {
zend_object std;
timelib_time *start;
+ zend_class_entry *start_ce;
timelib_time *current;
timelib_time *end;
timelib_rel_time *interval;
diff --git a/ext/date/tests/014.phpt b/ext/date/tests/014.phpt
index be0847777f..5e609c8685 100644
--- a/ext/date/tests/014.phpt
+++ b/ext/date/tests/014.phpt
@@ -26,7 +26,11 @@ object(DateTime)#%d (3) {
["timezone"]=>
string(3) "UTC"
}
-object(DateTimeZone)#%d (0) {
+object(DateTimeZone)#%d (2) {
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(3) "UTC"
}
Warning: timezone_offset_get() expects exactly 2 parameters, 0 given in %s on line %d
diff --git a/ext/date/tests/DatePeriod_wrong_constructor.phpt b/ext/date/tests/DatePeriod_wrong_constructor.phpt
index 62e6aa98ac..744ca26c87 100644
--- a/ext/date/tests/DatePeriod_wrong_constructor.phpt
+++ b/ext/date/tests/DatePeriod_wrong_constructor.phpt
@@ -10,8 +10,8 @@ date.timezone=UTC
new DatePeriod();
?>
--EXPECTF--
-Fatal error: Uncaught exception 'Exception' with message 'DatePeriod::__construct(): This constructor accepts either (DateTime, DateInterval, int) OR (DateTime, DateInterval, DateTime) OR (string) as arguments.' in %s:%d
+Fatal error: Uncaught exception 'Exception' with message 'DatePeriod::__construct(): This constructor accepts either (DateTimeInterface, DateInterval, int) OR (DateTimeInterface, DateInterval, DateTime) OR (string) as arguments.' in %s:%d
Stack trace:
#0 %s(%d): DatePeriod->__construct()
#1 {main}
- thrown in %s on line %d \ No newline at end of file
+ thrown in %s on line %d
diff --git a/ext/date/tests/DateTimeZone_clone_basic1.phpt b/ext/date/tests/DateTimeZone_clone_basic1.phpt
index 6de5d4b463..a89005aaec 100644
--- a/ext/date/tests/DateTimeZone_clone_basic1.phpt
+++ b/ext/date/tests/DateTimeZone_clone_basic1.phpt
@@ -29,9 +29,17 @@ if ($clone != $orig) {
===DONE===
--EXPECTF--
*** Testing clone on DateTime objects ***
-object(DateTimeZone)#%d (0) {
+object(DateTimeZone)#%d (2) {
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(3) "UTC"
}
-object(DateTimeZone)#%d (0) {
+object(DateTimeZone)#%d (2) {
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(3) "UTC"
}
TEST PASSED : Objects equal but not indetical
===DONE===
diff --git a/ext/date/tests/DateTimeZone_clone_basic2.phpt b/ext/date/tests/DateTimeZone_clone_basic2.phpt
index a499510ff9..92f833082f 100644
--- a/ext/date/tests/DateTimeZone_clone_basic2.phpt
+++ b/ext/date/tests/DateTimeZone_clone_basic2.phpt
@@ -31,19 +31,27 @@ var_dump($d2_clone);
===DONE===
--EXPECTF--
*** Testing clone on objects whoose class derived from DateTimeZone class ***
-object(DateTimeZoneExt1)#%d (2) {
+object(DateTimeZoneExt1)#%d (4) {
["property1"]=>
int(99)
["property2"]=>
string(5) "Hello"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
}
-object(DateTimeZoneExt1)#%d (2) {
+object(DateTimeZoneExt1)#%d (4) {
["property1"]=>
int(99)
["property2"]=>
string(5) "Hello"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
}
-object(DateTimeZoneExt2)#%d (4) {
+object(DateTimeZoneExt2)#%d (6) {
["property3"]=>
bool(true)
["property4"]=>
@@ -52,8 +60,12 @@ object(DateTimeZoneExt2)#%d (4) {
int(99)
["property2"]=>
string(5) "Hello"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
}
-object(DateTimeZoneExt2)#%d (4) {
+object(DateTimeZoneExt2)#%d (6) {
["property3"]=>
bool(true)
["property4"]=>
@@ -62,5 +74,9 @@ object(DateTimeZoneExt2)#%d (4) {
int(99)
["property2"]=>
string(5) "Hello"
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
}
===DONE===
diff --git a/ext/date/tests/DateTimeZone_clone_basic3.phpt b/ext/date/tests/DateTimeZone_clone_basic3.phpt
index e85f42e876..128c8ff40b 100644
--- a/ext/date/tests/DateTimeZone_clone_basic3.phpt
+++ b/ext/date/tests/DateTimeZone_clone_basic3.phpt
@@ -30,11 +30,19 @@ var_dump($d2_clone);
*** Testing clone on DateTime objects ***
-- Create a DateTimeZone object --
-object(DateTimeZone)#%d (0) {
+object(DateTimeZone)#%d (2) {
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
}
-- Add some properties --
-object(DateTimeZone)#%d (2) {
+object(DateTimeZone)#%d (4) {
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
["property1"]=>
int(99)
["property2"]=>
@@ -42,7 +50,11 @@ object(DateTimeZone)#%d (2) {
}
-- clone it --
-object(DateTimeZone)#%d (2) {
+object(DateTimeZone)#%d (4) {
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
["property1"]=>
int(99)
["property2"]=>
@@ -50,7 +62,11 @@ object(DateTimeZone)#%d (2) {
}
-- Add some more properties --
-object(DateTimeZone)#%d (4) {
+object(DateTimeZone)#%d (6) {
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
["property1"]=>
int(99)
["property2"]=>
@@ -62,7 +78,11 @@ object(DateTimeZone)#%d (4) {
}
-- clone it --
-object(DateTimeZone)#%d (4) {
+object(DateTimeZone)#%d (6) {
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
["property1"]=>
int(99)
["property2"]=>
diff --git a/ext/date/tests/DateTimeZone_construct_basic.phpt b/ext/date/tests/DateTimeZone_construct_basic.phpt
index b681e8f9c3..2f18f81c03 100644
--- a/ext/date/tests/DateTimeZone_construct_basic.phpt
+++ b/ext/date/tests/DateTimeZone_construct_basic.phpt
@@ -21,10 +21,22 @@ var_dump( new DateTimeZone("America/Los_Angeles") );
===DONE===
--EXPECTF--
*** Testing new DateTimeZone() : basic functionality ***
-object(DateTimeZone)#%d (0) {
+object(DateTimeZone)#%d (2) {
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(3) "UTC"
}
-object(DateTimeZone)#%d (0) {
+object(DateTimeZone)#%d (2) {
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
}
-object(DateTimeZone)#%d (0) {
+object(DateTimeZone)#%d (2) {
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(19) "America/Los_Angeles"
}
===DONE===
diff --git a/ext/date/tests/DateTimeZone_serialize_type_1.phpt b/ext/date/tests/DateTimeZone_serialize_type_1.phpt
new file mode 100644
index 0000000000..51a5c53b23
--- /dev/null
+++ b/ext/date/tests/DateTimeZone_serialize_type_1.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Test serialization of DateTimeZone objects
+--FILE--
+<?php
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+$tz1 = date_create("2012-01-01 10:00 +1:00")->getTimezone();
+var_dump( $tz1 );
+$serialized = serialize($tz1);
+var_dump($serialized);
+
+$tz2 = unserialize($serialized);
+var_dump($tz2);
+// Try to use unserialzied object
+var_dump( $tz2->getName() );
+
+?>
+===DONE===
+--EXPECTF--
+object(DateTimeZone)#%d (2) {
+ ["timezone_type"]=>
+ int(1)
+ ["timezone"]=>
+ string(6) "+01:00"
+}
+string(77) "O:12:"DateTimeZone":2:{s:13:"timezone_type";i:1;s:8:"timezone";s:6:"+01:00";}"
+object(DateTimeZone)#%d (2) {
+ ["timezone_type"]=>
+ int(1)
+ ["timezone"]=>
+ string(6) "+01:00"
+}
+string(6) "+01:00"
+===DONE===
diff --git a/ext/date/tests/DateTimeZone_serialize_type_2.phpt b/ext/date/tests/DateTimeZone_serialize_type_2.phpt
new file mode 100644
index 0000000000..a264322f3e
--- /dev/null
+++ b/ext/date/tests/DateTimeZone_serialize_type_2.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Test serialization of DateTimeZone objects
+--FILE--
+<?php
+//Set the default time zone
+date_default_timezone_set("Europe/London");
+
+$tz1 = new DateTimeZone("EST");
+var_dump( $tz1 );
+$serialized = serialize($tz1);
+var_dump($serialized);
+
+$tz2 = unserialize($serialized);
+var_dump($tz2);
+// Try to use unserialzied object
+var_dump( $tz2->getName() );
+
+?>
+===DONE===
+--EXPECTF--
+object(DateTimeZone)#%d (2) {
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(16) "America/New_York"
+}
+string(88) "O:12:"DateTimeZone":2:{s:13:"timezone_type";i:3;s:8:"timezone";s:16:"America/New_York";}"
+object(DateTimeZone)#%d (2) {
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(16) "America/New_York"
+}
+string(16) "America/New_York"
+===DONE===
diff --git a/ext/date/tests/DateTimeZone_serialize.phpt b/ext/date/tests/DateTimeZone_serialize_type_3.phpt
index 08dd934466..49b9349bb8 100644
--- a/ext/date/tests/DateTimeZone_serialize.phpt
+++ b/ext/date/tests/DateTimeZone_serialize_type_3.phpt
@@ -18,12 +18,18 @@ var_dump( $tz2->getName() );
?>
===DONE===
--EXPECTF--
-object(DateTimeZone)#%d (0) {
+object(DateTimeZone)#%d (2) {
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(16) "America/New_York"
}
-string(24) "O:12:"DateTimeZone":0:{}"
-object(DateTimeZone)#%d (0) {
+string(88) "O:12:"DateTimeZone":2:{s:13:"timezone_type";i:3;s:8:"timezone";s:16:"America/New_York";}"
+object(DateTimeZone)#%d (2) {
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(16) "America/New_York"
}
-
-Warning: DateTimeZone::getName(): The DateTimeZone object has not been correctly initialized by its constructor in %s on line %d
-bool(false)
-===DONE=== \ No newline at end of file
+string(16) "America/New_York"
+===DONE===
diff --git a/ext/date/tests/DateTimeZone_verify.phpt b/ext/date/tests/DateTimeZone_verify.phpt
index 3ca09131a7..241d91e665 100644
--- a/ext/date/tests/DateTimeZone_verify.phpt
+++ b/ext/date/tests/DateTimeZone_verify.phpt
@@ -26,7 +26,7 @@ object(ReflectionClass)#%d (1) {
string(12) "DateTimeZone"
}
..and get names of all its methods
-array(7) {
+array(9) {
[0]=>
&object(ReflectionMethod)#%d (2) {
["name"]=>
@@ -37,41 +37,55 @@ array(7) {
[1]=>
&object(ReflectionMethod)#%d (2) {
["name"]=>
- string(7) "getName"
+ string(8) "__wakeup"
["class"]=>
string(12) "DateTimeZone"
}
[2]=>
&object(ReflectionMethod)#%d (2) {
["name"]=>
- string(9) "getOffset"
+ string(11) "__set_state"
["class"]=>
string(12) "DateTimeZone"
}
[3]=>
&object(ReflectionMethod)#%d (2) {
["name"]=>
- string(14) "getTransitions"
+ string(7) "getName"
["class"]=>
string(12) "DateTimeZone"
}
[4]=>
&object(ReflectionMethod)#%d (2) {
["name"]=>
- string(11) "getLocation"
+ string(9) "getOffset"
["class"]=>
string(12) "DateTimeZone"
}
[5]=>
&object(ReflectionMethod)#%d (2) {
["name"]=>
- string(17) "listAbbreviations"
+ string(14) "getTransitions"
["class"]=>
string(12) "DateTimeZone"
}
[6]=>
&object(ReflectionMethod)#%d (2) {
["name"]=>
+ string(11) "getLocation"
+ ["class"]=>
+ string(12) "DateTimeZone"
+ }
+ [7]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
+ string(17) "listAbbreviations"
+ ["class"]=>
+ string(12) "DateTimeZone"
+ }
+ [8]=>
+ &object(ReflectionMethod)#%d (2) {
+ ["name"]=>
string(15) "listIdentifiers"
["class"]=>
string(12) "DateTimeZone"
@@ -108,4 +122,4 @@ array(14) {
["PER_COUNTRY"]=>
int(4096)
}
-===DONE=== \ No newline at end of file
+===DONE===
diff --git a/ext/date/tests/bug60774.phpt b/ext/date/tests/bug60774.phpt
new file mode 100644
index 0000000000..7045cd7781
--- /dev/null
+++ b/ext/date/tests/bug60774.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Bug #60774 (DateInterval::format("%a") is always zero when an interval is created using the createFromDateString method)
+--FILE--
+<?php
+$i= DateInterval::createFromDateString('2 days');
+var_dump($i);
+echo $i->format("%d"), "\n";
+echo $i->format("%a"), "\n";
+?>
+--EXPECTF--
+object(DateInterval)#1 (%d) {
+ ["y"]=>
+ int(0)
+ ["m"]=>
+ int(0)
+ ["d"]=>
+ int(2)
+ ["h"]=>
+ int(0)
+ ["i"]=>
+ int(0)
+ ["s"]=>
+ int(0)
+ ["weekday"]=>
+ int(0)
+ ["weekday_behavior"]=>
+ int(0)
+ ["first_last_day_of"]=>
+ int(0)
+ ["invert"]=>
+ int(0)
+ ["days"]=>
+ bool(false)
+ ["special_type"]=>
+ int(0)
+ ["special_amount"]=>
+ int(0)
+ ["have_weekday_relative"]=>
+ int(0)
+ ["have_special_relative"]=>
+ int(0)
+}
+2
+(unknown)
diff --git a/ext/date/tests/bug61642.phpt b/ext/date/tests/bug61642.phpt
new file mode 100644
index 0000000000..d03a814d88
--- /dev/null
+++ b/ext/date/tests/bug61642.phpt
@@ -0,0 +1,62 @@
+--TEST--
+Bug #61642 (modify("+5 weekdays") returns Sunday)
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+// ±5 and ±10 (and any non-zero multiple of 5) is broken, but everything else
+// should already work correctly.
+$weekdays = range(-11, 11);
+$dates = array('2012-03-29', '2012-03-30', '2012-03-31', '2012-04-01', '2012-04-02', '2012-04-03', '2012-04-04', '2012-04-05');
+
+$header = array();
+
+foreach ($dates as $startdate) {
+ $date = new DateTime($startdate);
+
+ $header[] = $date->format('Y-m-d D');
+}
+
+echo '### ', implode(' ', $header), "\n\n";
+
+foreach ($weekdays as $days) {
+ $line = array();
+
+ printf('%+3d ', $days);
+
+ foreach ($dates as $startdate) {
+ $date = new DateTime($startdate);
+ $date->modify("{$days} weekdays");
+
+ $line[] = $date->format('Y-m-d D');
+ }
+
+ echo implode(' ', $line), "\n";
+}
+?>
+--EXPECTF--
+### 2012-03-29 Thu 2012-03-30 Fri 2012-03-31 Sat 2012-04-01 Sun 2012-04-02 Mon 2012-04-03 Tue 2012-04-04 Wed 2012-04-05 Thu
+
+-11 2012-03-14 Wed 2012-03-15 Thu 2012-03-16 Fri 2012-03-16 Fri 2012-03-16 Fri 2012-03-19 Mon 2012-03-20 Tue 2012-03-21 Wed
+-10 2012-03-15 Thu 2012-03-16 Fri 2012-03-19 Mon 2012-03-19 Mon 2012-03-19 Mon 2012-03-20 Tue 2012-03-21 Wed 2012-03-22 Thu
+ -9 2012-03-16 Fri 2012-03-19 Mon 2012-03-20 Tue 2012-03-20 Tue 2012-03-20 Tue 2012-03-21 Wed 2012-03-22 Thu 2012-03-23 Fri
+ -8 2012-03-19 Mon 2012-03-20 Tue 2012-03-21 Wed 2012-03-21 Wed 2012-03-21 Wed 2012-03-22 Thu 2012-03-23 Fri 2012-03-26 Mon
+ -7 2012-03-20 Tue 2012-03-21 Wed 2012-03-22 Thu 2012-03-22 Thu 2012-03-22 Thu 2012-03-23 Fri 2012-03-26 Mon 2012-03-27 Tue
+ -6 2012-03-21 Wed 2012-03-22 Thu 2012-03-23 Fri 2012-03-23 Fri 2012-03-23 Fri 2012-03-26 Mon 2012-03-27 Tue 2012-03-28 Wed
+ -5 2012-03-22 Thu 2012-03-23 Fri 2012-03-26 Mon 2012-03-26 Mon 2012-03-26 Mon 2012-03-27 Tue 2012-03-28 Wed 2012-03-29 Thu
+ -4 2012-03-23 Fri 2012-03-26 Mon 2012-03-27 Tue 2012-03-27 Tue 2012-03-27 Tue 2012-03-28 Wed 2012-03-29 Thu 2012-03-30 Fri
+ -3 2012-03-26 Mon 2012-03-27 Tue 2012-03-28 Wed 2012-03-28 Wed 2012-03-28 Wed 2012-03-29 Thu 2012-03-30 Fri 2012-04-02 Mon
+ -2 2012-03-27 Tue 2012-03-28 Wed 2012-03-29 Thu 2012-03-29 Thu 2012-03-29 Thu 2012-03-30 Fri 2012-04-02 Mon 2012-04-03 Tue
+ -1 2012-03-28 Wed 2012-03-29 Thu 2012-03-30 Fri 2012-03-30 Fri 2012-03-30 Fri 2012-04-02 Mon 2012-04-03 Tue 2012-04-04 Wed
+ +0 2012-03-29 Thu 2012-03-30 Fri 2012-04-02 Mon 2012-04-02 Mon 2012-04-02 Mon 2012-04-03 Tue 2012-04-04 Wed 2012-04-05 Thu
+ +1 2012-03-30 Fri 2012-04-02 Mon 2012-04-02 Mon 2012-04-02 Mon 2012-04-03 Tue 2012-04-04 Wed 2012-04-05 Thu 2012-04-06 Fri
+ +2 2012-04-02 Mon 2012-04-03 Tue 2012-04-03 Tue 2012-04-03 Tue 2012-04-04 Wed 2012-04-05 Thu 2012-04-06 Fri 2012-04-09 Mon
+ +3 2012-04-03 Tue 2012-04-04 Wed 2012-04-04 Wed 2012-04-04 Wed 2012-04-05 Thu 2012-04-06 Fri 2012-04-09 Mon 2012-04-10 Tue
+ +4 2012-04-04 Wed 2012-04-05 Thu 2012-04-05 Thu 2012-04-05 Thu 2012-04-06 Fri 2012-04-09 Mon 2012-04-10 Tue 2012-04-11 Wed
+ +5 2012-04-05 Thu 2012-04-06 Fri 2012-04-06 Fri 2012-04-06 Fri 2012-04-09 Mon 2012-04-10 Tue 2012-04-11 Wed 2012-04-12 Thu
+ +6 2012-04-06 Fri 2012-04-09 Mon 2012-04-09 Mon 2012-04-09 Mon 2012-04-10 Tue 2012-04-11 Wed 2012-04-12 Thu 2012-04-13 Fri
+ +7 2012-04-09 Mon 2012-04-10 Tue 2012-04-10 Tue 2012-04-10 Tue 2012-04-11 Wed 2012-04-12 Thu 2012-04-13 Fri 2012-04-16 Mon
+ +8 2012-04-10 Tue 2012-04-11 Wed 2012-04-11 Wed 2012-04-11 Wed 2012-04-12 Thu 2012-04-13 Fri 2012-04-16 Mon 2012-04-17 Tue
+ +9 2012-04-11 Wed 2012-04-12 Thu 2012-04-12 Thu 2012-04-12 Thu 2012-04-13 Fri 2012-04-16 Mon 2012-04-17 Tue 2012-04-18 Wed
++10 2012-04-12 Thu 2012-04-13 Fri 2012-04-13 Fri 2012-04-13 Fri 2012-04-16 Mon 2012-04-17 Tue 2012-04-18 Wed 2012-04-19 Thu
++11 2012-04-13 Fri 2012-04-16 Mon 2012-04-16 Mon 2012-04-16 Mon 2012-04-17 Tue 2012-04-18 Wed 2012-04-19 Thu 2012-04-20 Fri
diff --git a/ext/date/tests/bug65184.phpt b/ext/date/tests/bug65184.phpt
new file mode 100644
index 0000000000..9bb68558aa
--- /dev/null
+++ b/ext/date/tests/bug65184.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Test bug #65184 strftime() returns insufficient-length string under multibyte locales
+--SKIPIF--
+<?php
+if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
+ die("skip Test is valid for Windows");
+}
+?>
+--INI--
+date.timezone = UTC
+--FILE--
+<?php
+ setlocale(LC_ALL, 'Japanese_Japan.932');
+ /* timestamp has to be some wednesday */
+ $s = strftime('%A', 1372884126);
+
+ for ($i = 0; $i < strlen($s); $i++) {
+ printf("%x ", ord($s[$i]));
+ }
+ echo "\n";
+
+ echo strlen(strftime('%A')), "\n";
+?>
+===DONE===
+--EXPECT--
+90 85 97 6a 93 fa
+6
+===DONE===
diff --git a/ext/date/tests/bug65502.phpt b/ext/date/tests/bug65502.phpt
new file mode 100644
index 0000000000..8819c1ff74
--- /dev/null
+++ b/ext/date/tests/bug65502.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Test for bug #65502: DateTimeImmutable::createFromFormat returns DateTime
+--CREDITS--
+Boro Sitnikovski <buritomath@yahoo.com>
+--INI--
+date.timezone = UTC
+--FILE--
+<?php
+echo get_class(DateTimeImmutable::createFromFormat('j-M-Y', '12-Sep-2013'));
+?>
+--EXPECT--
+DateTimeImmutable
diff --git a/ext/date/tests/bug65548.phpt b/ext/date/tests/bug65548.phpt
new file mode 100644
index 0000000000..53f2519f6d
--- /dev/null
+++ b/ext/date/tests/bug65548.phpt
@@ -0,0 +1,34 @@
+--TEST--
+Test for bug #65548: Comparison for DateTimeImmutable doesn't work
+--CREDITS--
+Boro Sitnikovski <buritomath@yahoo.com>
+--INI--
+date.timezone = UTC
+--FILE--
+<?php
+$iToday = new DateTimeImmutable('today');
+$iTomorrow = new DateTimeImmutable('tomorrow');
+
+$mToday = new DateTime('today');
+$mTomorrow = new DateTime('tomorrow');
+
+var_dump($iToday < $iTomorrow);
+var_dump($iToday == $iTomorrow);
+var_dump($iToday > $iTomorrow);
+
+var_dump($iToday == $mToday);
+var_dump($iToday === $mToday);
+
+var_dump($iToday < $mTomorrow);
+var_dump($iToday == $mTomorrow);
+var_dump($iToday > $mTomorrow);
+?>
+--EXPECT--
+bool(true)
+bool(false)
+bool(false)
+bool(true)
+bool(false)
+bool(true)
+bool(false)
+bool(false)
diff --git a/ext/date/tests/date_format_error.phpt b/ext/date/tests/date_format_error.phpt
index 967695a86d..a563d0d974 100644
--- a/ext/date/tests/date_format_error.phpt
+++ b/ext/date/tests/date_format_error.phpt
@@ -56,12 +56,12 @@ bool(false)
-- Testing date_create() function with an invalid values for $object argument --
-Warning: date_format() expects parameter 1 to be DateTime, object given in %sp on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, object given in %sp on line %d
bool(false)
-Warning: date_format() expects parameter 1 to be DateTime, integer given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-Warning: date_format() expects parameter 1 to be DateTime, null given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
===DONE===
diff --git a/ext/date/tests/date_format_variation1.phpt b/ext/date/tests/date_format_variation1.phpt
index 025b7d332f..e5efc07356 100644
--- a/ext/date/tests/date_format_variation1.phpt
+++ b/ext/date/tests/date_format_variation1.phpt
@@ -2,10 +2,10 @@
Test date_format() function : usage variation - Passing unexpected values to first argument $object.
--FILE--
<?php
-/* Prototype : string date_format ( DateTime $object , string $format )
+/* Prototype : string date_format ( DateTimeInterface $object , string $format )
* Description: Returns date formatted according to given format
* Source code: ext/date/php_date.c
- * Alias to functions: DateTime::format
+ * Alias to functions: DateTimeInterface::format
*/
echo "*** Testing date_format() : usage variation - unexpected values to first argument \$object***\n";
@@ -112,141 +112,141 @@ fclose( $file_handle );
-- int 0 --
-Warning: date_format() expects parameter 1 to be DateTime, integer given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int 1 --
-Warning: date_format() expects parameter 1 to be DateTime, integer given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int 12345 --
-Warning: date_format() expects parameter 1 to be DateTime, integer given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int -12345 --
-Warning: date_format() expects parameter 1 to be DateTime, integer given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- float 10.5 --
-Warning: date_format() expects parameter 1 to be DateTime, double given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- float -10.5 --
-Warning: date_format() expects parameter 1 to be DateTime, double given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- float .5 --
-Warning: date_format() expects parameter 1 to be DateTime, double given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- empty array --
-Warning: date_format() expects parameter 1 to be DateTime, array given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- int indexed array --
-Warning: date_format() expects parameter 1 to be DateTime, array given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- associative array --
-Warning: date_format() expects parameter 1 to be DateTime, array given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- nested arrays --
-Warning: date_format() expects parameter 1 to be DateTime, array given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- uppercase NULL --
-Warning: date_format() expects parameter 1 to be DateTime, null given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- lowercase null --
-Warning: date_format() expects parameter 1 to be DateTime, null given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- lowercase true --
-Warning: date_format() expects parameter 1 to be DateTime, boolean given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- lowercase false --
-Warning: date_format() expects parameter 1 to be DateTime, boolean given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- uppercase TRUE --
-Warning: date_format() expects parameter 1 to be DateTime, boolean given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- uppercase FALSE --
-Warning: date_format() expects parameter 1 to be DateTime, boolean given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- empty string DQ --
-Warning: date_format() expects parameter 1 to be DateTime, string given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- empty string SQ --
-Warning: date_format() expects parameter 1 to be DateTime, string given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- string DQ --
-Warning: date_format() expects parameter 1 to be DateTime, string given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- string SQ --
-Warning: date_format() expects parameter 1 to be DateTime, string given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- mixed case string --
-Warning: date_format() expects parameter 1 to be DateTime, string given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- heredoc --
-Warning: date_format() expects parameter 1 to be DateTime, string given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- instance of classWithToString --
-Warning: date_format() expects parameter 1 to be DateTime, object given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
bool(false)
-- instance of classWithoutToString --
-Warning: date_format() expects parameter 1 to be DateTime, object given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
bool(false)
-- undefined var --
-Warning: date_format() expects parameter 1 to be DateTime, null given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- unset var --
-Warning: date_format() expects parameter 1 to be DateTime, null given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- resource --
-Warning: date_format() expects parameter 1 to be DateTime, resource given in %s on line %d
+Warning: date_format() expects parameter 1 to be DateTimeInterface, resource given in %s on line %d
bool(false)
===DONE===
diff --git a/ext/date/tests/date_offset_get_error.phpt b/ext/date/tests/date_offset_get_error.phpt
index bd4e429225..8531845ca7 100644
--- a/ext/date/tests/date_offset_get_error.phpt
+++ b/ext/date/tests/date_offset_get_error.phpt
@@ -3,10 +3,10 @@ Test date_offset_get() function : error conditions
--FILE--
<?php
-/* Prototype : int date_offset_get ( DateTime $object )
+/* Prototype : int date_offset_get ( DateTimeInterface $object )
* Description: Returns the daylight saving time offset
* Source code: ext/date/php_date.c
- * Alias to functions: DateTime::getOffset
+ * Alias to functions: DateTimeInterface::getOffset
*/
//Set the default time zone
@@ -46,12 +46,12 @@ bool(false)
-- Testing date_offset_get() function with an invalid values for $object argument --
-Warning: date_offset_get() expects parameter 1 to be DateTime, object given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
bool(false)
-Warning: date_offset_get() expects parameter 1 to be DateTime, integer given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-Warning: date_offset_get() expects parameter 1 to be DateTime, null given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
===DONE===
diff --git a/ext/date/tests/date_offset_get_variation1.phpt b/ext/date/tests/date_offset_get_variation1.phpt
index 9df6e2d16b..4b67b90646 100644
--- a/ext/date/tests/date_offset_get_variation1.phpt
+++ b/ext/date/tests/date_offset_get_variation1.phpt
@@ -2,10 +2,10 @@
Test date_offset_get() function : usage variation - Passing unexpected values to first argument $object.
--FILE--
<?php
-/* Prototype : int date_offset_get ( DateTime $object )
+/* Prototype : int date_offset_get ( DateTimeInterface $object )
* Description: Returns the daylight saving time offset
* Source code: ext/date/php_date.c
- * Alias to functions: DateTime::getOffset
+ * Alias to functions: DateTimeInterface::getOffset
*/
echo "*** Testing date_offset_get() : usage variation - unexpected values to first argument \$object***\n";
@@ -110,141 +110,141 @@ fclose( $file_handle );
-- int 0 --
-Warning: date_offset_get() expects parameter 1 to be DateTime, integer given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int 1 --
-Warning: date_offset_get() expects parameter 1 to be DateTime, integer given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int 12345 --
-Warning: date_offset_get() expects parameter 1 to be DateTime, integer given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int -12345 --
-Warning: date_offset_get() expects parameter 1 to be DateTime, integer given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- float 10.5 --
-Warning: date_offset_get() expects parameter 1 to be DateTime, double given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- float -10.5 --
-Warning: date_offset_get() expects parameter 1 to be DateTime, double given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- float .5 --
-Warning: date_offset_get() expects parameter 1 to be DateTime, double given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- empty array --
-Warning: date_offset_get() expects parameter 1 to be DateTime, array given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- int indexed array --
-Warning: date_offset_get() expects parameter 1 to be DateTime, array given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- associative array --
-Warning: date_offset_get() expects parameter 1 to be DateTime, array given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- nested arrays --
-Warning: date_offset_get() expects parameter 1 to be DateTime, array given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- uppercase NULL --
-Warning: date_offset_get() expects parameter 1 to be DateTime, null given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- lowercase null --
-Warning: date_offset_get() expects parameter 1 to be DateTime, null given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- lowercase true --
-Warning: date_offset_get() expects parameter 1 to be DateTime, boolean given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- lowercase false --
-Warning: date_offset_get() expects parameter 1 to be DateTime, boolean given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- uppercase TRUE --
-Warning: date_offset_get() expects parameter 1 to be DateTime, boolean given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- uppercase FALSE --
-Warning: date_offset_get() expects parameter 1 to be DateTime, boolean given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- empty string DQ --
-Warning: date_offset_get() expects parameter 1 to be DateTime, string given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- empty string SQ --
-Warning: date_offset_get() expects parameter 1 to be DateTime, string given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- string DQ --
-Warning: date_offset_get() expects parameter 1 to be DateTime, string given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- string SQ --
-Warning: date_offset_get() expects parameter 1 to be DateTime, string given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- mixed case string --
-Warning: date_offset_get() expects parameter 1 to be DateTime, string given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- heredoc --
-Warning: date_offset_get() expects parameter 1 to be DateTime, string given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- instance of classWithToString --
-Warning: date_offset_get() expects parameter 1 to be DateTime, object given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
bool(false)
-- instance of classWithoutToString --
-Warning: date_offset_get() expects parameter 1 to be DateTime, object given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
bool(false)
-- undefined var --
-Warning: date_offset_get() expects parameter 1 to be DateTime, null given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- unset var --
-Warning: date_offset_get() expects parameter 1 to be DateTime, null given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- resource --
-Warning: date_offset_get() expects parameter 1 to be DateTime, resource given in %s on line %d
+Warning: date_offset_get() expects parameter 1 to be DateTimeInterface, resource given in %s on line %d
bool(false)
===DONE===
diff --git a/ext/date/tests/date_period-immutable.phpt b/ext/date/tests/date_period-immutable.phpt
new file mode 100644
index 0000000000..0ec4b4a130
--- /dev/null
+++ b/ext/date/tests/date_period-immutable.phpt
@@ -0,0 +1,56 @@
+--TEST--
+DatePeriod
+--FILE--
+<?php
+date_default_timezone_set('UTC');
+$db1 = new DateTimeImmutable( '2008-01-01' );
+$db2 = new DateTime( '2008-01-01' );
+$de = new DateTime( '2008-03-31' );
+$di = DateInterval::createFromDateString( 'first day of next month' );
+
+foreach ( new DatePeriod( $db1, $di, $de ) as $dt )
+{
+ echo get_class( $dt ), "\n";
+ echo $dt->format( "l Y-m-d\n" );
+ echo $dt->modify( "3 tuesday" )->format( "l Y-m-d\n" );
+ echo $dt->format( "l Y-m-d\n\n" );
+}
+
+foreach ( new DatePeriod( $db2, $di, $de ) as $dt )
+{
+ echo get_class( $dt ), "\n";
+ echo $dt->format( "l Y-m-d\n" );
+ echo $dt->modify( "3 tuesday" )->format( "l Y-m-d\n" );
+ echo $dt->format( "l Y-m-d\n\n" );
+}
+?>
+--EXPECT--
+DateTimeImmutable
+Tuesday 2008-01-01
+Tuesday 2008-01-15
+Tuesday 2008-01-01
+
+DateTimeImmutable
+Friday 2008-02-01
+Tuesday 2008-02-19
+Friday 2008-02-01
+
+DateTimeImmutable
+Saturday 2008-03-01
+Tuesday 2008-03-18
+Saturday 2008-03-01
+
+DateTime
+Tuesday 2008-01-01
+Tuesday 2008-01-15
+Tuesday 2008-01-15
+
+DateTime
+Friday 2008-02-01
+Tuesday 2008-02-19
+Tuesday 2008-02-19
+
+DateTime
+Saturday 2008-03-01
+Tuesday 2008-03-18
+Tuesday 2008-03-18
diff --git a/ext/date/tests/date_time_immutable-inherited.phpt b/ext/date/tests/date_time_immutable-inherited.phpt
new file mode 100644
index 0000000000..ad8b7edb84
--- /dev/null
+++ b/ext/date/tests/date_time_immutable-inherited.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Tests for DateTimeImmutable.
+--INI--
+date.timezone=Europe/London
+--FILE--
+<?php
+$tz = new DateTimeZone("Asia/Tokyo");
+$current = "2012-12-27 16:24:08";
+
+echo "\ngetTimezone():\n";
+$v = date_create_immutable($current);
+$x = $v->getTimezone();
+var_dump($x->getName());
+
+echo "\ngetTimestamp():\n";
+$v = date_create_immutable($current);
+$x = $v->getTimestamp();
+var_dump($x);
+?>
+--EXPECT--
+getTimezone():
+string(13) "Europe/London"
+
+getTimestamp():
+int(1356625448)
diff --git a/ext/date/tests/date_time_immutable.phpt b/ext/date/tests/date_time_immutable.phpt
new file mode 100644
index 0000000000..b4a576570e
--- /dev/null
+++ b/ext/date/tests/date_time_immutable.phpt
@@ -0,0 +1,167 @@
+--TEST--
+Tests for DateTimeImmutable.
+--INI--
+date.timezone=Europe/London
+--FILE--
+<?php
+$tz = new DateTimeZone("Asia/Tokyo");
+$current = "2012-12-27 16:24:08";
+
+function dump($a, $b, $c)
+{
+ echo 'orig: ', $a->format('Y-m-d H:i:s e'), "\n";
+ echo 'copy: ', $b->format('Y-m-d H:i:s e'), "\n";
+ echo 'changed: ', $c->format('Y-m-d H:i:s e'), "\n";
+}
+
+echo "modify():\n";
+$v = date_create_immutable($current);
+$z = $v;
+$x = $z->modify("+2 days");
+dump($v, $z, $x);
+$v = date_create($current);
+$z = $v;
+$x = $z->modify("+2 days");
+dump($v, $z, $x);
+
+echo "\nadd():\n";
+$v = date_create_immutable($current);
+$z = $v;
+$x = $z->add(new DateInterval("P2DT2S"));
+dump($v, $z, $x);
+$v = date_create($current);
+$z = $v;
+$x = $z->add(new DateInterval("P2DT2S"));
+dump($v, $z, $x);
+
+echo "\nsub():\n";
+$v = date_create_immutable($current);
+$z = $v;
+$x = $z->sub(new DateInterval("P2DT2S"));
+dump($v, $z, $x);
+$v = date_create($current);
+$z = $v;
+$x = $z->sub(new DateInterval("P2DT2S"));
+dump($v, $z, $x);
+
+echo "\nsetTimezone():\n";
+$v = date_create_immutable($current);
+$z = $v;
+$x = $z->setTimezone($tz);
+dump($v, $z, $x);
+$v = date_create($current);
+$z = $v;
+$x = $z->setTimezone($tz);
+dump($v, $z, $x);
+$v = new DateTimeImmutable($current);
+$z = $v;
+$x = $z->setTimezone($tz);
+dump($v, $z, $x);
+
+echo "\nsetTime():\n";
+$v = date_create_immutable($current);
+$z = $v;
+$x = $z->setTime(5, 7, 19);
+dump($v, $z, $x);
+$v = date_create($current);
+$z = $v;
+$x = $z->setTime(5, 7, 19);
+dump($v, $z, $x);
+
+echo "\nsetDate():\n";
+$v = date_create_immutable($current);
+$z = $v;
+$x = $z->setDate(5, 7, 19);
+dump($v, $z, $x);
+$v = date_create($current);
+$z = $v;
+$x = $z->setDate(5, 7, 19);
+dump($v, $z, $x);
+
+echo "\nsetIsoDate():\n";
+$v = date_create_immutable($current);
+$z = $v;
+$x = $z->setIsoDate(2012, 2, 6);
+dump($v, $z, $x);
+$v = date_create($current);
+$z = $v;
+$x = $z->setIsoDate(2012, 2, 6);
+dump($v, $z, $x);
+
+echo "\nsetTimestamp():\n";
+$v = date_create_immutable($current);
+$z = $v;
+$x = $z->setTimestamp(2012234222);
+dump($v, $z, $x);
+$v = date_create($current);
+$z = $v;
+$x = $z->setTimestamp(2012234222);
+dump($v, $z, $x);
+?>
+--EXPECT--
+modify():
+orig: 2012-12-27 16:24:08 Europe/London
+copy: 2012-12-27 16:24:08 Europe/London
+changed: 2012-12-29 16:24:08 Europe/London
+orig: 2012-12-29 16:24:08 Europe/London
+copy: 2012-12-29 16:24:08 Europe/London
+changed: 2012-12-29 16:24:08 Europe/London
+
+add():
+orig: 2012-12-27 16:24:08 Europe/London
+copy: 2012-12-27 16:24:08 Europe/London
+changed: 2012-12-29 16:24:10 Europe/London
+orig: 2012-12-29 16:24:10 Europe/London
+copy: 2012-12-29 16:24:10 Europe/London
+changed: 2012-12-29 16:24:10 Europe/London
+
+sub():
+orig: 2012-12-27 16:24:08 Europe/London
+copy: 2012-12-27 16:24:08 Europe/London
+changed: 2012-12-25 16:24:06 Europe/London
+orig: 2012-12-25 16:24:06 Europe/London
+copy: 2012-12-25 16:24:06 Europe/London
+changed: 2012-12-25 16:24:06 Europe/London
+
+setTimezone():
+orig: 2012-12-27 16:24:08 Europe/London
+copy: 2012-12-27 16:24:08 Europe/London
+changed: 2012-12-28 01:24:08 Asia/Tokyo
+orig: 2012-12-28 01:24:08 Asia/Tokyo
+copy: 2012-12-28 01:24:08 Asia/Tokyo
+changed: 2012-12-28 01:24:08 Asia/Tokyo
+orig: 2012-12-27 16:24:08 Europe/London
+copy: 2012-12-27 16:24:08 Europe/London
+changed: 2012-12-28 01:24:08 Asia/Tokyo
+
+setTime():
+orig: 2012-12-27 16:24:08 Europe/London
+copy: 2012-12-27 16:24:08 Europe/London
+changed: 2012-12-27 05:07:19 Europe/London
+orig: 2012-12-27 05:07:19 Europe/London
+copy: 2012-12-27 05:07:19 Europe/London
+changed: 2012-12-27 05:07:19 Europe/London
+
+setDate():
+orig: 2012-12-27 16:24:08 Europe/London
+copy: 2012-12-27 16:24:08 Europe/London
+changed: 0005-07-19 16:24:08 Europe/London
+orig: 0005-07-19 16:24:08 Europe/London
+copy: 0005-07-19 16:24:08 Europe/London
+changed: 0005-07-19 16:24:08 Europe/London
+
+setIsoDate():
+orig: 2012-12-27 16:24:08 Europe/London
+copy: 2012-12-27 16:24:08 Europe/London
+changed: 2012-01-14 16:24:08 Europe/London
+orig: 2012-01-14 16:24:08 Europe/London
+copy: 2012-01-14 16:24:08 Europe/London
+changed: 2012-01-14 16:24:08 Europe/London
+
+setTimestamp():
+orig: 2012-12-27 16:24:08 Europe/London
+copy: 2012-12-27 16:24:08 Europe/London
+changed: 2033-10-06 18:57:02 Europe/London
+orig: 2033-10-06 18:57:02 Europe/London
+copy: 2033-10-06 18:57:02 Europe/London
+changed: 2033-10-06 18:57:02 Europe/London
diff --git a/ext/date/tests/date_timestamp_get.phpt b/ext/date/tests/date_timestamp_get.phpt
index bdd4d047ea..ec0258bdc0 100644
--- a/ext/date/tests/date_timestamp_get.phpt
+++ b/ext/date/tests/date_timestamp_get.phpt
@@ -17,4 +17,4 @@ bool(true)
-Warning: date_timestamp_get() expects parameter 1 to be DateTime, integer given in %s on line %d \ No newline at end of file
+Warning: date_timestamp_get() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
diff --git a/ext/date/tests/date_timezone_get_error.phpt b/ext/date/tests/date_timezone_get_error.phpt
index 1310cbe9d6..01963c8224 100644
--- a/ext/date/tests/date_timezone_get_error.phpt
+++ b/ext/date/tests/date_timezone_get_error.phpt
@@ -2,10 +2,10 @@
Test date_timezone_get() function : error conditions
--FILE--
<?php
-/* Prototype : DateTimeZone date_timezone_get ( DateTime $object )
- * Description: Return time zone relative to given DateTime
+/* Prototype : DateTimeZone date_timezone_get ( DateTimeInterface $object )
+ * Description: Return time zone relative to given DateTimeInterface
* Source code: ext/date/php_date.c
- * Alias to functions: DateTime::getTimezone
+ * Alias to functions: DateTimeInterface::getTimezone
*/
// Set timezone
@@ -45,12 +45,12 @@ bool(false)
-- Testing date_timezone_get() function with an invalid values for $object argument --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, object given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
bool(false)
-Warning: date_timezone_get() expects parameter 1 to be DateTime, integer given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-Warning: date_timezone_get() expects parameter 1 to be DateTime, null given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
===DONE===
diff --git a/ext/date/tests/date_timezone_get_variation1.phpt b/ext/date/tests/date_timezone_get_variation1.phpt
index 3b2034ecc2..dd346e9d92 100644
--- a/ext/date/tests/date_timezone_get_variation1.phpt
+++ b/ext/date/tests/date_timezone_get_variation1.phpt
@@ -2,10 +2,10 @@
Test date_timezone_get() function : usage variation - Passing unexpected values to first argument $object.
--FILE--
<?php
-/* Prototype : DateTimeZone date_timezone_get ( DateTime $object )
- * Description: Return time zone relative to given DateTime
+/* Prototype : DateTimeZone date_timezone_get ( DateTimeInterface $object )
+ * Description: Return time zone relative to given DateTimeInterface
* Source code: ext/date/php_date.c
- * Alias to functions: DateTime::getTimezone
+ * Alias to functions: DateTimeInterface::getTimezone
*/
echo "*** Testing date_timezone_get() : usage variation - unexpected values to first argument \$object***\n";
@@ -110,141 +110,141 @@ fclose( $file_handle );
-- int 0 --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, integer given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int 1 --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, integer given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int 12345 --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, integer given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int -12345 --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, integer given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- float 10.5 --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, double given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- float -10.5 --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, double given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- float .5 --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, double given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- empty array --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, array given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- int indexed array --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, array given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- associative array --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, array given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- nested arrays --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, array given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- uppercase NULL --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, null given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- lowercase null --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, null given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- lowercase true --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, boolean given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- lowercase false --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, boolean given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- uppercase TRUE --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, boolean given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- uppercase FALSE --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, boolean given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- empty string DQ --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, string given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- empty string SQ --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, string given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- string DQ --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, string given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- string SQ --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, string given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- mixed case string --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, string given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- heredoc --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, string given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- instance of classWithToString --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, object given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
bool(false)
-- instance of classWithoutToString --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, object given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
bool(false)
-- undefined var --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, null given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- unset var --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, null given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- resource --
-Warning: date_timezone_get() expects parameter 1 to be DateTime, resource given in %s on line %d
+Warning: date_timezone_get() expects parameter 1 to be DateTimeInterface, resource given in %s on line %d
bool(false)
===DONE===
diff --git a/ext/date/tests/timezone_open_basic1.phpt b/ext/date/tests/timezone_open_basic1.phpt
index 7a989362b0..7fcfcb34cb 100644
--- a/ext/date/tests/timezone_open_basic1.phpt
+++ b/ext/date/tests/timezone_open_basic1.phpt
@@ -18,10 +18,22 @@ var_dump( timezone_open("America/Los_Angeles") );
===DONE===
--EXPECTF--
*** Testing timezone_open() : basic functionality ***
-object(DateTimeZone)#%d (0) {
+object(DateTimeZone)#%d (2) {
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(3) "UTC"
}
-object(DateTimeZone)#%d (0) {
+object(DateTimeZone)#%d (2) {
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(13) "Europe/London"
}
-object(DateTimeZone)#%d (0) {
+object(DateTimeZone)#%d (2) {
+ ["timezone_type"]=>
+ int(3)
+ ["timezone"]=>
+ string(19) "America/Los_Angeles"
}
===DONE=== \ No newline at end of file