1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Extended tests with date constants

This commit is contained in:
jorgsowa
2023-05-15 00:15:13 +02:00
committed by Derick Rethans
parent e9e6eb714e
commit e7e5f1f2d4
7 changed files with 130 additions and 65 deletions

View File

@@ -4,17 +4,20 @@ DateTimeImmutable constants
<?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
DATE_ATOM === DateTimeImmutable::ATOM,
DATE_COOKIE === DateTimeImmutable::COOKIE,
DATE_ISO8601 === DateTimeImmutable::ISO8601,
DATE_ISO8601_EXPANDED === DateTimeImmutable::ISO8601_EXPANDED,
DATE_RFC822 === DateTimeImmutable::RFC822,
DATE_RFC850 === DateTimeImmutable::RFC850,
DATE_RFC1036 === DateTimeImmutable::RFC1036,
DATE_RFC1123 === DateTimeImmutable::RFC1123,
DATE_RFC7231 === DateTimeImmutable::RFC7231,
DATE_RFC2822 === DateTimeImmutable::RFC2822,
DATE_RFC3339 === DateTimeImmutable::RFC3339,
DATE_RFC3339_EXTENDED === DateTimeImmutable::RFC3339_EXTENDED,
DATE_RSS === DateTimeImmutable::RSS,
DATE_W3C === DateTimeImmutable::W3C
);
?>
@@ -30,3 +33,6 @@ bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)

View File

@@ -4,17 +4,20 @@ DateTimeInterface constants
<?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
DATE_ATOM === DateTimeInterface::ATOM,
DATE_COOKIE === DateTimeInterface::COOKIE,
DATE_ISO8601 === DateTimeInterface::ISO8601,
DATE_ISO8601_EXPANDED === DateTimeInterface::ISO8601_EXPANDED,
DATE_RFC822 === DateTimeInterface::RFC822,
DATE_RFC850 === DateTimeInterface::RFC850,
DATE_RFC1036 === DateTimeInterface::RFC1036,
DATE_RFC1123 === DateTimeInterface::RFC1123,
DATE_RFC7231 === DateTimeImmutable::RFC7231,
DATE_RFC2822 === DateTimeInterface::RFC2822,
DATE_RFC3339 === DateTimeInterface::RFC3339,
DATE_RFC3339_EXTENDED === DateTimeInterface::RFC3339_EXTENDED,
DATE_RSS === DateTimeInterface::RSS,
DATE_W3C === DateTimeInterface::W3C
);
?>
@@ -30,3 +33,6 @@ bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)

View File

@@ -4,17 +4,20 @@ DateTime constants
<?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
DATE_ATOM === DateTime::ATOM,
DATE_COOKIE === DateTime::COOKIE,
DATE_ISO8601 === DateTime::ISO8601,
DATE_ISO8601_EXPANDED === DateTime::ISO8601_EXPANDED,
DATE_RFC822 === DateTime::RFC822,
DATE_RFC850 === DateTime::RFC850,
DATE_RFC1036 === DateTime::RFC1036,
DATE_RFC1123 === DateTime::RFC1123,
DATE_RFC7231 === DateTime::RFC7231,
DATE_RFC2822 === DateTime::RFC2822,
DATE_RFC3339 === DateTime::RFC3339,
DATE_RFC3339_EXTENDED === DateTime::RFC3339_EXTENDED,
DATE_RSS === DateTime::RSS,
DATE_W3C === DateTime::W3C
);
?>
@@ -30,3 +33,6 @@ bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)

View File

