Req #71520 [Opn->Fbk]: Adding the DateTime constants to the DateTimeInterface interface

From: Date: Thu, 04 Feb 2016 09:33:40 +0000
Subject: Req #71520 [Opn->Fbk]: Adding the DateTime constants to the DateTimeInterface interface
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199049@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71520&edit=1 ID: 71520 Updated by: requinix@php.net Reported by: nyamsprod at gmail dot com Summary: Adding the DateTime constants to the DateTimeInterface interface -Status: Open +Status: Feedback Type: Feature/Change Request Package: Date/time related Operating System: Irrelevant PHP Version: Irrelevant Block user comment: N Private report: N New Comment: They aren't missing. The constants are on the DateTime class. Why should they be copied onto DateTimeImmutable? What's wrong with keeping them on DateTime? Previous Comments: ------------------------------------------------------------------------ [2016-02-04 09:25:51] nyamsprod at gmail dot com Description: ------------ Currently it's not possible to access DateTime constants directly from DateTimeImmutable. Test script: --------------- $datetime = new DateTimeImmutable('2000-01-01 00:00:00', new DateTimeZone('Africa/Kinshasa')); var_dump($datetime->format(DateTimeImmutable::ATOM)); var_dump($datetime->format(DateTimeImmutable::COOKIE)); var_dump($datetime->format(DateTimeImmutable::ISO8601)); var_dump($datetime->format(DateTimeImmutable::RFC822)); var_dump($datetime->format(DateTimeImmutable::RFC850)); var_dump($datetime->format(DateTimeImmutable::RFC1036)); var_dump($datetime->format(DateTimeImmutable::RFC2822)); var_dump($datetime->format(DateTimeImmutable::RFC3339)); var_dump($datetime->format(DateTimeImmutable::RSS)); var_dump($datetime->format(DateTimeImmutable::W3C)); Expected result: ---------------- string(25) "2000-01-01T00:00:00+01:00" string(34) "Saturday, 01-Jan-2000 00:00:00 WAT" string(24) "2000-01-01T00:00:00+0100" string(29) "Sat, 01 Jan 00 00:00:00 +0100" string(32) "Saturday, 01-Jan-00 00:00:00 WAT" string(29) "Sat, 01 Jan 00 00:00:00 +0100" string(31) "Sat, 01 Jan 2000 00:00:00 +0100" string(25) "2000-01-01T00:00:00+01:00" string(31) "Sat, 01 Jan 2000 00:00:00 +0100" string(25) "2000-01-01T00:00:00+01:00" Actual result: -------------- The following constant are missing on the DateTimeInterface interface DateTimeInterface::ATOM, DateTimeInterface::COOKIE, DateTimeInterface::ISO8601, DateTimeInterface::RFC822, DateTimeInterface::RFC850, DateTimeInterface::RFC1036, DateTimeInterface::RFC2822, DateTimeInterface::RFC3339, DateTimeInterface::RSS, DateTimeInterface::W3C ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71520&edit=1

« previous php.bugs (#199049) next »