com php-src: Implemented FR #71520: NEWS ext/date/php_date. c ext/date/tests/DateTimeImmutable_constants.phpt ext/d
ate/tests/DateTimeInterface_constants.phpt ext/date/tests /DateTime_constants.phpt
| From: | Nikita Popov | Date: | Fri, 02 Jun 2017 22:54:34 +0000 |
| Subject: | com php-src: Implemented FR #71520: NEWS ext/date/php_date. c ext/date/tests/DateTimeImmutable_constants.phpt ext/d ate/tests/DateTimeInterface_constants.phpt ext/date/tests /DateTime_constants.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-97997@lists.php.net to get a copy of this message | ||
Commit: 637714cdaa80d1d3450df5186710b25b54463fa6
Author: Michael Moravec <mail@majkl578.cz> Mon, 17 Apr 2017 18:06:20 +0200
Committer: Nikita Popov <nikita.ppv@gmail.com> Sat, 3 Jun 2017 00:54:34 +0200
Parents: d9886614dcfdd8e03015814804249a57b26ba9d0
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=637714cdaa80d1d3450df5186710b25b54463fa6
Log:
Implemented FR #71520
Adding the DateTime constants to the DateTimeInterface interface.
Bugs:
https://bugs.php.net/71520
Changed paths:
M NEWS
M ext/date/php_date.c
A ext/date/tests/DateTimeImmutable_constants.phpt
A ext/date/tests/DateTimeInterface_constants.phpt
A ext/date/tests/DateTime_constants.phpt
Diff:
diff --git a/NEWS b/NEWS
index 2a65522..5b6a9ba 100644
--- a/NEWS
+++ b/NEWS
@@ -73,6 +73,8 @@ PHP NEWS
. Fixed bug #74080 (add constant for RFC7231 format datetime). (duncan3dc)
. Fixed bug #74639 (implement clone for DatePeriod and DateInterval).
(andrewnester)
+ . Implemented FR #71520 (Adding the DateTime constants to the
+ DateTimeInterface interface). (Majkl578)
- Dba:
. Fixed bug #72885 (flatfile: dba_fetch() fails to read replaced entry).
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index ac08f36..5bd9b8e 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -2064,6 +2064,23 @@ static void date_register_classes(void) /* {{{ */
date_ce_interface = zend_register_internal_interface(&ce_interface);
date_ce_interface->interface_gets_implemented = implement_date_interface_handler;
+#define REGISTER_DATE_INTERFACE_CONST_STRING(const_name, value) \
+ zend_declare_class_constant_stringl(date_ce_interface, const_name, sizeof(const_name)-1, value,
sizeof(value)-1);
+
+ REGISTER_DATE_INTERFACE_CONST_STRING("ATOM", DATE_FORMAT_RFC3339);
+ REGISTER_DATE_INTERFACE_CONST_STRING("COOKIE", DATE_FORMAT_COOKIE);
+ REGISTER_DATE_INTERFACE_CONST_STRING("ISO8601", DATE_FORMAT_ISO8601);
+ REGISTER_DATE_INTERFACE_CONST_STRING("RFC822", DATE_FORMAT_RFC822);
+ REGISTER_DATE_INTERFACE_CONST_STRING("RFC850", DATE_FORMAT_RFC850);
+ REGISTER_DATE_INTERFACE_CONST_STRING("RFC1036", DATE_FORMAT_RFC1036);
+ REGISTER_DATE_INTERFACE_CONST_STRING("RFC1123", DATE_FORMAT_RFC1123);
+ REGISTER_DATE_INTERFACE_CONST_STRING("RFC7231", DATE_FORMAT_RFC7231);
+ REGISTER_DATE_INTERFACE_CONST_STRING("RFC2822", DATE_FORMAT_RFC2822);
+ REGISTER_DATE_INTERFACE_CONST_STRING("RFC3339", DATE_FORMAT_RFC3339);
+ REGISTER_DATE_INTERFACE_CONST_STRING("RFC3339_EXTENDED", DATE_FORMAT_RFC3339_EXTENDED);
+ REGISTER_DATE_INTERFACE_CONST_STRING("RSS", DATE_FORMAT_RFC1123);
+ REGISTER_DATE_INTERFACE_CONST_STRING("W3C", DATE_FORMAT_RFC3339);
+
INIT_CLASS_ENTRY(ce_date, "DateTime", date_funcs_date);
ce_date.create_object = date_object_new_date;
date_ce_date = zend_register_internal_class_ex(&ce_date, NULL);
@@ -2076,23 +2093,6 @@ static void date_register_classes(void) /* {{{ */
date_object_handlers_date.get_gc = date_object_get_gc;
zend_class_implements(date_ce_date, 1, date_ce_interface);
-#define REGISTER_DATE_CLASS_CONST_STRING(const_name, value) \
- zend_declare_class_constant_stringl(date_ce_date, const_name, sizeof(const_name)-1, value,
sizeof(value)-1);
-
- REGISTER_DATE_CLASS_CONST_STRING("ATOM", DATE_FORMAT_RFC3339);
- REGISTER_DATE_CLASS_CONST_STRING("COOKIE", DATE_FORMAT_COOKIE);
- REGISTER_DATE_CLASS_CONST_STRING("ISO8601", DATE_FORMAT_ISO8601);
- REGISTER_DATE_CLASS_CONST_STRING("RFC822", DATE_FORMAT_RFC822);
- REGISTER_DATE_CLASS_CONST_STRING("RFC850", DATE_FORMAT_RFC850);
- REGISTER_DATE_CLASS_CONST_STRING("RFC1036", DATE_FORMAT_RFC1036);
- REGISTER_DATE_CLASS_CONST_STRING("RFC1123", DATE_FORMAT_RFC1123);
- REGISTER_DATE_CLASS_CONST_STRING("RFC7231", DATE_FORMAT_RFC7231);
- REGISTER_DATE_CLASS_CONST_STRING("RFC2822", DATE_FORMAT_RFC2822);
- REGISTER_DATE_CLASS_CONST_STRING("RFC3339", DATE_FORMAT_RFC3339);
- REGISTER_DATE_CLASS_CONST_STRING("RFC3339_EXTENDED", DATE_FORMAT_RFC3339_EXTENDED);
- REGISTER_DATE_CLASS_CONST_STRING("RSS", DATE_FORMAT_RFC1123);
- REGISTER_DATE_CLASS_CONST_STRING("W3C", DATE_FORMAT_RFC3339);
-
INIT_CLASS_ENTRY(ce_immutable, "DateTimeImmutable", date_funcs_immutable);
ce_immutable.create_object = date_object_new_date;
date_ce_immutable = zend_register_internal_class_ex(&ce_immutable, NULL);
diff --git a/ext/date/tests/DateTimeImmutable_constants.phpt
b/ext/date/tests/DateTimeImmutable_constants.phpt
new file mode 100644
index 0000000..a3e7c0c
--- /dev/null
+++ b/ext/date/tests/DateTimeImmutable_constants.phpt
@@ -0,0 +1,32 @@
+--TEST--
+DateTimeImmutable constants
+--FILE--
+<?php
+
+var_dump(
+ DATE_ATOM === DateTimeImmutable::ATOM,
+ DATE_COOKIE === DateTimeImmutable::COOKIE,
+ DATE_ISO8601 === DateTimeImmutable::ISO8601,
+ DATE_RFC822 === DateTimeImmutable::RFC822,
+ DATE_RFC850 === DateTimeImmutable::RFC850,
+ DATE_RFC1036 === DateTimeImmutable::RFC1036,
+ DATE_RFC1123 === DateTimeImmutable::RFC1123,
+ DATE_RFC2822 === DateTimeImmutable::RFC2822,
+ DATE_RFC3339 === DateTimeImmutable::RFC3339,
+ DATE_RSS === DateTimeImmutable::RSS,
+ DATE_W3C === DateTimeImmutable::W3C
+);
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
diff --git a/ext/date/tests/DateTimeInterface_constants.phpt
b/ext/date/tests/DateTimeInterface_constants.phpt
new file mode 100644
index 0000000..972714c
--- /dev/null
+++ b/ext/date/tests/DateTimeInterface_constants.phpt
@@ -0,0 +1,32 @@
+--TEST--
+DateTimeInterface constants
+--FILE--
+<?php
+
+var_dump(
+ DATE_ATOM === DateTimeInterface::ATOM,
+ DATE_COOKIE === DateTimeInterface::COOKIE,
+ DATE_ISO8601 === DateTimeInterface::ISO8601,
+ DATE_RFC822 === DateTimeInterface::RFC822,
+ DATE_RFC850 === DateTimeInterface::RFC850,
+ DATE_RFC1036 === DateTimeInterface::RFC1036,
+ DATE_RFC1123 === DateTimeInterface::RFC1123,
+ DATE_RFC2822 === DateTimeInterface::RFC2822,
+ DATE_RFC3339 === DateTimeInterface::RFC3339,
+ DATE_RSS === DateTimeInterface::RSS,
+ DATE_W3C === DateTimeInterface::W3C
+);
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
diff --git a/ext/date/tests/DateTime_constants.phpt b/ext/date/tests/DateTime_constants.phpt
new file mode 100644
index 0000000..44e8401
--- /dev/null
+++ b/ext/date/tests/DateTime_constants.phpt
@@ -0,0 +1,32 @@
+--TEST--
+DateTime constants
+--FILE--
+<?php
+
+var_dump(
+ DATE_ATOM === DateTime::ATOM,
+ DATE_COOKIE === DateTime::COOKIE,
+ DATE_ISO8601 === DateTime::ISO8601,
+ DATE_RFC822 === DateTime::RFC822,
+ DATE_RFC850 === DateTime::RFC850,
+ DATE_RFC1036 === DateTime::RFC1036,
+ DATE_RFC1123 === DateTime::RFC1123,
+ DATE_RFC2822 === DateTime::RFC2822,
+ DATE_RFC3339 === DateTime::RFC3339,
+ DATE_RSS === DateTime::RSS,
+ DATE_W3C === DateTime::W3C
+);
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)