35static __inline __int64 php_date_llabs( __int64 i ) {
return i >= 0? i: -i; }
36#elif defined(__GNUC__) && __GNUC__ < 3
37static __inline __int64_t php_date_llabs( __int64_t i ) {
return i >= 0 ? i : -i; }
39static inline long long php_date_llabs(
long long i ) {
return i >= 0 ? i : -i; }
43#define DATE_I64_BUF_LEN 65
44# define DATE_I64A(i, s, len) _i64toa_s(i, s, len, 10)
45# define DATE_A64I(i, s) i = _atoi64(s)
47#define DATE_I64_BUF_LEN 65
48# define DATE_I64A(i, s, len) \
50 int st = snprintf(s, len, "%lld", i); \
53#define DATE_A64I(i, s) i = strtoll(s, NULL, 10)
58#ifdef HAVE_GETTIMEOFDAY
82#define DATE_FORMAT_RFC822 "D, d M y H:i:s O"
90#define DATE_FORMAT_RFC850 "l, d-M-y H:i:s T"
100#define DATE_FORMAT_RFC1036 "D, d M y H:i:s O"
107#define DATE_FORMAT_RFC1123 "D, d M Y H:i:s O"
112#define DATE_FORMAT_RFC7231 "D, d M Y H:i:s \\G\\M\\T"
134#define DATE_FORMAT_RFC2822 "D, d M Y H:i:s O"
156#define DATE_FORMAT_RFC3339 "Y-m-d\\TH:i:sP"
164#define DATE_FORMAT_ISO8601 "Y-m-d\\TH:i:sO"
186#define DATE_FORMAT_ISO8601_EXPANDED "X-m-d\\TH:i:sP"
192#define DATE_FORMAT_ISO8601_LARGE_YEAR "x-m-d\\TH:i:sP"
202#define DATE_FORMAT_RFC3339_EXTENDED "Y-m-d\\TH:i:s.vP"
210#define DATE_FORMAT_COOKIE "l, d-M-Y H:i:s T"
212#define SUNFUNCS_RET_TIMESTAMP 0
213#define SUNFUNCS_RET_STRING 1
214#define SUNFUNCS_RET_DOUBLE 2
216#define PHP_DATE_TIMEZONE_GROUP_AFRICA 0x0001
217#define PHP_DATE_TIMEZONE_GROUP_AMERICA 0x0002
218#define PHP_DATE_TIMEZONE_GROUP_ANTARCTICA 0x0004
219#define PHP_DATE_TIMEZONE_GROUP_ARCTIC 0x0008
220#define PHP_DATE_TIMEZONE_GROUP_ASIA 0x0010
221#define PHP_DATE_TIMEZONE_GROUP_ATLANTIC 0x0020
222#define PHP_DATE_TIMEZONE_GROUP_AUSTRALIA 0x0040
223#define PHP_DATE_TIMEZONE_GROUP_EUROPE 0x0080
224#define PHP_DATE_TIMEZONE_GROUP_INDIAN 0x0100
225#define PHP_DATE_TIMEZONE_GROUP_PACIFIC 0x0200
226#define PHP_DATE_TIMEZONE_GROUP_UTC 0x0400
227#define PHP_DATE_TIMEZONE_GROUP_ALL 0x07FF
228#define PHP_DATE_TIMEZONE_GROUP_ALL_W_BC 0x0FFF
229#define PHP_DATE_TIMEZONE_PER_COUNTRY 0x1000
231#define PHP_DATE_PERIOD_EXCLUDE_START_DATE 0x0001
232#define PHP_DATE_PERIOD_INCLUDE_END_DATE 0x0002
236static const char* guess_timezone(
const timelib_tzdb *tzdb);
237static void date_register_classes(
void);
247#define DATE_DEFAULT_LATITUDE "31.7667"
248#define DATE_DEFAULT_LONGITUDE "35.2333"
251#define DATE_SUNSET_ZENITH "90.833333"
254#define DATE_SUNRISE_ZENITH "90.833333"
268static
zend_class_entry *date_ce_date, *date_ce_timezone, *date_ce_interval, *date_ce_period;
270static
zend_class_entry *date_ce_date_error, *date_ce_date_object_error, *date_ce_date_range_error;
271static
zend_class_entry *date_ce_date_exception, *date_ce_date_invalid_timezone_exception, *date_ce_date_invalid_operation_exception, *date_ce_date_malformed_string_exception, *date_ce_date_malformed_interval_string_exception, *date_ce_date_malformed_period_string_exception;
281 return date_ce_immutable;
286 return date_ce_interface;
291 return date_ce_timezone;
296 return date_ce_interval;
301 return date_ce_period;
313 zend_throw_error(date_ce_date_object_error,
"Object of type %s has not been correctly initialized by calling parent::__construct() in its constructor",
ZSTR_VAL(ce->
name));
320 zend_throw_error(date_ce_date_object_error,
"Object of type %s not been correctly initialized by calling parent::__construct() in its constructor",
ZSTR_VAL(ce->
name));
323 zend_throw_error(date_ce_date_object_error,
"Object of type %s (inheriting %s) has not been correctly initialized by calling parent::__construct() in its constructor",
ZSTR_VAL(ce->
name),
ZSTR_VAL(ce_ptr->
name));
327#define DATE_CHECK_INITIALIZED(member, ce) \
328 if (UNEXPECTED(!member)) { \
329 date_throw_uninitialized_error(ce); \
333static void date_object_free_storage_date(
zend_object *
object);
334static void date_object_free_storage_timezone(
zend_object *
object);
335static void date_object_free_storage_interval(
zend_object *
object);
336static void date_object_free_storage_period(
zend_object *
object);
359static int date_interval_compare_objects(
zval *o1,
zval *o2);
367static int date_object_compare_timezone(
zval *tz1,
zval *tz2);
394 date_globals->default_timezone =
NULL;
395 date_globals->timezone =
NULL;
396 date_globals->tzcache =
NULL;
401static void _php_date_tzinfo_dtor(
zval *
zv)
450#define DATE_TIMEZONEDB php_date_global_timezone_db ? php_date_global_timezone_db : timelib_builtin_db()
456 date_register_classes();
457 register_php_date_symbols(module_number);
504 int dummy_error_code;
522static timelib_tzinfo *php_date_parse_tzfile_wrapper(
const char *formal_tzname,
const timelib_tzdb *tzdb,
int *dummy_error_code)
524 return php_date_parse_tzfile(formal_tzname, tzdb);
535 "Invalid date.timezone value '%s', using '%s' instead",
542 if (OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage) ==
FAILURE) {
551static const char* guess_timezone(
const timelib_tzdb *tzdb)
580 zend_throw_error(date_ce_date_error,
"Timezone database is corrupt. Please file a bug report as this should never happen");
588 const char *class_name, *prop_name;
589 size_t prop_name_len;
592 if (class_name[0] !=
'*') {
596 cname = zend_string_init(class_name,
strlen(class_name), 0);
620static const char *
const mon_full_names[] = {
621 "January",
"February",
"March",
"April",
622 "May",
"June",
"July",
"August",
623 "September",
"October",
"November",
"December"
626static const char *
const mon_short_names[] = {
627 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
630static const char *
const day_full_names[] = {
631 "Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
634static const char *
const day_short_names[] = {
635 "Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"
638static const char *english_suffix(
timelib_sll number)
640 if (number >= 10 && number <= 19) {
643 switch (number % 10) {
657 if (day_of_week < 0) {
660 return day_full_names[day_of_week];
666 if (day_of_week < 0) {
669 return day_short_names[day_of_week];
703 (
offset->offset < 0) ?
'-' :
'+',
714 for (i = 0; i < format_len; i++) {
753 int retval = ((((long)t->
sse)-(((long)t->
sse) - ((((long)t->
sse) % 86400) + 3600))) * 10);
783 rfc_colon ?
":" :
"",
800 ((
offset->offset < 0) ?
'-' :
'+'),
813 (
int) t->
h, (
int) t->
i, (
int) t->
s,
820 php_date_short_day_name(t->
y, t->
m, t->
d),
821 (
int) t->
d, mon_short_names[t->
m - 1],
832 default:
buffer[0] = format[i];
buffer[1] =
'\0'; length = 1;
break;
834 smart_str_appendl(&
string,
buffer, length);
837 smart_str_0(&
string);
848 if (!date_obj->
time) {
893 string = date_format(format, format_len, t,
localtime);
935 (
offset->offset < 0) ?
'-' :
'+',
947 case 'd':
case 'j':
retval = (int) t->
d;
break;
954 case 'W':
retval = (int) isoweek;
break;
957 case 'm':
case 'n':
retval = (int) t->
m;
break;
962 case 'y':
retval = (int) (t->
y % 100);
break;
963 case 'Y':
retval = (int) t->
y;
break;
964 case 'o':
retval = (int) isoyear;
break;
968 retval = ((((long)t->
sse)-(((long)t->
sse) - ((((long)t->
sse) % 86400) + 3600))) * 10);
977 case 'g':
case 'h':
retval = (int) ((t->
h % 12) ? (
int) t->
h % 12 : 12);
break;
978 case 'H':
case 'G':
retval = (int) t->
h;
break;
979 case 'i':
retval = (int) t->
i;
break;
980 case 's':
retval = (int) t->
s;
break;
1017 bool ts_is_null = 1;
1065 if (
error->error_count) {
1085 int parse_error, epoch_does_not_fit_in_zend_long;
1088 bool preset_ts_is_null = 1;
1116 parse_error =
error->error_count;
1131 if (epoch_does_not_fit_in_zend_long) {
1144 bool min_is_null = 1, sec_is_null = 1, mon_is_null = 1, day_is_null = 1, yea_is_null = 1;
1148 int epoch_does_not_fit_in_zend_long;
1193 if (yea >= 0 && yea < 70) {
1195 }
else if (yea >= 70 && yea <= 100) {
1211 if (epoch_does_not_fit_in_zend_long) {
1217 ts += adjust_seconds;
1261 bool timestamp_is_null = 1;
1263 int max_reallocs = 5;
1264 size_t buf_len = 256, real_len;
1280 if (timestamp_is_null) {
1301 ta.tm_mon = ts->
m - 1;
1302 ta.tm_year = ts->
y - 1900;
1307#ifdef HAVE_STRUCT_TM_TM_GMTOFF
1310#ifdef HAVE_STRUCT_TM_TM_ZONE
1316 ta.tm_isdst =
offset->is_dst;
1317#ifdef HAVE_STRUCT_TM_TM_GMTOFF
1318 ta.tm_gmtoff =
offset->offset;
1320#ifdef HAVE_STRUCT_TM_TM_ZONE
1321 ta.tm_zone =
offset->abbr;
1328 buf = zend_string_alloc(buf_len, 0);
1331 buf = zend_string_extend(
buf, buf_len, 0);
1332 if (!--max_reallocs) {
1349 if (real_len && real_len != buf_len) {
1350 buf = zend_string_truncate(
buf, real_len, 0);
1353 zend_string_efree(
buf);
1385 bool timestamp_is_null = 1;
1386 bool associative = 0;
1396 if (timestamp_is_null) {
1441 bool timestamp_is_null = 1;
1450 if (timestamp_is_null) {
1473 add_assoc_string(
return_value,
"weekday", php_date_full_day_name(ts->
y, ts->
m, ts->
d));
1474 add_assoc_string(
return_value,
"month", mon_full_names[ts->
m - 1]);
1508static void write_date_period_property(
zend_object *obj,
const char *
name,
const size_t name_len,
zval *
zv)
1515 zend_string_release(property_name);
1518static void initialize_date_period_properties(
php_period_obj *period_obj)
1523 zend_std_get_properties_ex(&period_obj->
std);
1525 create_date_period_datetime(period_obj->
start, period_obj->
start_ce, &
zv);
1526 write_date_period_property(&period_obj->
std,
"start",
sizeof(
"start") - 1, &
zv);
1529 write_date_period_property(&period_obj->
std,
"current",
sizeof(
"current") - 1, &
zv);
1531 create_date_period_datetime(period_obj->
end, period_obj->
start_ce, &
zv);
1532 write_date_period_property(&period_obj->
std,
"end",
sizeof(
"end") - 1, &
zv);
1534 create_date_period_interval(period_obj->
interval, &
zv);
1535 write_date_period_property(&period_obj->
std,
"interval",
sizeof(
"interval") - 1, &
zv);
1538 write_date_period_property(&period_obj->
std,
"recurrences",
sizeof(
"recurrences") - 1, &
zv);
1541 write_date_period_property(&period_obj->
std,
"include_start_date",
sizeof(
"include_start_date") - 1, &
zv);
1544 write_date_period_property(&period_obj->
std,
"include_end_date",
sizeof(
"include_end_date") - 1, &
zv);
1572 date_period_it_invalidate_current(iter);
1586 if (
object->include_end_date) {
1587 return object->current->us <=
object->end->us ?
SUCCESS :
FAILURE;
1589 return object->current->us <
object->end->us ?
SUCCESS :
FAILURE;
1593 return object->current->sse <
object->end->sse ?
SUCCESS :
FAILURE;
1604 while (tmp != date_ce_date && tmp != date_ce_immutable && tmp->
parent) {
1623 *newdateobj->
time = *it_time;
1660 date_period_advance(it_time,
object->interval);
1663 zend_std_get_properties_ex(&
object->std);
1665 create_date_period_datetime(
object->current,
object->start_ce, ¤t_zv);
1669 zend_string_release(property_name);
1672 date_period_it_invalidate_current(iter);
1686 date_throw_uninitialized_error(date_ce_period);
1696 date_period_it_invalidate_current(iter);
1702 date_period_it_dtor,
1703 date_period_it_has_more,
1704 date_period_it_current_data,
1705 date_period_it_current_key,
1706 date_period_it_move_forward,
1707 date_period_it_rewind,
1708 date_period_it_invalidate_current,
1736 !instanceof_function(implementor, date_ce_date) &&
1737 !instanceof_function(implementor, date_ce_immutable)
1752 obj = php_interval_obj_from_obj(
object);
1759 prop = date_interval_read_property(
object,
name,
BP_VAR_IS, cache_slot, &
rv);
1761 if (prop != &
EG(uninitialized_zval)) {
1764 }
else if (
type == 1) {
1766 }
else if (
type == 0) {
1778static void date_register_classes(
void)
1780 date_ce_interface = register_class_DateTimeInterface();
1781 date_ce_interface->interface_gets_implemented = implement_date_interface_handler;
1783 date_ce_date = register_class_DateTime(date_ce_interface);
1784 date_ce_date->create_object = date_object_new_date;
1785 date_ce_date->default_object_handlers = &date_object_handlers_date;
1788 date_object_handlers_date.free_obj = date_object_free_storage_date;
1789 date_object_handlers_date.clone_obj = date_object_clone_date;
1790 date_object_handlers_date.compare = date_object_compare_date;
1791 date_object_handlers_date.get_properties_for = date_object_get_properties_for;
1792 date_object_handlers_date.get_gc = date_object_get_gc;
1794 date_ce_immutable = register_class_DateTimeImmutable(date_ce_interface);
1795 date_ce_immutable->create_object = date_object_new_date;
1796 date_ce_immutable->default_object_handlers = &date_object_handlers_date;
1798 date_object_handlers_immutable.clone_obj = date_object_clone_date;
1799 date_object_handlers_immutable.compare = date_object_compare_date;
1800 date_object_handlers_immutable.get_properties_for = date_object_get_properties_for;
1801 date_object_handlers_immutable.get_gc = date_object_get_gc;
1803 date_ce_timezone = register_class_DateTimeZone();
1804 date_ce_timezone->create_object = date_object_new_timezone;
1805 date_ce_timezone->default_object_handlers = &date_object_handlers_timezone;
1808 date_object_handlers_timezone.free_obj = date_object_free_storage_timezone;
1809 date_object_handlers_timezone.clone_obj = date_object_clone_timezone;
1810 date_object_handlers_timezone.get_properties_for = date_object_get_properties_for_timezone;
1811 date_object_handlers_timezone.get_gc = date_object_get_gc_timezone;
1812 date_object_handlers_timezone.get_debug_info = date_object_get_debug_info_timezone;
1813 date_object_handlers_timezone.compare = date_object_compare_timezone;
1815 date_ce_interval = register_class_DateInterval();
1816 date_ce_interval->create_object = date_object_new_interval;
1817 date_ce_interval->default_object_handlers = &date_object_handlers_interval;
1820 date_object_handlers_interval.free_obj = date_object_free_storage_interval;
1821 date_object_handlers_interval.clone_obj = date_object_clone_interval;
1822 date_object_handlers_interval.has_property = date_interval_has_property;
1823 date_object_handlers_interval.read_property = date_interval_read_property;
1824 date_object_handlers_interval.write_property = date_interval_write_property;
1825 date_object_handlers_interval.get_properties = date_object_get_properties_interval;
1826 date_object_handlers_interval.get_property_ptr_ptr = date_interval_get_property_ptr_ptr;
1827 date_object_handlers_interval.get_gc = date_object_get_gc_interval;
1828 date_object_handlers_interval.compare = date_interval_compare_objects;
1831 date_ce_period->create_object = date_object_new_period;
1832 date_ce_period->default_object_handlers = &date_object_handlers_period;
1833 date_ce_period->get_iterator = date_object_period_get_iterator;
1836 date_object_handlers_period.free_obj = date_object_free_storage_period;
1837 date_object_handlers_period.clone_obj = date_object_clone_period;
1838 date_object_handlers_period.get_gc = date_object_get_gc_period;
1839 date_object_handlers_period.get_property_ptr_ptr = date_period_get_property_ptr_ptr;
1840 date_object_handlers_period.read_property = date_period_read_property;
1841 date_object_handlers_period.write_property = date_period_write_property;
1843 date_ce_date_error = register_class_DateError(
zend_ce_error);
1844 date_ce_date_object_error = register_class_DateObjectError(date_ce_date_error);
1845 date_ce_date_range_error = register_class_DateRangeError(date_ce_date_error);
1848 date_ce_date_invalid_timezone_exception = register_class_DateInvalidTimeZoneException(date_ce_date_exception);
1849 date_ce_date_invalid_operation_exception = register_class_DateInvalidOperationException(date_ce_date_exception);
1850 date_ce_date_malformed_string_exception = register_class_DateMalformedStringException(date_ce_date_exception);
1851 date_ce_date_malformed_interval_string_exception = register_class_DateMalformedIntervalStringException(date_ce_date_exception);
1852 date_ce_date_malformed_period_string_exception = register_class_DateMalformedPeriodStringException(date_ce_date_exception);
1862 return &intern->
std;
1867 php_date_obj *old_obj = php_date_obj_from_obj(this_ptr);
1868 php_date_obj *new_obj = php_date_obj_from_obj(date_object_new_date(old_obj->
std.
ce));
1871 if (!old_obj->
time) {
1872 return &new_obj->
std;
1885 return &new_obj->
std;
1888static void date_clone_immutable(
zval *
object,
zval *new_object)
1904 zend_throw_error(date_ce_date_object_error,
"Trying to compare an incomplete DateTime or DateTimeImmutable object");
1936 ZVAL_STR(&
zv, date_format(
"x-m-d H:i:s.u",
sizeof(
"x-m-d H:i:s.u")-1,
dateobj->time, 1));
1940 if (
dateobj->time->is_localtime) {
1944 switch (
dateobj->time->zone_type) {
1949 zend_string *tmpstr = zend_string_alloc(
sizeof(
"UTC+05:00")-1, 0);
1950 int utc_offset =
dateobj->time->z;
1953 utc_offset < 0 ?
'-' :
'+',
1954 abs(utc_offset / 3600),
1955 abs(((utc_offset % 3600) / 60)));
1984 dateobj = php_date_obj_from_obj(
object);
1990 date_object_to_hash(
dateobj, props);
2002 return &intern->
std;
2012 return &new_obj->
std;
2017 switch (new_obj->
type) {
2031 return &new_obj->
std;
2034static int date_object_compare_timezone(
zval *tz1,
zval *tz2)
2044 zend_throw_error(date_ce_date_object_error,
"Trying to compare uninitialized DateTimeZone objects");
2049 zend_throw_error(date_ce_date_exception,
"Cannot compare two different kinds of DateTimeZone objects");
2066 switch (tzobj->
type) {
2072 int seconds = utc_offset % 60;
2076 size =
sizeof(
"+05:00");
2077 format =
"%c%02d:%02d";
2079 size =
sizeof(
"+05:00:01");
2080 format =
"%c%02d:%02d:%02d";
2086 utc_offset < 0 ?
'-' :
'+',
2087 abs((
int)(utc_offset / 3600)),
2088 abs((
int)(utc_offset % 3600) / 60),
2107 php_timezone_to_string(tzobj, &
zv);
2127 tzobj = php_timezone_obj_from_obj(
object);
2133 date_timezone_object_to_hash(tzobj, props);
2144 tzobj = php_timezone_obj_from_obj(
object);
2153 php_timezone_to_string(tzobj, &
zv);
2166 return &intern->
std;
2181 if (old_obj->
diff) {
2185 return &new_obj->
std;
2209#define PHP_DATE_INTERVAL_ADD_PROPERTY(n,f) \
2210 ZVAL_LONG(&zv, (zend_long)intervalobj->diff->f); \
2211 zend_hash_str_update(props, n, sizeof(n)-1, &zv);
2231#undef PHP_DATE_INTERVAL_ADD_PROPERTY
2239 intervalobj = php_interval_obj_from_obj(
object);
2245 date_interval_object_to_hash(intervalobj, props);
2257 return &intern->
std;
2263 php_period_obj *new_obj = php_period_obj_from_obj(date_object_new_period(old_obj->
std.
ce));
2272 if (old_obj->
start) {
2284 return &new_obj->
std;
2287static void date_object_free_storage_date(
zend_object *
object)
2298static void date_object_free_storage_timezone(
zend_object *
object)
2308static void date_object_free_storage_interval(
zend_object *
object)
2320static void date_object_free_storage_period(
zend_object *
object)
2324 if (intern->
start) {
2375 if ((*last_errors)->warning_count || (*last_errors)->error_count) {
2386 time->us = microsecond;
2389static void php_date_get_current_time_with_fraction(time_t *sec,
suseconds_t *usec)
2391#ifdef HAVE_GETTIMEOFDAY
2392 struct timeval tp = {0};
2409 char *new_abbr =
NULL;
2419 if (time_str_len == 0) {
2424 if (time_str_len == 0) {
2426 time_str_len =
sizeof(
"now") - 1;
2432 update_errors_warnings(&
err);
2437 zend_throw_exception_ex(date_ce_date_malformed_string_exception, 0,
"Failed to parse time string (%s) at position %d (%c): %s", time_str,
2438 err->error_messages[0].position,
err->error_messages[0].character ?
err->error_messages[0].character :
' ',
err->error_messages[0].message);
2440 if (
err &&
err->error_count) {
2446 if (timezone_object) {
2450 switch (tzobj->
type) {
2452 tzi = tzobj->
tzi.
tz;
2463 zend_throw_error(
NULL,
"The DateTimeZone object has not been correctly initialized by its constructor");
2467 }
else if (
dateobj->time->tz_info) {
2483 now->z = new_offset;
2486 now->z = new_offset;
2488 now->tz_abbr = new_abbr;
2491 php_date_get_current_time_with_fraction(&sec, &usec);
2493 php_date_set_time_fraction(
now, usec);
2496 && time_str_len ==
sizeof(
"now") - 1
2497 && memcmp(time_str,
"now",
sizeof(
"now") - 1) == 0) {
2512 dateobj->time->have_relative = 0;
2526 php_date_set_time_fraction(
dateobj->time, usec);
2531 double sec_dval = trunc(ts);
2537 date_ce_date_range_error,
2548 usec = (int)
round(
fmod(ts, 1) * 1000000);
2551 sec += usec > 0 ? 1 : -1;
2558 date_ce_date_range_error,
2569 usec = 1000000 + usec;
2581 char *time_str =
NULL;
2582 size_t time_str_len = 0;
2602 char *time_str =
NULL;
2603 size_t time_str_len = 0;
2623 char *time_str =
NULL, *format_str =
NULL;
2624 size_t time_str_len = 0, format_str_len = 0;
2645 char *time_str =
NULL, *format_str =
NULL;
2646 size_t time_str_len = 0, format_str_len = 0;
2667 char *time_str =
NULL;
2668 size_t time_str_len = 0;
2684 char *time_str =
NULL;
2685 size_t time_str_len = 0;
2700 zval *datetimeimmutable_object =
NULL;
2721 zval *datetimeinterface_object =
NULL;
2796 zval *datetimeinterface_object =
NULL;
2850 zval *z_timezone_type;
2860 z_timezone_type =
zend_hash_str_find(myht,
"timezone_type",
sizeof(
"timezone_type")-1);
2870 switch (
Z_LVAL_P(z_timezone_type)) {
2877 zend_string_release(tmp);
2893 tzobj->
tzi.
tz = tzi;
2919 if (!php_date_initialize_from_hash(&
dateobj, myht)) {
2941 if (!php_date_initialize_from_hash(&
dateobj, myht)) {
2962 date_object_to_hash(
dateobj, myht);
2964 add_common_properties(myht, &
dateobj->std);
2982 date_object_to_hash(
dateobj, myht);
2984 add_common_properties(myht, &
dateobj->std);
3000static void restore_custom_datetime_properties(
zval *
object,
HashTable *myht)
3006 if (!prop_name || (
Z_TYPE_P(prop_val) ==
IS_REFERENCE) || date_time_is_internal_property(prop_name)) {
3009 update_property(
Z_OBJ_P(
object), prop_name, prop_val);
3028 if (!php_date_initialize_from_hash(&
dateobj, myht)) {
3033 restore_custom_datetime_properties(
object, myht);
3052 if (!php_date_initialize_from_hash(&
dateobj, myht)) {
3057 restore_custom_datetime_properties(
object, myht);
3074 if (!php_date_initialize_from_hash(&
dateobj, myht)) {
3094 if (!php_date_initialize_from_hash(&
dateobj, myht)) {
3107 add_assoc_long(z,
"warning_count",
error->warning_count);
3109 for (i = 0; i <
error->warning_count; i++) {
3112 add_assoc_zval(z,
"warnings", &element);
3114 add_assoc_long(z,
"error_count",
error->error_count);
3116 for (i = 0; i <
error->error_count; i++) {
3119 add_assoc_zval(z,
"errors", &element);
3141#define PHP_DATE_PARSE_DATE_SET_TIME_ELEMENT(name, elem) \
3142 if (parsed_time->elem == TIMELIB_UNSET) { \
3143 add_assoc_bool(return_value, #name, 0); \
3145 add_assoc_long(return_value, #name, parsed_time->elem); \
3157 add_assoc_double(
return_value,
"fraction", (
double)parsed_time->
us / 1000000.0);
3190 add_assoc_long(&element,
"year", parsed_time->
relative.
y);
3191 add_assoc_long(&element,
"month", parsed_time->
relative.
m);
3192 add_assoc_long(&element,
"day", parsed_time->
relative.
d);
3193 add_assoc_long(&element,
"hour", parsed_time->
relative.
h);
3194 add_assoc_long(&element,
"minute", parsed_time->
relative.
i);
3195 add_assoc_long(&element,
"second", parsed_time->
relative.
s);
3260static bool php_date_modify(
zval *
object,
char *modify,
size_t modify_len)
3269 date_throw_uninitialized_error(
Z_OBJCE_P(
object));
3276 update_errors_warnings(&
err);
3278 if (
err &&
err->error_count) {
3281 err->error_messages[0].position,
3282 err->error_messages[0].character ?
err->error_messages[0].character :
' ',
3283 err->error_messages[0].message);
3290 dateobj->time->sse_uptodate = 0;
3323 tmp_time->
y == 1970 && tmp_time->
m == 1 && tmp_time->
d == 1 &&
3324 tmp_time->
h == 0 && tmp_time->
i == 0 && tmp_time->
s == 0 && tmp_time->
us == 0 &&
3326 tmp_time->
z == 0 && tmp_time->
dst == 0
3335 dateobj->time->have_relative = 0;
3352 if (!php_date_modify(
object, modify, modify_len)) {
3374 if (!php_date_modify(
object, modify, modify_len)) {
3398 date_clone_immutable(
object, &new_object);
3401 if (!php_date_modify(&new_object, modify, modify_len)) {
3458 date_clone_immutable(
object, &new_object);
3533 date_clone_immutable(
object, &new_object);
3581 if (
dateobj->time->is_localtime) {
3585 set_timezone_from_timelib_time(tzobj,
dateobj->time);
3601 switch (tzobj->
type) {
3619 zval *timezone_object;
3625 php_date_timezone_set(
object, timezone_object,
return_value);
3635 zval *timezone_object;
3642 date_clone_immutable(
object, &new_object);
3643 php_date_timezone_set(&new_object, timezone_object,
return_value);
3661 if (
dateobj->time->is_localtime) {
3662 switch (
dateobj->time->zone_type) {
3727 date_clone_immutable(
object, &new_object);
3775 date_clone_immutable(
object, &new_object);
3793 dateobj->time->have_relative = 1;
3828 date_clone_immutable(
object, &new_object);
3829 php_date_isodate_set(&new_object, y, w, d,
return_value);
3843 php_date_set_time_fraction(
dateobj->time, 0);
3856 php_date_timestamp_set(
object, timestamp,
return_value);
3873 date_clone_immutable(
object, &new_object);
3874 php_date_timestamp_set(&new_object, timestamp,
return_value);
3893 date_ce_date_range_error,
3905 date_clone_immutable(
object, &new_object);
3908 php_date_set_time_fraction(new_dateobj->
time, (
int)us);
3927 date_ce_date_range_error,
3938 php_date_set_time_fraction(
dateobj->time, (
int)us);
3950 int epoch_does_not_fit_in_zend_long;
3958 if (!
dateobj->time->sse_uptodate) {
3964 if (epoch_does_not_fit_in_zend_long) {
3965 zend_throw_error(date_ce_date_range_error,
"Epoch doesn't fit in a PHP integer");
3991 zval *object1, *object2;
4015static bool timezone_initialize(
php_timezone_obj *tzobj,
const char *tz,
size_t tz_len,
char **warning_message)
4019 const char *orig_tz = tz;
4021 if (
strlen(tz) != tz_len) {
4022 if (warning_message) {
4023 spprintf(warning_message, 0,
"Timezone must not contain null bytes");
4030 if ((dummy_t->
z >= (100 * 60 * 60)) || (dummy_t->
z <= (-100 * 60 * 60))) {
4031 if (warning_message) {
4032 spprintf(warning_message, 0,
"Timezone offset is out of range (%s)", orig_tz);
4039 if (!not_found && (*tz !=
'\0')) {
4040 if (warning_message) {
4041 spprintf(warning_message, 0,
"Unknown or bad timezone (%s)", orig_tz);
4048 if (warning_message) {
4049 spprintf(warning_message, 0,
"Unknown or bad timezone (%s)", orig_tz);
4054 set_timezone_from_timelib_time(tzobj, dummy_t);
4066 char *warning_message;
4073 if (!timezone_initialize(tzobj,
ZSTR_VAL(tz),
ZSTR_LEN(tz), &warning_message)) {
4075 efree(warning_message);
4087 char *exception_message;
4094 if (!timezone_initialize(tzobj,
ZSTR_VAL(tz),
ZSTR_LEN(tz), &exception_message)) {
4095 zend_throw_exception_ex(date_ce_date_invalid_timezone_exception, 0,
"DateTimeZone::__construct(): %s", exception_message);
4096 efree(exception_message);
4104 zval *z_timezone_type;
4106 if ((z_timezone_type =
zend_hash_str_find(myht,
"timezone_type",
sizeof(
"timezone_type") - 1)) ==
NULL) {
4143 if (!php_date_timezone_initialize_from_hash(&
return_value, &tzobj, myht)) {
4163 if (!php_date_timezone_initialize_from_hash(&
return_value, &tzobj, myht)) {
4184 date_timezone_object_to_hash(tzobj, myht);
4186 add_common_properties(myht, &tzobj->
std);
4201static void restore_custom_datetimezone_properties(
zval *
object,
HashTable *myht)
4207 if (!prop_name || (
Z_TYPE_P(prop_val) ==
IS_REFERENCE) || date_timezone_is_internal_property(prop_name)) {
4210 update_property(
Z_OBJ_P(
object), prop_name, prop_val);
4229 if (!php_date_timezone_initialize_from_hash(&
object, &tzobj, myht)) {
4234 restore_custom_datetimezone_properties(
object, myht);
4294 switch (tzobj->
type) {
4328#define add_nominal() \
4329 array_init(&element); \
4330 add_assoc_long(&element, "ts", timestamp_begin); \
4331 add_assoc_str(&element, "time", php_format_date(DATE_FORMAT_ISO8601_LARGE_YEAR, 13, timestamp_begin, 0)); \
4332 add_assoc_long(&element, "offset", tzobj->tzi.tz->type[0].offset); \
4333 add_assoc_bool(&element, "isdst", tzobj->tzi.tz->type[0].isdst); \
4334 add_assoc_string(&element, "abbr", &tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[0].abbr_idx]); \
4335 add_next_index_zval(return_value, &element);
4338 array_init(&element); \
4339 add_assoc_long(&element, "ts", ts); \
4340 add_assoc_str(&element, "time", php_format_date(DATE_FORMAT_ISO8601_LARGE_YEAR, 13, ts, 0)); \
4341 add_assoc_long(&element, "offset", tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].offset); \
4342 add_assoc_bool(&element, "isdst", tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].isdst); \
4343 add_assoc_string(&element, "abbr", &tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[tzobj->tzi.tz->trans_idx[i]].abbr_idx]); \
4344 add_next_index_zval(return_value, &element);
4346#define add_by_index(i,ts) \
4347 array_init(&element); \
4348 add_assoc_long(&element, "ts", ts); \
4349 add_assoc_str(&element, "time", php_format_date(DATE_FORMAT_ISO8601_LARGE_YEAR, 13, ts, 0)); \
4350 add_assoc_long(&element, "offset", tzobj->tzi.tz->type[i].offset); \
4351 add_assoc_bool(&element, "isdst", tzobj->tzi.tz->type[i].isdst); \
4352 add_assoc_string(&element, "abbr", &tzobj->tzi.tz->timezone_abbr[tzobj->tzi.tz->type[i].abbr_idx]); \
4353 add_next_index_zval(return_value, &element);
4355#define add_from_tto(to,ts) \
4356 array_init(&element); \
4357 add_assoc_long(&element, "ts", ts); \
4358 add_assoc_str(&element, "time", php_format_date(DATE_FORMAT_ISO8601_LARGE_YEAR, 13, ts, 0)); \
4359 add_assoc_long(&element, "offset", (to)->offset); \
4360 add_assoc_bool(&element, "isdst", (to)->is_dst); \
4361 add_assoc_string(&element, "abbr", (to)->abbr); \
4362 add_next_index_zval(return_value, &element);
4364#define add_last() add(tzobj->tzi.tz->bit64.timecnt - 1, timestamp_begin)
4405 if (tzobj->
tzi.
tz->
trans[i] < timestamp_end) {
4427 for (
size_t j = 0;
j < transitions.
count;
j++) {
4428 if (transitions.
times[
j] <= last_transition_ts) {
4431 if (transitions.
times[
j] < timestamp_begin) {
4434 if (transitions.
times[
j] > timestamp_end) {
4467static bool date_interval_initialize(
timelib_rel_time **rt,
char *format,
size_t format_length)
4478 zend_throw_exception_ex(date_ce_date_malformed_interval_string_exception, 0,
"Unknown or bad format (%s)", format);
4494 zend_throw_exception_ex(date_ce_date_malformed_interval_string_exception, 0,
"Failed to parse interval (%s)", format);
4505static int date_interval_compare_objects(
zval *o1,
zval *o2)
4523 obj = php_interval_obj_from_obj(
object);
4530#define GET_VALUE_FROM_STRUCT(n,m) \
4531 if (zend_string_equals_literal(name, m)) { \
4532 value = obj->diff->n; \
4543 fvalue = obj->
diff->
us / 1000000.0;
4573 obj = php_interval_obj_from_obj(
object);
4579#define SET_VALUE_FROM_STRUCT(n,m) \
4580 if (zend_string_equals_literal(name, m)) { \
4581 obj->diff->n = zval_get_long(value); \
4593 obj->
diff->
us = zend_dval_to_lval(zval_get_double(
value) * 1000000.0);
4622 cache_slot[0] = cache_slot[1] = cache_slot[2] =
NULL;
4643 if (!date_interval_initialize(&reltime,
ZSTR_VAL(interval_string),
ZSTR_LEN(interval_string))) {
4648 diobj->
diff = reltime;
4664 if (
err->error_count > 0) {
4666 "Unknown or bad format (%s) at position %d (%c) while unserializing: %s",
4668 err->error_messages[0].position,
4669 err->error_messages[0].character ?
err->error_messages[0].character :
' ',
err->error_messages[0].message);
4676 if ((*intobj)->diff) {
4681 (*intobj)->initialized = 1;
4683 (*intobj)->from_string =
true;
4684 (*intobj)->date_string = zend_string_copy(
Z_STR_P(date_str));
4693 if ((*intobj)->diff) {
4700#define PHP_DATE_INTERVAL_READ_PROPERTY(element, member, itype, def) \
4702 zval *z_arg = zend_hash_str_find(myht, element, sizeof(element) - 1); \
4703 if (z_arg && Z_TYPE_P(z_arg) <= IS_STRING) { \
4704 (*intobj)->diff->member = (itype)zval_get_long(z_arg); \
4706 (*intobj)->diff->member = (itype)def; \
4710#define PHP_DATE_INTERVAL_READ_PROPERTY_I64(element, member) \
4712 zval *z_arg = zend_hash_str_find(myht, element, sizeof(element) - 1); \
4713 if (z_arg && Z_TYPE_P(z_arg) <= IS_STRING) { \
4714 zend_string *tmp_str; \
4715 zend_string *str = zval_get_tmp_string(z_arg, &tmp_str); \
4716 DATE_A64I((*intobj)->diff->member, ZSTR_VAL(str)); \
4717 zend_tmp_string_release(tmp_str); \
4719 (*intobj)->diff->member = -1LL; \
4723#define PHP_DATE_INTERVAL_READ_PROPERTY_DAYS(member) \
4725 zval *z_arg = zend_hash_str_find(myht, "days", sizeof("days") - 1); \
4726 if (z_arg && Z_TYPE_P(z_arg) == IS_FALSE) { \
4727 (*intobj)->diff->member = TIMELIB_UNSET; \
4728 } else if (z_arg && Z_TYPE_P(z_arg) <= IS_STRING) { \
4729 zend_string *str = zval_get_string(z_arg); \
4730 DATE_A64I((*intobj)->diff->member, ZSTR_VAL(str)); \
4731 zend_string_release(str); \
4733 (*intobj)->diff->member = -1LL; \
4737#define PHP_DATE_INTERVAL_READ_PROPERTY_DOUBLE(element, member, def) \
4739 zval *z_arg = zend_hash_str_find(myht, element, sizeof(element) - 1); \
4741 (*intobj)->diff->member = (double)zval_get_double(z_arg); \
4743 (*intobj)->diff->member = (double)def; \
4756 (*intobj)->diff->us = zend_dval_to_lval(zval_get_double(z_arg) * 1000000.0);
4773 (*intobj)->civil_or_wall =
val;
4777 (*intobj)->initialized = 1;
4795 php_date_interval_initialize_from_hash(&
return_value, &intobj, myht);
4813 date_interval_object_to_hash(intervalobj, myht);
4815 add_common_properties(myht, &intervalobj->
std);
4839static void restore_custom_dateinterval_properties(
zval *
object,
HashTable *myht)
4845 if (!prop_name || (
Z_TYPE_P(prop_val) ==
IS_REFERENCE) || date_interval_is_internal_property(prop_name)) {
4848 update_property(
Z_OBJ_P(
object), prop_name, prop_val);
4868 php_date_interval_initialize_from_hash(&
object, &intervalobj, myht);
4869 restore_custom_dateinterval_properties(
object, myht);
4886 php_date_interval_initialize_from_hash(&
return_value, &intobj, myht);
4916 if (
err->error_count > 0) {
4918 err->error_messages[0].position,
err->error_messages[0].character ?
err->error_messages[0].character :
' ',
err->error_messages[0].message);
4923 if (
time->have_date ||
time->have_time ||
time->have_zone) {
4950 if (
err->error_count > 0) {
4951 zend_throw_error(date_ce_date_malformed_interval_string_exception,
"Unknown or bad format (%s) at position %d (%c): %s",
ZSTR_VAL(time_str),
4952 err->error_messages[0].position,
err->error_messages[0].character ?
err->error_messages[0].character :
' ',
err->error_messages[0].message);
4956 if (
time->have_date ||
time->have_time ||
time->have_zone) {
4957 zend_throw_error(date_ce_date_malformed_interval_string_exception,
"String '%s' contains non-relative elements",
ZSTR_VAL(time_str));
4974 int length, have_format_spec = 0;
4981 for (i = 0; i < format_len; i++) {
4982 if (have_format_spec) {
4983 switch (format[i]) {
5016 default:
buffer[0] =
'%';
buffer[1] = format[i];
buffer[2] =
'\0'; length = 2;
break;
5018 smart_str_appendl(&
string,
buffer, length);
5019 have_format_spec = 0;
5021 if (format[i] ==
'%') {
5022 have_format_spec = 1;
5024 smart_str_appendc(&
string, format[i]);
5029 smart_str_0(&
string);
5031 if (
string.
s ==
NULL) {
5053 RETURN_STR(date_interval_format(format, format_len, diobj->
diff));
5069 zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0,
"Unknown or bad format (%s)", format);
5092 if (!date_period_initialize(&(dpobj->
start), &(dpobj->
end), &(dpobj->
interval), recurrences, isostr, isostr_len)) {
5099 zend_string_release(
func);
5105 zend_string_release(
func);
5108 if (dpobj->
end ==
NULL && recurrences == 0) {
5110 zend_throw_exception_ex(date_ce_date_malformed_period_string_exception, 0,
"%s(): ISO interval must contain an end date or a recurrence count, \"%s\" given",
ZSTR_VAL(
func), isostr);
5111 zend_string_release(
func);
5130 if (dpobj->
end ==
NULL && (recurrences < 1 || recurrences > max_recurrences)) {
5133 zend_string_release(
func);
5144 if (
UNEXPECTED(recurrences > max_recurrences)) {
5147 zend_string_release(
func);
5155 initialize_date_period_properties(dpobj);
5164 char *isostr =
NULL;
5165 size_t isostr_len = 0;
5178 if (!date_period_init_iso8601_string(dpobj, date_ce_immutable, isostr, isostr_len,
options, &recurrences)) {
5182 if (!date_period_init_finish(dpobj,
options, recurrences)) {
5194 char *isostr =
NULL;
5195 size_t isostr_len = 0;
5201 zend_type_error(
"DatePeriod::__construct() accepts (DateTimeInterface, DateInterval, int [, int]), or (DateTimeInterface, DateInterval, DateTime [, int]), or (string [, int]) as arguments");
5211 zend_error(
E_DEPRECATED,
"Calling DatePeriod::__construct(string $isostr, int $options = 0) is deprecated, "
5212 "use DatePeriod::createFromISO8601String() instead");
5217 if (!date_period_init_iso8601_string(dpobj, date_ce_date, isostr, isostr_len,
options, &recurrences)) {
5240 dpobj->
start = clone;
5254 if (!date_period_init_finish(dpobj,
options, recurrences)) {
5353static int check_id_allowed(
char *
id,
zend_long what)
5376 char *option =
NULL;
5377 size_t option_len = 0;
5388 "when argument #1 ($timezoneGroup) is DateTimeZone::PER_COUNTRY");
5397 for (i = 0; i < item_count; ++i) {
5399 if (tzdb->
data[table[i].pos + 5] == option[0] && tzdb->
data[table[i].pos + 6] == option[1]) {
5425 zval element, *abbr_array_p, abbr_array;
5444 if (!abbr_array_p) {
5450 add_next_index_zval(&abbr_array, &element);
5452 }
while (entry->
name);
5498 double latitude, longitude, zenith, gmt_offset, altitude;
5499 bool latitude_is_null = 1, longitude_is_null = 1, zenith_is_null = 1, gmt_offset_is_null = 1;
5500 double h_rise, h_set,
N;
5518 if (latitude_is_null) {
5519 latitude =
INI_FLT(
"date.default_latitude");
5522 if (longitude_is_null) {
5523 longitude =
INI_FLT(
"date.default_longitude");
5526 if (zenith_is_null) {
5528 zenith =
INI_FLT(
"date.sunset_zenith");
5530 zenith =
INI_FLT(
"date.sunrise_zenith");
5541 altitude = 90 - zenith;
5556 if (gmt_offset_is_null) {
5571 N = (calc_sunset ? h_set : h_rise) + gmt_offset;
5573 if (
N > 24 ||
N < 0) {
5580 switch (retformat) {
5582 retstr =
strpprintf(0,
"%02d:%02d", (
int)
N, (
int) (60 * (
N - (
int)
N)));
5610 double latitude, longitude;
5671 add_assoc_bool(
return_value,
"civil_twilight_begin", 0);
5675 add_assoc_bool(
return_value,
"civil_twilight_begin", 1);
5689 add_assoc_bool(
return_value,
"nautical_twilight_begin", 0);
5690 add_assoc_bool(
return_value,
"nautical_twilight_end", 0);
5693 add_assoc_bool(
return_value,
"nautical_twilight_begin", 1);
5694 add_assoc_bool(
return_value,
"nautical_twilight_end", 1);
5707 add_assoc_bool(
return_value,
"astronomical_twilight_begin", 0);
5708 add_assoc_bool(
return_value,
"astronomical_twilight_end", 0);
5711 add_assoc_bool(
return_value,
"astronomical_twilight_begin", 1);
5712 add_assoc_bool(
return_value,
"astronomical_twilight_end", 1);
5736 create_date_period_datetime(period_obj->
start, period_obj->
start_ce, &
zv);
5742 create_date_period_datetime(period_obj->
end, period_obj->
start_ce, &
zv);
5745 create_date_period_interval(period_obj->
interval, &
zv);
5771 if (!date_obj->
time) {
5793 if (!date_obj->
time) {
5797 if (period_obj->
end !=
NULL) {
5814 if (!date_obj->
time) {
5858 ht_entry =
zend_hash_str_find(myht,
"include_start_date",
sizeof(
"include_start_date")-1);
5866 ht_entry =
zend_hash_str_find(myht,
"include_end_date",
sizeof(
"include_end_date")-1);
5876 initialize_date_period_properties(period_obj);
5896 if (!php_date_period_initialize_from_hash(period_obj, myht)) {
5917 date_period_object_to_hash(period_obj, myht);
5919 add_common_properties(myht, &period_obj->
std);
5944static void restore_custom_dateperiod_properties(
zval *
object,
HashTable *myht)
5950 if (!prop_name || (
Z_TYPE_P(prop_val) ==
IS_REFERENCE) || date_period_is_internal_property(prop_name)) {
5953 update_property(
Z_OBJ_P(
object), prop_name, prop_val);
5972 if (!php_date_period_initialize_from_hash(period_obj, myht)) {
5976 restore_custom_dateperiod_properties(
object, myht);
5993 if (!php_date_period_initialize_from_hash(period_obj, myht)) {
6004 if (date_period_is_internal_property(
name)) {
6006 return &
EG(uninitialized_zval);
6016 if (date_period_is_internal_property(
name)) {
6026 if (date_period_is_internal_property(
name)) {
6028 return &
EG(error_zval);
int timelib_astro_rise_set_altitude(timelib_time *t_loc, double lon, double lat, double altit, int upper_limb, double *h_rise, double *h_set, timelib_sll *ts_rise, timelib_sll *ts_set, timelib_sll *ts_transit)
gettimeofday(bool $as_float=false)
fmod(float $num1, float $num2)
timelib_sll timelib_iso_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d)
void timelib_isoweek_from_date(timelib_sll y, timelib_sll m, timelib_sll d, timelib_sll *iw, timelib_sll *iy)
timelib_sll timelib_day_of_year(timelib_sll y, timelib_sll m, timelib_sll d)
timelib_sll timelib_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)
timelib_sll timelib_days_in_month(timelib_sll y, timelib_sll m)
timelib_sll timelib_daynr_from_weeknr(timelib_sll iy, timelib_sll iw, timelib_sll id)
memset(ptr, 0, type->size)
zend_ffi_ctype_name_buf buf
#define round(tables, k1, k2)
foreach($dp as $el) foreach( $dp as $el) if( $pass2< 2) echo ""
timelib_time * timelib_sub(timelib_time *old_time, timelib_rel_time *interval)
timelib_time * timelib_add(timelib_time *old_time, timelib_rel_time *interval)
timelib_rel_time * timelib_diff(timelib_time *one, timelib_time *two)
timelib_time * timelib_sub_wall(timelib_time *old_time, timelib_rel_time *interval)
timelib_time * timelib_add_wall(timelib_time *old_time, timelib_rel_time *interval)
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
timelib_long timelib_parse_zone(const char **ptr, int *dst, timelib_time *t, int *tz_not_found, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_wrapper)
const timelib_tz_lookup_table * timelib_timezone_abbreviations_list(void)
timelib_time * timelib_parse_from_format(const char *format, const char *string, size_t len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper)
timelib_time * timelib_strtotime(const char *s, size_t len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper)
const char * timelib_timezone_id_from_abbr(const char *abbr, timelib_long gmtoffset, int isdst)
void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options)
void timelib_strtointerval(const char *s, size_t len, timelib_time **begin, timelib_time **end, timelib_rel_time **period, int *recurrences, timelib_error_container **errors)
void timelib_get_transitions_for_year(timelib_tzinfo *tz, timelib_sll year, timelib_posix_transitions *transitions)
const timelib_tzdb_index_entry * timelib_timezone_identifiers_list(const timelib_tzdb *tzdb, int *count)
void timelib_tzinfo_dtor(timelib_tzinfo *tz)
timelib_tzinfo * timelib_parse_tzfile(const char *timezone, const timelib_tzdb *tzdb, int *error_code)
timelib_time_offset * timelib_get_time_zone_info(timelib_sll ts, timelib_tzinfo *tz)
timelib_sll timelib_get_current_offset(timelib_time *t)
int timelib_timezone_id_is_valid(const char *timezone, const timelib_tzdb *tzdb)
const timelib_tzdb * timelib_builtin_db(void)
php_info_print_table_start()
php_info_print_table_row(2, "PDO Driver for Firebird", "enabled")
php_info_print_table_end()
#define PHP_MSHUTDOWN_FUNCTION
#define PHP_MINIT_FUNCTION
#define PHP_MINFO_FUNCTION
#define PHP_GINIT_FUNCTION
#define PHP_RINIT_FUNCTION
#define PHP_RSHUTDOWN_FUNCTION
#define PHP_MODULE_GLOBALS
PHPAPI zend_long php_parse_date(const char *string, zend_long *now)
PHPAPI zend_class_entry * php_date_get_immutable_ce(void)
#define PHP_DATE_PERIOD_INCLUDE_END_DATE
#define GET_VALUE_FROM_STRUCT(n, m)
#define PHP_DATE_TIMEZONE_GROUP_UTC
#define PHP_DATE_TIMEZONE_GROUP_ATLANTIC
PHPAPI zend_class_entry * php_date_get_date_ce(void)
int php_date_global_timezone_db_enabled
#define DATE_SUNRISE_ZENITH
#define PHP_DATE_TIMEZONE_GROUP_INDIAN
#define PHP_DATE_TIMEZONE_PER_COUNTRY
PHPAPI zend_class_entry * php_date_get_period_ce(void)
PHPAPI zend_class_entry * php_date_get_interface_ce(void)
#define PHP_DATE_TIMEZONE_GROUP_AMERICA
PHPAPI int php_idate(char format, time_t ts, bool localtime)
#define PHP_DATE_TIMEZONE_GROUP_ALL_W_BC
#define PHP_DATE_TIMEZONE_GROUP_PACIFIC
PHPAPI zend_string * php_format_date_obj(const char *format, size_t format_len, php_date_obj *date_obj)
#define PHP_DATE_PARSE_DATE_SET_TIME_ELEMENT(name, elem)
#define PHP_DATE_TIMEZONE_GROUP_AUSTRALIA
PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, bool gmt)
#define SUNFUNCS_RET_STRING
PHPAPI timelib_tzinfo * get_timezone_info(void)
#define SUNFUNCS_RET_TIMESTAMP
#define PHP_DATE_TIMEZONE_GROUP_EUROPE
timelib_tzdb * php_date_global_timezone_db
#define DATE_CHECK_INITIALIZED(member, ce)
#define PHP_DATE_TIMEZONE_GROUP_AFRICA
#define PHP_DATE_INTERVAL_ADD_PROPERTY(n, f)
zend_module_entry date_module_entry
#define DATE_SUNSET_ZENITH
#define PHP_DATE_INTERVAL_READ_PROPERTY_DAYS(member)
#define PHP_DATE_PERIOD_EXCLUDE_START_DATE
PHPAPI bool php_date_initialize_from_ts_double(php_date_obj *dateobj, double ts)
PHPAPI zend_string * php_format_date(const char *format, size_t format_len, time_t ts, bool localtime)
#define SET_VALUE_FROM_STRUCT(n, m)
PHPAPI zend_class_entry * php_date_get_timezone_ce(void)
PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb)
#define add_by_index(i, ts)
#define PHP_DATE_TIMEZONE_GROUP_ARCTIC
PHPAPI time_t php_time(void)
#define PHP_DATE_INTERVAL_READ_PROPERTY_I64(element, member)
#define PHP_DATE_TIMEZONE_GROUP_ANTARCTICA
PHPAPI bool php_date_initialize(php_date_obj *dateobj, const char *time_str, size_t time_str_len, const char *format, zval *timezone_object, int flags)
PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, bool gmt)
#define PHP_DATE_TIMEZONE_GROUP_ASIA
#define PHP_DATE_TIMEZONE_GROUP_ALL
PHPAPI zval * php_date_instantiate(zend_class_entry *pce, zval *object)
#define SUNFUNCS_RET_DOUBLE
#define DATE_DEFAULT_LONGITUDE
ZEND_PARSE_PARAMETERS_NONE()
PHPAPI zend_class_entry * php_date_get_interval_ce(void)
#define DATE_DEFAULT_LATITUDE
PHPAPI void php_date_initialize_from_ts_long(php_date_obj *dateobj, zend_long sec, int usec)
#define add_from_tto(to, ts)
#define PHP_DATE_INTERVAL_READ_PROPERTY(element, member, itype, def)
#define Z_PHPINTERVAL_P(zv)
#define Z_PHPPERIOD_P(zv)
struct _php_timezone_obj php_timezone_obj
#define Z_PHPTIMEZONE_P(zv)
#define PHP_DATE_INIT_FORMAT
struct _php_interval_obj php_interval_obj
#define PHP_DATE_INIT_CTOR
struct _php_date_obj php_date_obj
#define PHP_DATE_DOUBLE_FITS_LONG(d)
timelib_error_container * last_errors
struct _php_period_obj php_period_obj
date_sun_info(int $timestamp, float $latitude, float $longitude)
date_default_timezone_get()
timezone_open(string $timezone)
gmdate(string $format, ?int $timestamp=null)
date_default_timezone_set(string $timezoneId)
timezone_abbreviations_list()
date(string $format, ?int $timestamp=null)
date_parse_from_format(string $format, string $datetime)
date_sunset(int $timestamp, int $returnFormat=SUNFUNCS_RET_STRING, ?float $latitude=null, ?float $longitude=null, ?float $zenith=null, ?float $utcOffset=null)
idate(string $format, ?int $timestamp=null)
date_time_set(DateTime $object, int $hour, int $minute, int $second=0, int $microsecond=0)
date_timezone_get(DateTimeInterface $object)
timezone_name_get(DateTimeZone $object)
date_date_set(DateTime $object, int $year, int $month, int $day)
timezone_location_get(DateTimeZone $object)
getdate(?int $timestamp=null)
date_add(DateTime $object, DateInterval $interval)
date_create_immutable(string $datetime="now", ?DateTimeZone $timezone=null)
date_timezone_set(DateTime $object, DateTimeZone $timezone)
mktime(int $hour, ?int $minute=null, ?int $second=null, ?int $month=null, ?int $day=null, ?int $year=null)
date_sunrise(int $timestamp, int $returnFormat=SUNFUNCS_RET_STRING, ?float $latitude=null, ?float $longitude=null, ?float $zenith=null, ?float $utcOffset=null)
checkdate(int $month, int $day, int $year)
date_parse(string $datetime)
timezone_name_from_abbr(string $abbr, int $utcOffset=-1, int $isDST=-1)
date_create_from_format(string $format, string $datetime, ?DateTimeZone $timezone=null)
date_timestamp_get(DateTimeInterface $object)
date_create(string $datetime="now", ?DateTimeZone $timezone=null)
date_isodate_set(DateTime $object, int $year, int $week, int $dayOfWeek=1)
date_sub(DateTime $object, DateInterval $interval)
gmstrftime(string $format, ?int $timestamp=null)
timezone_offset_get(DateTimeZone $object, DateTimeInterface $datetime)
date_diff(DateTimeInterface $baseObject, DateTimeInterface $targetObject, bool $absolute=false)
strtotime(string $datetime, ?int $baseTimestamp=null)
date_interval_create_from_date_string(string $datetime)
date_timestamp_set(DateTime $object, int $timestamp)
gmmktime(int $hour, ?int $minute=null, ?int $second=null, ?int $month=null, ?int $day=null, ?int $year=null)
strftime(string $format, ?int $timestamp=null)
date_modify(DateTime $object, string $modifier)
localtime(?int $timestamp=null, bool $associative=false)
date_offset_get(DateTimeInterface $object)
timezone_transitions_get(DateTimeZone $object, int $timestampBegin=PHP_INT_MIN, int $timestampEnd=PHP_INT_MAX)
date_create_immutable_from_format(string $format, string $datetime, ?DateTimeZone $timezone=null)
timezone_identifiers_list(int $timezoneGroup=DateTimeZone::ALL, ?string $countryCode=null)
unsigned const char * end
PHPAPI zval * cfg_get_entry(const char *name, size_t name_length)
#define STD_PHP_INI_ENTRY
PHP_JSON_API size_t int options
unsigned char key[REFLECTION_KEY_LEN]
PHPAPI int php_version_compare(const char *, const char *)
zend_string * date_string
timelib_rel_time * interval
zend_class_entry * start_ce
union _php_timezone_obj::@213245010343033015320150043202117071337023242314 tzi
timelib_posix_trans_info * dst_end
struct _timelib_rel_time::@101250100307152364107271232245320174113050270325 special
unsigned int have_special_relative
unsigned int have_weekday_relative
unsigned int is_localtime
unsigned int sse_uptodate
unsigned int have_relative
timelib_rel_time relative
const char * full_tz_name
const unsigned char * data
struct _timelib_tzinfo::@164363312306351063307143032200107146325273170202 bit64
timelib_posix_str * posix_info
zend_class_entry * parent
const zend_object_iterator_funcs * funcs
zend_object_iterator intern
void timelib_time_offset_dtor(timelib_time_offset *t)
timelib_time * timelib_time_ctor(void)
timelib_long timelib_date_to_int(timelib_time *d, int *error)
timelib_time * timelib_time_clone(timelib_time *orig)
int timelib_time_compare(timelib_time *t1, timelib_time *t2)
void timelib_error_container_dtor(timelib_error_container *errors)
timelib_rel_time * timelib_rel_time_clone(timelib_rel_time *rel)
void timelib_time_dtor(timelib_time *t)
timelib_time_offset * timelib_time_offset_ctor(void)
void timelib_rel_time_dtor(timelib_rel_time *t)
timelib_rel_time * timelib_rel_time_ctor(void)
void timelib_unixtime2local(timelib_time *tm, timelib_sll ts)
#define TIMELIB_ZONETYPE_ID
void timelib_unixtime2gmt(timelib_time *tm, timelib_sll ts)
void timelib_set_timezone_from_offset(timelib_time *t, timelib_sll utc_offset)
struct _timelib_error_container timelib_error_container
#define TIMELIB_OVERRIDE_TIME
void timelib_unixtime2date(timelib_sll ts, timelib_sll *y, timelib_sll *m, timelib_sll *d)
void timelib_update_ts(timelib_time *time, timelib_tzinfo *tzi)
void timelib_update_from_sse(timelib_time *tm)
#define TIMELIB_ZONETYPE_OFFSET
struct _timelib_tzdb timelib_tzdb
#define TIMELIB_ASCII_VERSION
struct _timelib_time timelib_time
void timelib_set_timezone(timelib_time *t, timelib_tzinfo *tz)
struct _timelib_rel_time timelib_rel_time
struct _timelib_tzdb_index_entry timelib_tzdb_index_entry
signed long long timelib_sll
struct _timelib_time_offset timelib_time_offset
struct _timelib_tzinfo timelib_tzinfo
struct _timelib_tz_lookup_table timelib_tz_lookup_table
#define TIMELIB_ZONETYPE_ABBR
struct _timelib_posix_transitions timelib_posix_transitions
void timelib_set_timezone_from_abbr(timelib_time *t, timelib_abbr_info abbr_info)
#define TIMELIB_SPECIAL_WEEKDAY
#define TIMELIB_SPECIAL_FIRST_DAY_OF_MONTH
#define timelib_is_leap(y)
ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char *format,...)
ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format,...)
ZEND_API ZEND_COLD void zend_type_error(const char *format,...)
ZEND_API ZEND_COLD void zend_error(int type, const char *format,...)
#define INTERNAL_FUNCTION_PARAMETERS
ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current)
ZEND_API void zend_restore_error_handling(zend_error_handling *saved)
#define INTERNAL_FUNCTION_PARAM_PASSTHRU
ZEND_API void add_assoc_bool_ex(zval *arg, const char *key, size_t key_len, bool b)
ZEND_API zend_result add_next_index_long(zval *arg, zend_long n)
ZEND_API zend_result object_init_ex(zval *arg, zend_class_entry *class_type)
ZEND_API ZEND_COLD void zend_argument_error(zend_class_entry *error_ce, uint32_t arg_num, const char *format,...)
ZEND_API void add_index_string(zval *arg, zend_ulong index, const char *str)
ZEND_API void add_assoc_string_ex(zval *arg, const char *key, size_t key_len, const char *str)
ZEND_API void zend_update_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zval *value)
ZEND_API void object_properties_init(zend_object *object, zend_class_entry *class_type)
ZEND_API void add_assoc_long_ex(zval *arg, const char *key, size_t key_len, zend_long n)
ZEND_API zend_result zend_parse_method_parameters(uint32_t num_args, zval *this_ptr, const char *type_spec,...)
ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *format,...)
ZEND_API zend_result add_next_index_string(zval *arg, const char *str)
ZEND_API void add_assoc_null_ex(zval *arg, const char *key, size_t key_len)
ZEND_API void add_index_long(zval *arg, zend_ulong index, zend_long n)
ZEND_API zend_result zend_parse_parameters_ex(int flags, uint32_t num_args, const char *type_spec,...)
#define Z_PARAM_NUMBER(dest)
#define Z_PARAM_PATH_STR(dest)
#define ZEND_PARSE_PARAMS_QUIET
#define ZEND_PARSE_PARAMETERS_END()
#define ZEND_MODULE_POST_ZEND_DEACTIVATE_N(module)
#define ZVAL_STRING(z, s)
#define ZEND_DECLARE_MODULE_GLOBALS(module_name)
#define Z_PARAM_STRING(dest, dest_len)
#define Z_PARAM_STR(dest)
#define Z_PARAM_STRING_OR_NULL(dest, dest_len)
#define Z_PARAM_DOUBLE_OR_NULL(dest, is_null)
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)
#define Z_PARAM_LONG(dest)
#define RETURN_NEW_STR(s)
#define RETURN_OBJ_COPY(r)
#define ZEND_MODULE_POST_ZEND_DEACTIVATE_D(module)
#define Z_PARAM_DOUBLE(dest)
#define Z_PARAM_LONG_OR_NULL(dest, is_null)
#define Z_PARAM_OBJECT_OF_CLASS_OR_NULL(dest, _ce)
#define Z_PARAM_BOOL(dest)
#define Z_PARAM_OBJECT_OF_CLASS(dest, _ce)
#define Z_PARAM_PATH(dest, dest_len)
#define Z_PARAM_ARRAY(dest)
#define estrndup(s, length)
#define ecalloc(nmemb, size)
#define FREE_HASHTABLE(ht)
#define ALLOC_HASHTABLE(ht)
strcmp(string $string1, string $string2)
zend_string_release_ex(func->internal_function.function_name, 0)
ZEND_API zend_result zend_unmangle_property_name_ex(const zend_string *name, const char **class_name, const char **prop_name, size_t *prop_len)
#define ZEND_INTERNAL_CLASS
#define strncasecmp(s1, s2, n)
ZEND_API zend_class_entry * zend_ce_exception
ZEND_API ZEND_COLD zend_object * zend_throw_exception_ex(zend_class_entry *exception_ce, zend_long code, const char *format,...)
ZEND_API zend_class_entry * zend_ce_error
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_readonly_property_modification_error_ex(const char *class_name, const char *prop_name)
ZEND_API zend_class_entry * zend_lookup_class(zend_string *name)
ZEND_API zend_string * get_active_function_or_method_name(void)
ZEND_API void ZEND_FASTCALL zend_hash_destroy(HashTable *ht)
ZEND_API zval *ZEND_FASTCALL zend_hash_str_find(const HashTable *ht, const char *str, size_t len)
ZEND_API zval *ZEND_FASTCALL zend_hash_str_update(HashTable *ht, const char *str, size_t len, zval *pData)
ZEND_API HashTable *ZEND_FASTCALL zend_array_dup(HashTable *source)
ZEND_API zval *ZEND_FASTCALL zend_hash_add(HashTable *ht, zend_string *key, zval *pData)
#define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent)
#define ZEND_HASH_FOREACH_STR_KEY_VAL_IND(ht, _key, _val)
#define ZEND_HASH_FOREACH_STR_KEY_VAL(ht, _key, _val)
#define ZEND_HASH_FOREACH_END()
#define UNREGISTER_INI_ENTRIES()
#define REGISTER_INI_ENTRIES()
#define DISPLAY_INI_ENTRIES()
ZEND_API zend_class_entry * zend_ce_aggregate
ZEND_API zend_result zend_create_internal_iterator_zval(zval *return_value, zval *obj)
ZEND_API void zend_iterator_init(zend_object_iterator *iter)
struct _zend_object_iterator zend_object_iterator
struct _zend_object_iterator_funcs zend_object_iterator_funcs
#define ZEND_LONG_FMT_SPEC
struct _zend_string zend_string
struct _zend_module_entry zend_module_entry
#define STANDARD_MODULE_PROPERTIES_EX
#define STANDARD_MODULE_HEADER_EX
ZEND_API zval * zend_std_get_property_ptr_ptr(zend_object *zobj, zend_string *name, int type, void **cache_slot)
ZEND_API HashTable * zend_std_get_properties_for(zend_object *obj, zend_prop_purpose purpose)
ZEND_API HashTable * zend_std_get_properties(zend_object *zobj)
ZEND_API int zend_std_has_property(zend_object *zobj, zend_string *name, int has_set_exists, void **cache_slot)
ZEND_API const zend_object_handlers std_object_handlers
ZEND_API zval * zend_std_write_property(zend_object *zobj, zend_string *name, zval *value, void **cache_slot)
ZEND_API zval * zend_std_read_property(zend_object *zobj, zend_string *name, int type, void **cache_slot, zval *rv)
enum _zend_prop_purpose zend_prop_purpose
@ ZEND_PROP_PURPOSE_DEBUG
@ ZEND_PROP_PURPOSE_SERIALIZE
@ ZEND_PROP_PURPOSE_ARRAY_CAST
@ ZEND_PROP_PURPOSE_VAR_EXPORT
#define ZEND_COMPARE_OBJECTS_FALLBACK(op1, op2)
ZEND_API void ZEND_FASTCALL zend_objects_clone_members(zend_object *new_object, zend_object *old_object)
ZEND_API void ZEND_FASTCALL zend_object_std_init(zend_object *object, zend_class_entry *ce)
ZEND_API void zend_object_std_dtor(zend_object *object)
ZEND_API bool ZEND_FASTCALL zend_is_true(const zval *op)
#define ZEND_UNCOMPARABLE
#define XtOffsetOf(s_type, field)
#define EMPTY_SWITCH_DEFAULT_CASE()
#define UNEXPECTED(condition)
struct _zend_class_entry zend_class_entry
struct _zend_object zend_object
ZEND_API zend_string * zend_string_concat3(const char *str1, size_t str1_len, const char *str2, size_t str2_len, const char *str3, size_t str3_len)
#define ZSTR_INIT_LITERAL(s, persistent)
#define zend_string_equals_literal(str, literal)
#define ZSTR_EMPTY_ALLOC()
#define Z_TRY_ADDREF_P(pz)
#define Z_STRVAL_P(zval_p)
#define Z_ARRVAL_P(zval_p)
#define ZVAL_STR_COPY(z, s)
struct _zend_array HashTable
#define Z_STRLEN_P(zval_p)
#define Z_OBJCE_P(zval_p)
#define ZVAL_NEW_STR(z, s)
#define Z_OBJPROP_P(zval_p)
#define ZVAL_DOUBLE(z, d)
#define ZVAL_OBJ_COPY(z, o)
ZEND_RESULT_CODE zend_result
struct _zend_object_handlers zend_object_handlers
#define ZVAL_COPY_VALUE(z, v)
ZEND_API void zval_ptr_dtor(zval *zval_ptr)