@@ -5,32 +5,38 @@ Test date_format() function : basic functionality
//Set the default time zone
date_default_timezone_set("Europe/London");
echo "*** Testing date_format() : basic functionality - formatting coinstants ***\n";
echo "*** Testing date_format() : basic functionality - formatting constants ***\n";
$date = new DateTime("2005-07-14 22:30:41");
var_dump( $date->format( DateTime::ATOM) ) ;
var_dump( $date->format( DateTime::COOKIE) ) ;
var_dump( $date->format( DateTime::ISO8601) ) ;
var_dump( $date->format( DateTime::ISO8601_EXPANDED) ) ;
var_dump( $date->format( DateTime::RFC822) ) ;
var_dump( $date->format( DateTime::RFC850) ) ;
var_dump( $date->format( DateTime::RFC1036) ) ;
var_dump( $date->format( DateTime::RFC1123) ) ;
var_dump( $date->format( DateTime:: RFC2822) ) ;
var_dump( $date->format( DateTime::RFC7231) ) ;
var_dump( $date->format( DateTime::RFC2822) ) ;
var_dump( $date->format( DateTime::RFC3339) ) ;
var_dump( $date->format( DateTime::RFC3339_EXTENDED) ) ;
var_dump( $date->format( DateTime::RSS) ) ;
var_dump( $date->format( DateTime::W3C) ) ;
?>
--EXPECT--
*** Testing date_format() : basic functionality - formatting coinstants ***
*** Testing date_format() : basic functionality - formatting constants ***
string(25) "2005-07-14T22:30:41+01:00"
string(34) "Thursday, 14-Jul-2005 22:30:41 BST"
string(24) "2005-07-14T22:30:41+0100"
string(26) "+2005-07-14T22:30:41+01:00"
string(29) "Thu, 14 Jul 05 22:30:41 +0100"
string(32) "Thursday, 14-Jul-05 22:30:41 BST"
string(29) "Thu, 14 Jul 05 22:30:41 +0100"
string(31) "Thu, 14 Jul 2005 22:30:41 +0100"
string(29) "Thu, 14 Jul 2005 22:30:41 GMT"
string(31) "Thu, 14 Jul 2005 22:30:41 +0100"
string(25) "2005-07-14T22:30:41+01:00"
string(29) "2005-07-14T22:30:41.000+01:00"
string(31) "Thu, 14 Jul 2005 22:30:41 +0100"
string(25) "2005-07-14T22:30:41+01:00"

View File

@@ -7,12 +7,15 @@ Date constants
DATE_ATOM,
DATE_COOKIE,
DATE_ISO8601,
DATE_ISO8601_EXPANDED,
DATE_RFC822,
DATE_RFC850,
DATE_RFC1036,
DATE_RFC1123,
DATE_RFC7231,
DATE_RFC2822,
DATE_RFC3339,
DATE_RFC3339_EXTENDED,
DATE_RSS,
DATE_W3C
);
@@ -25,17 +28,20 @@ Date constants
print "\n";
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
DATE_ATOM == DateTime::ATOM,
DATE_COOKIE == DateTime::COOKIE,
DATE_ISO8601 == DateTime::ISO8601,
DATE_ISO8601_EXPANDED == DateTime::ISO8601_EXPANDED,
DATE_RFC822 == DateTime::RFC822,
DATE_RFC850 == DateTime::RFC850,
DATE_RFC1036 == DateTime::RFC1036,
DATE_RFC1123 == DateTime::RFC1123,
DATE_RFC2822 == DateTime::RFC2822,
DATE_RFC7231 == DateTime::RFC7231,
DATE_RFC3339 == DateTime::RFC3339,
DATE_RFC3339_EXTENDED == DateTime::RFC3339_EXTENDED,
DATE_RSS == DateTime::RSS,
DATE_W3C == DateTime::W3C
);
?>
--EXPECT--
@@ -45,6 +51,8 @@ string(35) "Saturday, 01-Jul-2006 14:27:30 CEST"
string(34) "Tuesday, 30-May-2006 14:32:13 CEST"
string(24) "2006-07-01T14:27:30+0200"
string(24) "2006-05-30T14:32:13+0200"
string(26) "+2006-07-01T14:27:30+02:00"
string(26) "+2006-05-30T14:32:13+02:00"
string(29) "Sat, 01 Jul 06 14:27:30 +0200"
string(29) "Tue, 30 May 06 14:32:13 +0200"
string(33) "Saturday, 01-Jul-06 14:27:30 CEST"
@@ -53,10 +61,14 @@ string(29) "Sat, 01 Jul 06 14:27:30 +0200"
string(29) "Tue, 30 May 06 14:32:13 +0200"
string(31) "Sat, 01 Jul 2006 14:27:30 +0200"
string(31) "Tue, 30 May 2006 14:32:13 +0200"
string(29) "Sat, 01 Jul 2006 14:27:30 GMT"
string(29) "Tue, 30 May 2006 14:32:13 GMT"
string(31) "Sat, 01 Jul 2006 14:27:30 +0200"
string(31) "Tue, 30 May 2006 14:32:13 +0200"
string(25) "2006-07-01T14:27:30+02:00"
string(25) "2006-05-30T14:32:13+02:00"
string(29) "2006-07-01T14:27:30.000+02:00"
string(29) "2006-05-30T14:32:13.000+02:00"
string(31) "Sat, 01 Jul 2006 14:27:30 +0200"
string(31) "Tue, 30 May 2006 14:32:13 +0200"
string(25) "2006-07-01T14:27:30+02:00"
@@ -73,3 +85,6 @@ bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)

