-/* Generated by re2c 0.13.5 on Sat Nov 26 16:43:35 2011 */
+/* Generated by re2c 0.13.5 on Mon Dec 5 22:02:27 2011 */
#line 1 "ext/date/lib/parse_date.re"
/*
+----------------------------------------------------------------------+
return value;
}
-static long timelib_get_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_found, const timelib_tzdb *tzdb)
+static long timelib_get_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_found, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_wrapper)
{
timelib_tzinfo *res;
long retval = 0;
#endif
/* If we have a TimeZone identifier to start with, use it */
if (strstr(tz_abbr, "/") || strcmp(tz_abbr, "UTC") == 0) {
- if ((res = timelib_parse_tzfile(tz_abbr, tzdb)) != NULL) {
+ if ((res = tz_wrapper(tz_abbr, tzdb)) != NULL) {
t->tz_info = res;
t->zone_type = TIMELIB_ZONETYPE_ID;
found++;
} \
}
-static int scan(Scanner *s)
+static int scan(Scanner *s, timelib_tz_get_wrapper tz_get_wrapper)
{
uchar *cursor = s->cur;
char *str, *ptr = NULL;
DEBUG_OUTPUT("tzcorrection | tz");
TIMELIB_INIT;
TIMELIB_HAVE_TZ();
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
+ s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
}
if (*ptr != '\0') {
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
+ s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
}
if (*ptr != '\0') {
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
+ s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
s->time->h = timelib_get_nr((char **) &ptr, 2);
s->time->i = timelib_get_nr((char **) &ptr, 2);
s->time->s = timelib_get_nr((char **) &ptr, 2);
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
+ s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
if (*ptr == '.') {
s->time->f = timelib_get_frac_nr((char **) &ptr, 9);
if (*ptr) { /* timezone is optional */
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
+ s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
s->time->s = timelib_get_nr((char **) &ptr, 2);
if (*ptr != '\0') {
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
+ s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
#define YYMAXFILL 31
-timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container **errors, const timelib_tzdb *tzdb)
+timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper)
{
Scanner in;
int t;
in.time->zone_type = 0;
do {
- t = scan(&in);
+ t = scan(&in, tz_get_wrapper);
#ifdef DEBUG_PARSER
printf("%d\n", t);
#endif
if (time->f == TIMELIB_UNSET ) time->f = 0.0;
}
-timelib_time *timelib_parse_from_format(char *format, char *string, int len, timelib_error_container **errors, const timelib_tzdb *tzdb)
+timelib_time *timelib_parse_from_format(char *format, char *string, int len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper)
{
char *fptr = format;
char *ptr = string;
case 'S': /* day suffix, ignored, nor checked */
timelib_skip_day_suffix((char **) &ptr);
break;
- case 'z': /* day of year - resets month (0 based) */
+ case 'z': /* day of year - resets month (0 based) - also initializes everything else to !TIMELIB_UNSET */
TIMELIB_CHECK_NUMBER;
if ((tmp = timelib_get_nr((char **) &ptr, 3)) == TIMELIB_UNSET) {
add_pbf_error(s, "A three digit day-of-year could not be found", string, begin);
} else {
s->time->m = 1;
s->time->d = tmp + 1;
+ timelib_do_normalize(s->time);
}
break;
case 'O': /* timezone */
{
int tz_not_found;
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
+ s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_pbf_error(s, "The timezone could not be found in the database", string, begin);
}
return value;
}
-static long timelib_get_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_found, const timelib_tzdb *tzdb)
+static long timelib_get_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_found, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_wrapper)
{
timelib_tzinfo *res;
long retval = 0;
#endif
/* If we have a TimeZone identifier to start with, use it */
if (strstr(tz_abbr, "/") || strcmp(tz_abbr, "UTC") == 0) {
- if ((res = timelib_parse_tzfile(tz_abbr, tzdb)) != NULL) {
+ if ((res = tz_wrapper(tz_abbr, tzdb)) != NULL) {
t->tz_info = res;
t->zone_type = TIMELIB_ZONETYPE_ID;
found++;
} \
}
-static int scan(Scanner *s)
+static int scan(Scanner *s, timelib_tz_get_wrapper tz_get_wrapper)
{
uchar *cursor = s->cur;
char *str, *ptr = NULL;
}
if (*ptr != '\0') {
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
+ s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
s->time->h = timelib_get_nr((char **) &ptr, 2);
s->time->i = timelib_get_nr((char **) &ptr, 2);
s->time->s = 0;
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, s->tzdb);
+ s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, s->tzdb, tz_get_wrapper);
break;
case 1:
s->time->y = timelib_get_nr((char **) &ptr, 4);
s->time->s = timelib_get_nr((char **) &ptr, 2);
if (*ptr != '\0') {
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
+ s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
if (*ptr == '.') {
s->time->f = timelib_get_frac_nr((char **) &ptr, 9);
if (*ptr) { /* timezone is optional */
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
+ s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
s->time->h = timelib_get_nr((char **) &ptr, 2);
s->time->i = timelib_get_nr((char **) &ptr, 2);
s->time->s = timelib_get_nr((char **) &ptr, 2);
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
+ s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
DEBUG_OUTPUT("tzcorrection | tz");
TIMELIB_INIT;
TIMELIB_HAVE_TZ();
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
+ s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
}
if (*ptr != '\0') {
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
+ s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_error(s, "The timezone could not be found in the database");
}
/*!max:re2c */
-timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container **errors, const timelib_tzdb *tzdb)
+timelib_time* timelib_strtotime(char *s, int len, struct timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper)
{
Scanner in;
int t;
in.time->zone_type = 0;
do {
- t = scan(&in);
+ t = scan(&in, tz_get_wrapper);
#ifdef DEBUG_PARSER
printf("%d\n", t);
#endif
if (time->f == TIMELIB_UNSET ) time->f = 0.0;
}
-timelib_time *timelib_parse_from_format(char *format, char *string, int len, timelib_error_container **errors, const timelib_tzdb *tzdb)
+timelib_time *timelib_parse_from_format(char *format, char *string, int len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper)
{
char *fptr = format;
char *ptr = string;
case 'S': /* day suffix, ignored, nor checked */
timelib_skip_day_suffix((char **) &ptr);
break;
- case 'z': /* day of year - resets month (0 based) */
+ case 'z': /* day of year - resets month (0 based) - also initializes everything else to !TIMELIB_UNSET */
TIMELIB_CHECK_NUMBER;
if ((tmp = timelib_get_nr((char **) &ptr, 3)) == TIMELIB_UNSET) {
add_pbf_error(s, "A three digit day-of-year could not be found", string, begin);
} else {
s->time->m = 1;
s->time->d = tmp + 1;
+ timelib_do_normalize(s->time);
}
break;
case 'O': /* timezone */
{
int tz_not_found;
- s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
+ s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb, tz_get_wrapper);
if (tz_not_found) {
add_pbf_error(s, "The timezone could not be found in the database", string, begin);
}
#include <limits.h>
#endif
-#define TIMELIB_VERSION 201101
+#define TIMELIB_VERSION 201102
#define TIMELIB_NONE 0x00
#define TIMELIB_OVERRIDE_TIME 0x01
#define TIMELIB_NO_CLONE 0x02
+#define TIMELIB_UNSET -99999
+
#define TIMELIB_SPECIAL_WEEKDAY 0x01
#define TIMELIB_SPECIAL_DAY_OF_WEEK_IN_MONTH 0x02
#define TIMELIB_SPECIAL_LAST_DAY_OF_WEEK_IN_MONTH 0x03
#define strncasecmp strnicmp
#endif
+/* Function pointers */
+typedef timelib_tzinfo* (*timelib_tz_get_wrapper)(char *tzname, const timelib_tzdb *tzdb);
+
/* From dow.c */
timelib_sll timelib_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d);
timelib_sll timelib_iso_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d);
int timelib_valid_date(timelib_sll y, timelib_sll m, timelib_sll d);
/* From parse_date.re */
-timelib_time *timelib_strtotime(char *s, int len, timelib_error_container **errors, const timelib_tzdb *tzdb);
-timelib_time *timelib_parse_from_format(char *format, char *s, int len, timelib_error_container **errors, const timelib_tzdb *tzdb);
+timelib_time *timelib_strtotime(char *s, int len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper);
+timelib_time *timelib_parse_from_format(char *format, char *s, int len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper);
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);
/* From tm2unixtime.c */
void timelib_update_ts(timelib_time* time, timelib_tzinfo* tzi);
+void timelib_do_normalize(timelib_time *base);
void timelib_do_rel_normalize(timelib_time *base, timelib_rel_time *rt);
/* From unixtime2tm.c */
do {} while (do_range_limit(0, 12, 12, &rt->m, &rt->y));
}
-static void do_normalize(timelib_time* time)
+void timelib_do_normalize(timelib_time* time)
{
- do {} while (do_range_limit(0, 60, 60, &time->s, &time->i));
- do {} while (do_range_limit(0, 60, 60, &time->i, &time->h));
- do {} while (do_range_limit(0, 24, 24, &time->h, &time->d));
+ if (time->s != TIMELIB_UNSET) do {} while (do_range_limit(0, 60, 60, &time->s, &time->i));
+ if (time->s != TIMELIB_UNSET) do {} while (do_range_limit(0, 60, 60, &time->i, &time->h));
+ if (time->s != TIMELIB_UNSET) do {} while (do_range_limit(0, 24, 24, &time->h, &time->d));
do {} while (do_range_limit(1, 13, 12, &time->m, &time->y));
do {} while (do_range_limit_days(&time->y, &time->m, &time->d));
if (time->relative.have_weekday_relative) {
do_adjust_for_weekday(time);
}
- do_normalize(time);
+ timelib_do_normalize(time);
if (time->have_relative) {
time->s += time->relative.s;
time->m++;
break;
}
- do_normalize(time);
+ timelib_do_normalize(time);
}
static void do_adjust_special_weekday(timelib_time* time)
break;
}
}
- do_normalize(time);
+ timelib_do_normalize(time);
memset(&(time->relative.special), 0, sizeof(time->relative.special));
}
break;
}
}
- do_normalize(time);
+ timelib_do_normalize(time);
}
static timelib_sll do_years(timelib_sll year)
const zend_function_entry date_funcs_interval[] = {
PHP_ME(DateInterval, __construct, arginfo_date_interval_construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
+ PHP_ME(DateInterval, __wakeup, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(DateInterval, __set_state, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_ME_MAPPING(format, date_interval_format, arginfo_date_method_interval_format, 0)
PHP_ME_MAPPING(createFromDateString, date_interval_create_from_date_string, arginfo_date_interval_create_from_date_string, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
PHP_FE_END
}
return tzi;
}
+
+timelib_tzinfo *php_date_parse_tzfile_wrapper(char *formal_tzname, const timelib_tzdb *tzdb)
+{
+ TSRMLS_FETCH();
+ return php_date_parse_tzfile(formal_tzname, tzdb TSRMLS_CC);
+}
/* }}} */
/* {{{ Helper functions */
int error2;
signed long retval;
- parsed_time = timelib_strtotime(string, strlen(string), &error, DATE_TIMEZONEDB);
+ parsed_time = timelib_strtotime(string, strlen(string), &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
if (error->error_count) {
timelib_error_container_dtor(error);
return -1;
initial_ts = emalloc(25);
snprintf(initial_ts, 24, "@%ld UTC", preset_ts);
- t = timelib_strtotime(initial_ts, strlen(initial_ts), NULL, DATE_TIMEZONEDB); /* we ignore the error here, as this should never fail */
+ t = timelib_strtotime(initial_ts, strlen(initial_ts), NULL, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper); /* we ignore the error here, as this should never fail */
timelib_update_ts(t, tzi);
now->tz_info = tzi;
now->zone_type = TIMELIB_ZONETYPE_ID;
RETURN_FALSE;
}
- t = timelib_strtotime(times, time_len, &error, DATE_TIMEZONEDB);
+ t = timelib_strtotime(times, time_len, &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
error1 = error->error_count;
timelib_error_container_dtor(error);
timelib_fill_holes(t, now, TIMELIB_NO_CLONE);
timelib_time_dtor(dateobj->time);
}
if (format) {
- dateobj->time = timelib_parse_from_format(format, time_str_len ? time_str : "", time_str_len ? time_str_len : 0, &err, DATE_TIMEZONEDB);
+ dateobj->time = timelib_parse_from_format(format, time_str_len ? time_str : "", time_str_len ? time_str_len : 0, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
} else {
- dateobj->time = timelib_strtotime(time_str_len ? time_str : "now", time_str_len ? time_str_len : sizeof("now") -1, &err, DATE_TIMEZONEDB);
+ dateobj->time = timelib_strtotime(time_str_len ? time_str : "now", time_str_len ? time_str_len : sizeof("now") -1, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
}
/* update last errors and warnings */
RETURN_FALSE;
}
- parsed_time = timelib_strtotime(date, date_len, &error, DATE_TIMEZONEDB);
+ parsed_time = timelib_strtotime(date, date_len, &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
php_date_do_return_parsed_time(INTERNAL_FUNCTION_PARAM_PASSTHRU, parsed_time, error);
}
/* }}} */
RETURN_FALSE;
}
- parsed_time = timelib_parse_from_format(format, date, date_len, &error, DATE_TIMEZONEDB);
+ parsed_time = timelib_parse_from_format(format, date, date_len, &error, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
php_date_do_return_parsed_time(INTERNAL_FUNCTION_PARAM_PASSTHRU, parsed_time, error);
}
/* }}} */
dateobj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC);
DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
- tmp_time = timelib_strtotime(modify, modify_len, &err, DATE_TIMEZONEDB);
+ tmp_time = timelib_strtotime(modify, modify_len, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
/* update last errors and warnings */
update_errors_warnings(err TSRMLS_CC);
}
/* }}} */
+static long php_date_long_from_hash_element(HashTable *myht, char *element, size_t size)
+{
+ zval **z_arg = NULL;
+
+ if (zend_hash_find(myht, element, size + 1, (void**) &z_arg) == SUCCESS) {
+ convert_to_long(*z_arg);
+ return Z_LVAL_PP(z_arg);
+ } else {
+ return -1;
+ }
+}
+
+static int php_date_interval_initialize_from_hash(zval **return_value, php_interval_obj **intobj, HashTable *myht TSRMLS_DC)
+{
+ (*intobj)->diff = timelib_rel_time_ctor();
+
+ (*intobj)->diff->y = php_date_long_from_hash_element(myht, "y", 1);
+ (*intobj)->diff->m = php_date_long_from_hash_element(myht, "m", 1);
+ (*intobj)->diff->d = php_date_long_from_hash_element(myht, "d", 1);
+ (*intobj)->diff->h = php_date_long_from_hash_element(myht, "h", 1);
+ (*intobj)->diff->i = php_date_long_from_hash_element(myht, "i", 1);
+ (*intobj)->diff->s = php_date_long_from_hash_element(myht, "s", 1);
+ (*intobj)->diff->invert = php_date_long_from_hash_element(myht, "invert", 6);
+ (*intobj)->diff->days = php_date_long_from_hash_element(myht, "days", 4);
+ (*intobj)->initialized = 1;
+
+ return 0;
+}
+
+/* {{{ proto DateInterval::__set_state()
+*/
+PHP_METHOD(DateInterval, __set_state)
+{
+ php_interval_obj *intobj;
+ 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_interval, return_value TSRMLS_CC);
+ intobj = (php_interval_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
+ php_date_interval_initialize_from_hash(&return_value, &intobj, myht TSRMLS_CC);
+}
+/* }}} */
+
+/* {{{ proto DateInterval::__wakeup()
+*/
+PHP_METHOD(DateInterval, __wakeup)
+{
+ zval *object = getThis();
+ php_interval_obj *intobj;
+ HashTable *myht;
+
+ intobj = (php_interval_obj *) zend_object_store_get_object(object TSRMLS_CC);
+
+ myht = Z_OBJPROP_P(object);
+
+ php_date_interval_initialize_from_hash(&return_value, &intobj, myht TSRMLS_CC);
+}
+/* }}} */
/* {{{ proto DateInterval date_interval_create_from_date_string(string time)
Uses the normal date parsers and sets up a DateInterval from the relative parts of the parsed string
*/
php_date_instantiate(date_ce_interval, return_value TSRMLS_CC);
- time = timelib_strtotime(time_str, time_str_len, &err, DATE_TIMEZONEDB);
+ time = timelib_strtotime(time_str, time_str_len, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
diobj = (php_interval_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
diobj->diff = timelib_rel_time_clone(&time->relative);
diobj->initialized = 1;
case 'I': length = slprintf(buffer, 32, "%02d", (int) t->i); break;
case 'i': length = slprintf(buffer, 32, "%d", (int) t->i); break;
- case 'S': length = slprintf(buffer, 32, "%02d", (int) t->s); break;
- case 's': length = slprintf(buffer, 32, "%d", (int) t->s); break;
+ case 'S': length = slprintf(buffer, 32, "%02ld", (long) t->s); break;
+ case 's': length = slprintf(buffer, 32, "%ld", (long) t->s); break;
case 'a': {
if ((int) t->days != -99999) {
PHP_FUNCTION(timezone_version_get);
PHP_METHOD(DateInterval, __construct);
+PHP_METHOD(DateInterval, __wakeup);
+PHP_METHOD(DateInterval, __set_state);
PHP_FUNCTION(date_interval_format);
PHP_FUNCTION(date_interval_create_from_date_string);
--- /dev/null
+--TEST--
+Bug #52113: Seg fault while creating (by unserialization) DatePeriod
+--FILE--
+<?php
+$start = new DateTime('2003-01-02 08:00:00');
+$end = new DateTime('2003-01-02 12:00:00');
+$diff = $start->diff($end);
+$p = new DatePeriod($start, $diff, 2);
+$diff_s = serialize($diff);
+var_dump($diff, $diff_s);
+var_export($diff);
+
+$diff_un = unserialize($diff_s);
+$p = new DatePeriod($start, $diff_un, 2);
+var_dump($diff_un, $p);
+
+$unser = DateInterval::__set_state(array(
+ 'y' => 7,
+ 'm' => 6,
+ 'd' => 5,
+ 'h' => 4,
+ 'i' => 3,
+ 's' => 2,
+ 'invert' => 1,
+ 'days' => 2400,
+));
+
+$p = new DatePeriod($start, $diff_un, 2);
+var_dump($unser, $p);
+
+?>
+--EXPECT--
+object(DateInterval)#3 (8) {
+ ["y"]=>
+ int(0)
+ ["m"]=>
+ int(0)
+ ["d"]=>
+ int(0)
+ ["h"]=>
+ int(4)
+ ["i"]=>
+ int(0)
+ ["s"]=>
+ int(0)
+ ["invert"]=>
+ int(0)
+ ["days"]=>
+ int(0)
+}
+string(128) "O:12:"DateInterval":8:{s:1:"y";i:0;s:1:"m";i:0;s:1:"d";i:0;s:1:"h";i:4;s:1:"i";i:0;s:1:"s";i:0;s:6:"invert";i:0;s:4:"days";i:0;}"
+DateInterval::__set_state(array(
+ 'y' => 0,
+ 'm' => 0,
+ 'd' => 0,
+ 'h' => 4,
+ 'i' => 0,
+ 's' => 0,
+ 'invert' => 0,
+ 'days' => 0,
+))object(DateInterval)#5 (8) {
+ ["y"]=>
+ int(0)
+ ["m"]=>
+ int(0)
+ ["d"]=>
+ int(0)
+ ["h"]=>
+ int(4)
+ ["i"]=>
+ int(0)
+ ["s"]=>
+ int(0)
+ ["invert"]=>
+ int(0)
+ ["days"]=>
+ int(0)
+}
+object(DatePeriod)#6 (0) {
+}
+object(DateInterval)#4 (8) {
+ ["y"]=>
+ int(7)
+ ["m"]=>
+ int(6)
+ ["d"]=>
+ int(5)
+ ["h"]=>
+ int(4)
+ ["i"]=>
+ int(3)
+ ["s"]=>
+ int(2)
+ ["invert"]=>
+ int(1)
+ ["days"]=>
+ int(2400)
+}
+object(DatePeriod)#7 (0) {
+}
--TEST--
Bug #51994 (date_parse_from_format is parsing invalid date using 'yz' format)
---XFAIL--
-Bug #51994 isn't fixed yet
--FILE--
<?php
$trans_date = '10153'; // 152nd day of year 2010 -> 03.06.2010
$a_date = date_parse_from_format('yz', $trans_date);
-
var_dump($a_date);
?>
--EXPECTF--
--- /dev/null
+--TEST--
+Bug #53502: strtotime with timezone memory leak
+--FILE--
+<?php
+for ($i = 0; $i < 1000; $i++) {
+ strtotime('Monday 00:00 Europe/Paris'); // Memory leak
+}
+echo "Nothing, test only makes sense through valgrind.\n";
+?>
+--EXPECT--
+Nothing, test only makes sense through valgrind.