summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/date/php_date.c97
-rw-r--r--ext/date/tests/bug33869.phpt12
-rw-r--r--ext/date/tests/bug34087.phpt8
-rw-r--r--ext/date/tests/bug34676.phpt2
-rw-r--r--ext/date/tests/bug34771.phpt2
-rw-r--r--ext/date/tests/date_create-1.phpt2
-rw-r--r--ext/date/tests/date_default_timezone_set-1.phpt8
-rw-r--r--ext/date/tests/mktime-3.phpt2
-rw-r--r--ext/date/tests/strtotime.phpt2
9 files changed, 68 insertions, 67 deletions
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index f904f4d3ac..f4e887f837 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -76,8 +76,9 @@ function_entry date_functions[] = {
{NULL, NULL, NULL}
};
-#ifdef EXPERIMENTAL_DATE_SUPPORT
+
function_entry date_funcs_date[] = {
+#ifdef EXPERIMENTAL_DATE_SUPPORT
ZEND_NAMED_FE(format, ZEND_FN(date_format), NULL)
ZEND_NAMED_FE(modify, ZEND_FN(date_modify), NULL)
ZEND_NAMED_FE(getTimezone, ZEND_FN(date_timezone_get), NULL)
@@ -86,25 +87,23 @@ function_entry date_funcs_date[] = {
ZEND_NAMED_FE(setTime, ZEND_FN(date_time_set), NULL)
ZEND_NAMED_FE(setDate, ZEND_FN(date_date_set), NULL)
ZEND_NAMED_FE(setISODate, ZEND_FN(date_isodate_set), NULL)
+#endif
{NULL, NULL, NULL}
};
function_entry date_funcs_timezone[] = {
+#ifdef EXPERIMENTAL_DATE_SUPPORT
ZEND_NAMED_FE(getName, ZEND_FN(timezone_name_get), NULL)
ZEND_NAMED_FE(getOffset, ZEND_FN(timezone_offset_get), NULL)
ZEND_NAMED_FE(getTransistions, ZEND_FN(timezone_transistions_get), NULL)
ZEND_MALIAS(timezone, listAbbreviations, abbreviations_list, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
ZEND_MALIAS(timezone, listIdentifiers, identifiers_list, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+#endif
{NULL, NULL, NULL}
};
-static void date_register_classes(TSRMLS_D);
-# define DATE_REGISTER_CLASSES date_register_classes(TSRMLS_C)
-#else
-# define DATE_REGISTER_CLASSES /* */
-#endif
-
static char* guess_timezone(TSRMLS_D);
+static void date_register_classes(TSRMLS_D);
/* }}} */
ZEND_DECLARE_MODULE_GLOBALS(date)
@@ -119,7 +118,11 @@ PHP_INI_BEGIN()
PHP_INI_END()
/* }}} */
-#ifdef EXPERIMENTAL_DATE_SUPPORT
+zend_class_entry *date_ce_date, *date_ce_timezone;
+
+static zend_object_handlers date_object_handlers_date;
+static zend_object_handlers date_object_handlers_timezone;
+
typedef struct _php_date_obj php_date_obj;
typedef struct _php_timezone_obj php_timezone_obj;
@@ -133,11 +136,7 @@ struct _php_timezone_obj {
timelib_tzinfo *tz;
};
-zend_class_entry *date_ce_date, *date_ce_timezone;
-
-static zend_object_handlers date_object_handlers_date;
-static zend_object_handlers date_object_handlers_timezone;
-
+#ifdef EXPERIMENTAL_DATE_SUPPORT
#define DATE_SET_CONTEXT \
zval *object; \
object = getThis(); \
@@ -156,12 +155,12 @@ static zend_object_handlers date_object_handlers_timezone;
} \
obj = (php_date_obj *) zend_object_store_get_object(object TSRMLS_CC); \
+#endif
-static zend_object_value date_object_new_date(zend_class_entry *class_type TSRMLS_DC);
-static zend_object_value date_object_new_timezone(zend_class_entry *class_type TSRMLS_DC);
static void date_object_free_storage_date(void *object TSRMLS_DC);
static void date_object_free_storage_timezone(void *object TSRMLS_DC);
-#endif
+static zend_object_value date_object_new_date(zend_class_entry *class_type TSRMLS_DC);
+static zend_object_value date_object_new_timezone(zend_class_entry *class_type TSRMLS_DC);
/* {{{ Module struct */
zend_module_entry date_module_entry = {
@@ -239,18 +238,7 @@ PHP_MINIT_FUNCTION(date)
ZEND_INIT_MODULE_GLOBALS(date, php_date_init_globals, NULL);
REGISTER_INI_ENTRIES();
- DATE_REGISTER_CLASSES;
-
- REGISTER_STRING_CONSTANT("DATE_ATOM", DATE_FORMAT_ISO8601, CONST_CS | CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("DATE_COOKIE", DATE_FORMAT_RFC1123, CONST_CS | CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("DATE_ISO8601", DATE_FORMAT_ISO8601, CONST_CS | CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("DATE_RFC822", DATE_FORMAT_RFC1123, CONST_CS | CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("DATE_RFC850", DATE_FORMAT_RFC1036, CONST_CS | CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("DATE_RFC1036", DATE_FORMAT_RFC1036, CONST_CS | CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("DATE_RFC1123", DATE_FORMAT_RFC1123, CONST_CS | CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("DATE_RFC2822", DATE_FORMAT_RFC2822, CONST_CS | CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("DATE_RSS", DATE_FORMAT_RFC1123, CONST_CS | CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("DATE_W3C", DATE_FORMAT_ISO8601, CONST_CS | CONST_PERSISTENT);
+ date_register_classes(TSRMLS_C);
php_date_global_timezone_db = NULL;
php_date_global_timezone_db_enabled = 0;
@@ -1128,7 +1116,38 @@ PHP_FUNCTION(getdate)
}
/* }}} */
-#ifdef EXPERIMENTAL_DATE_SUPPORT
+static void date_register_classes(TSRMLS_D)
+{
+ zend_class_entry ce_date, ce_timezone;
+
+ INIT_CLASS_ENTRY(ce_date, "date", date_funcs_date);
+ ce_date.create_object = date_object_new_date;
+ date_ce_date = zend_register_internal_class_ex(&ce_date, NULL, NULL TSRMLS_CC);
+ memcpy(&date_object_handlers_date, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ date_object_handlers_date.clone_obj = NULL;
+
+#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);
+
+ REGISTER_DATE_CLASS_CONST_STRING("ATOM", DATE_FORMAT_ISO8601);
+ REGISTER_DATE_CLASS_CONST_STRING("COOKIE", DATE_FORMAT_RFC1123);
+ REGISTER_DATE_CLASS_CONST_STRING("ISO8601", DATE_FORMAT_ISO8601);
+ REGISTER_DATE_CLASS_CONST_STRING("RFC822", DATE_FORMAT_RFC1123);
+ REGISTER_DATE_CLASS_CONST_STRING("RFC850", DATE_FORMAT_RFC1036);
+ REGISTER_DATE_CLASS_CONST_STRING("RFC1036", DATE_FORMAT_RFC1036);
+ REGISTER_DATE_CLASS_CONST_STRING("RFC1123", DATE_FORMAT_RFC1123);
+ REGISTER_DATE_CLASS_CONST_STRING("RFC2822", DATE_FORMAT_RFC2822);
+ REGISTER_DATE_CLASS_CONST_STRING("RSS", DATE_FORMAT_RFC1123);
+ REGISTER_DATE_CLASS_CONST_STRING("W3C", DATE_FORMAT_ISO8601);
+
+
+ INIT_CLASS_ENTRY(ce_timezone, "timezone", 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 = NULL;
+}
+
static zend_object_value date_object_new_date(zend_class_entry *class_type TSRMLS_DC)
{
php_date_obj *intern;
@@ -1175,28 +1194,10 @@ static void date_object_free_storage_date(void *object TSRMLS_DC)
static void date_object_free_storage_timezone(void *object TSRMLS_DC)
{
- php_timezone_obj *intern = (php_timezone_obj *)object;
-
efree(object);
}
-static void date_register_classes(TSRMLS_D)
-{
- zend_class_entry ce_date, ce_timezone;
-
- INIT_CLASS_ENTRY(ce_date, "date", date_funcs_date);
- ce_date.create_object = date_object_new_date;
- date_ce_date = zend_register_internal_class_ex(&ce_date, NULL, NULL TSRMLS_CC);
- memcpy(&date_object_handlers_date, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
- date_object_handlers_date.clone_obj = NULL;
-
- INIT_CLASS_ENTRY(ce_timezone, "timezone", 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 = NULL;
-}
-
+#ifdef EXPERIMENTAL_DATE_SUPPORT
/* Advanced Interface */
static zval * date_instanciate(zend_class_entry *pce, zval *object TSRMLS_DC)
{
diff --git a/ext/date/tests/bug33869.phpt b/ext/date/tests/bug33869.phpt
index 6957a6b7e2..fc2c4833fa 100644
--- a/ext/date/tests/bug33869.phpt
+++ b/ext/date/tests/bug33869.phpt
@@ -4,17 +4,17 @@ Bug #33869 (strtotime() doesn't parse "+1days" format)
<?php
date_default_timezone_set("UTC");
$tm = strtotime("2005-01-01 01:01:01");
- echo date(DATE_ISO8601, strtotime('+5days', $tm));
+ echo date(date::ISO8601, strtotime('+5days', $tm));
echo "\n";
- echo date(DATE_ISO8601, strtotime('+1month', $tm));
+ echo date(date::ISO8601, strtotime('+1month', $tm));
echo "\n";
- echo date(DATE_ISO8601, strtotime('+1year', $tm));
+ echo date(date::ISO8601, strtotime('+1year', $tm));
echo "\n";
- echo date(DATE_ISO8601, strtotime('+5 days', $tm));
+ echo date(date::ISO8601, strtotime('+5 days', $tm));
echo "\n";
- echo date(DATE_ISO8601, strtotime('+1 month', $tm));
+ echo date(date::ISO8601, strtotime('+1 month', $tm));
echo "\n";
- echo date(DATE_ISO8601, strtotime('+1 year', $tm));
+ echo date(date::ISO8601, strtotime('+1 year', $tm));
echo "\n";
?>
--EXPECT--
diff --git a/ext/date/tests/bug34087.phpt b/ext/date/tests/bug34087.phpt
index 3fa3885481..76640c3954 100644
--- a/ext/date/tests/bug34087.phpt
+++ b/ext/date/tests/bug34087.phpt
@@ -6,10 +6,10 @@ date_default_timezone_set("UTC");
echo "Y/m/d: ", strtotime("2005/8/12"), "\n";
echo "Y-m-d: ", strtotime("2005-8-12"), "\n";
-echo date(DATE_ISO8601, strtotime("2005/1/2")), "\n";
-echo date(DATE_ISO8601, strtotime("2005/01/02")), "\n";
-echo date(DATE_ISO8601, strtotime("2005/01/2")), "\n";
-echo date(DATE_ISO8601, strtotime("2005/1/02")), "\n";
+echo date(date::ISO8601, strtotime("2005/1/2")), "\n";
+echo date(date::ISO8601, strtotime("2005/01/02")), "\n";
+echo date(date::ISO8601, strtotime("2005/01/2")), "\n";
+echo date(date::ISO8601, strtotime("2005/1/02")), "\n";
?>
--EXPECT--
Y/m/d: 1123804800
diff --git a/ext/date/tests/bug34676.phpt b/ext/date/tests/bug34676.phpt
index 6f616feb40..84f58e922a 100644
--- a/ext/date/tests/bug34676.phpt
+++ b/ext/date/tests/bug34676.phpt
@@ -10,7 +10,7 @@ $tests = array(
foreach ($tests as $test) {
$t = strtotime("2005-12-22 ". $test);
- printf("%-10s => %s\n", $test, date(DATE_ISO8601, $t));
+ printf("%-10s => %s\n", $test, date(date::ISO8601, $t));
}
?>
diff --git a/ext/date/tests/bug34771.phpt b/ext/date/tests/bug34771.phpt
index a27d085a1d..bed9511d60 100644
--- a/ext/date/tests/bug34771.phpt
+++ b/ext/date/tests/bug34771.phpt
@@ -13,7 +13,7 @@ $tests = array(
foreach ($tests as $test) {
$t = strtotime("2005-12-22 ". $test);
- printf("%-10s => %s\n", $test, date(DATE_ISO8601, $t));
+ printf("%-10s => %s\n", $test, date(date::ISO8601, $t));
}
?>
diff --git a/ext/date/tests/date_create-1.phpt b/ext/date/tests/date_create-1.phpt
index 0f4fe59867..c66bb6fd30 100644
--- a/ext/date/tests/date_create-1.phpt
+++ b/ext/date/tests/date_create-1.phpt
@@ -28,7 +28,7 @@ $d[] = date_create("2005-07-14 22:30:41 Europe/Oslo", $tz1);
$d[] = date_create("2005-07-14 22:30:41 America/Los_Angeles", $tz2);
foreach($d as $date) {
- echo $date->format(DATE_ISO8601), "\n";
+ echo $date->format(date::ISO8601), "\n";
}
?>
--EXPECT--
diff --git a/ext/date/tests/date_default_timezone_set-1.phpt b/ext/date/tests/date_default_timezone_set-1.phpt
index 90916e9238..3b422a8690 100644
--- a/ext/date/tests/date_default_timezone_set-1.phpt
+++ b/ext/date/tests/date_default_timezone_set-1.phpt
@@ -12,10 +12,10 @@ date.timezone=
$date4 = strtotime("2005-07-12 08:00:00");
echo date_default_timezone_get(), "\n";
- echo date(DATE_ISO8601, $date1), "\n";
- echo date(DATE_ISO8601, $date2), "\n";
- echo date(DATE_ISO8601, $date3), "\n";
- echo date(DATE_ISO8601, $date4), "\n";
+ echo date(date::ISO8601, $date1), "\n";
+ echo date(date::ISO8601, $date2), "\n";
+ echo date(date::ISO8601, $date3), "\n";
+ echo date(date::ISO8601, $date4), "\n";
?>
--EXPECTF--
Strict Standards: strtotime(): It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. We selected 'Europe/London' for 'UTC/0.0/no DST' instead in %sdate_default_timezone_set-1.php on line 3
diff --git a/ext/date/tests/mktime-3.phpt b/ext/date/tests/mktime-3.phpt
index d4ccfbabe4..7e9aa62d93 100644
--- a/ext/date/tests/mktime-3.phpt
+++ b/ext/date/tests/mktime-3.phpt
@@ -16,7 +16,7 @@ foreach ($tzs as $tz) {
if ($ret == FALSE) {
echo "out of range\n";
} else {
- echo date("F ".DATE_ISO8601, $ret), "\n";
+ echo date("F ".date::ISO8601, $ret), "\n";
}
}
echo "\n";
diff --git a/ext/date/tests/strtotime.phpt b/ext/date/tests/strtotime.phpt
index 6560d7f1fd..e8eea399d2 100644
--- a/ext/date/tests/strtotime.phpt
+++ b/ext/date/tests/strtotime.phpt
@@ -8,7 +8,7 @@ $d[] = strtotime("2005-07-14 22:30:41");
$d[] = strtotime("2005-07-14 22:30:41 GMT");
foreach($d as $date) {
- echo date(DATE_ISO8601, $date), "\n";
+ echo date(date::ISO8601, $date), "\n";
}
?>
--EXPECT--