View File

@@ -10,12 +10,14 @@ $constants = array(
'DATE_ATOM',
'DATE_COOKIE',
'DATE_ISO8601',
'DATE_ISO8601_EXPANDED',
'DATE_RFC822',
'DATE_RFC850',
'DATE_RFC1036',
'DATE_RFC1123',
'DATE_RFC2822',
'DATE_RFC3339',
'DATE_RFC3339_EXTENDED',
'DATE_RSS',
'DATE_W3C'
);
@@ -30,11 +32,13 @@ foreach ($constants as $const) {
DATE_ATOM: OK
DATE_COOKIE: OK
DATE_ISO8601: OK
DATE_ISO8601_EXPANDED: OK
DATE_RFC822: OK
DATE_RFC850: OK
DATE_RFC1036: OK
DATE_RFC1123: OK
DATE_RFC2822: OK
DATE_RFC3339: OK
DATE_RFC3339_EXTENDED: OK
DATE_RSS: OK
DATE_W3C: OK

View File

@@ -3,8 +3,8 @@ date_create_from_format() and date_parse_from_format().
--FILE--
<?php
date_default_timezone_set('Europe/Oslo');
$formats = array( DATE_ATOM, DATE_COOKIE, DATE_ISO8601, DATE_RFC822,
DATE_RFC850, DATE_RFC1036, DATE_RFC1123, DATE_RFC2822, DATE_RFC3339,
$formats = array( DATE_ATOM, DATE_COOKIE, DATE_ISO8601, DATE_ISO8601_EXPANDED, DATE_RFC822,
DATE_RFC850, DATE_RFC1036, DATE_RFC1123, DATE_RFC2822, DATE_RFC3339, DATE_RFC3339_EXTENDED,
DATE_RSS, DATE_W3C );
foreach( $formats as $format )
@@ -54,9 +54,20 @@ object(DateTime)#3 (3) {
string(6) "+02:00"
}
string(13) "X-m-d\TH:i:sP"
string(26) "+2008-07-08T22:14:12+02:00"
object(DateTime)#2 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+02:00"
}
string(16) "D, d M y H:i:s O"
string(29) "Tue, 08 Jul 08 22:14:12 +0200"
object(DateTime)#2 (3) {
object(DateTime)#1 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
["timezone_type"]=>
@@ -67,7 +78,7 @@ object(DateTime)#2 (3) {
string(16) "l, d-M-y H:i:s T"
string(36) "Tuesday, 08-Jul-08 22:14:12 GMT+0200"
object(DateTime)#1 (3) {
object(DateTime)#3 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
["timezone_type"]=>
@@ -78,17 +89,6 @@ object(DateTime)#1 (3) {
string(16) "D, d M y H:i:s O"
string(29) "Tue, 08 Jul 08 22:14:12 +0200"
object(DateTime)#3 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+02:00"
}
string(16) "D, d M Y H:i:s O"
string(31) "Tue, 08 Jul 2008 22:14:12 +0200"
object(DateTime)#2 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
@@ -109,9 +109,31 @@ object(DateTime)#1 (3) {
string(6) "+02:00"
}
string(16) "D, d M Y H:i:s O"
string(31) "Tue, 08 Jul 2008 22:14:12 +0200"
object(DateTime)#3 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+02:00"
}
string(13) "Y-m-d\TH:i:sP"
string(25) "2008-07-08T22:14:12+02:00"
object(DateTime)#3 (3) {
object(DateTime)#2 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
["timezone_type"]=>
int(1)
["timezone"]=>
string(6) "+02:00"
}
string(15) "Y-m-d\TH:i:s.vP"
string(29) "2008-07-08T22:14:12.000+02:00"
object(DateTime)#1 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
["timezone_type"]=>
@@ -122,7 +144,7 @@ object(DateTime)#3 (3) {
string(16) "D, d M Y H:i:s O"
string(31) "Tue, 08 Jul 2008 22:14:12 +0200"
object(DateTime)#2 (3) {
object(DateTime)#3 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
["timezone_type"]=>
@@ -133,7 +155,7 @@ object(DateTime)#2 (3) {
string(13) "Y-m-d\TH:i:sP"
string(25) "2008-07-08T22:14:12+02:00"
object(DateTime)#1 (3) {
object(DateTime)#2 (3) {
["date"]=>
string(26) "2008-07-08 22:14:12.000000"
["timezone_type"]=>