[prev in list] [next in list] [prev in thread] [next in thread]
List: php-doc-bugs
Subject: [DOC-BUGS] Bug #64908 [Nab->Asn]: DateTime's constructor accepts time that not exists because of DST
From: aharvey () php ! net
Date: 2013-05-23 18:31:26
Message-ID: E1UfaIQ-0000f0-BH () sgrv2 ! php ! net
[Download RAW message or body]
Edit report at https://bugs.php.net/bug.php?id=64908&edit=1
ID: 64908
Updated by: aharvey@php.net
Reported by: istvan dot dani at gmail dot com
Summary: DateTime's constructor accepts time that not exists
because of DST
-Status: Not a bug
+Status: Assigned
Type: Bug
Package: Documentation problem
Operating System: OS X 10.8
PHP Version: Irrelevant
-Assigned To:
+Assigned To: aharvey
Block user comment: N
Private report: N
New Comment:
Reopening.
Previous Comments:
------------------------------------------------------------------------
[2013-05-23 18:29:41] derick@php.net
That's wrong, it should say "invalid date *format*". Marking this as a doc issue.
------------------------------------------------------------------------
[2013-05-23 18:17:46] istvan dot dani at gmail dot com
Yep. Manual at http://hu1.php.net/manual/en/datetime.construct.php says:
"If an invalid date is specified, then an exception is now thrown. Previously an
error was emitted."
------------------------------------------------------------------------
[2013-05-23 17:22:23] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php
PHP's date time handling auto-corrects wrong date/time values. This is similar to doing:
<?php
$n = new DateTime("2013-04-31");
var_dump( $n );
?>
class DateTime#1 (3) {
public $date =>
string(19) "2013-05-01 00:00:00"
public $timezone_type =>
int(3)
public $timezone =>
string(13) "Europe/London"
}
------------------------------------------------------------------------
[2013-05-23 08:30:06] istvan dot dani at gmail dot com
Description:
------------
Europe/Budapest timezone offset is +1, and +2 in DST.
Transition to DST is at 2013-03-31 01:00:00 UTC/GMT.
According to this, locale time should not exists between 02:00:00 and 03:00:00,
and must not be accepted as valid time.
Test script:
---------------
try {
$wrong_date = new DateTime("2013-03-31 02:30:00", new DateTimeZone("Europe/Budapest"));
} catch (Exception $e) {
echo $e->getMessage();
}
print "Wrong date in local timezone: " . $wrong_date->format("Y-m-d H:i:s");
$wrong_date->setTimezone(new DateTimeZone("UTC"));
print "<br />Converting to UTC: " . $wrong_date->format("Y-m-d H:i:s");
$wrong_date->setTimezone(new DateTimeZone("Europe/Budapest"));
print "<br />Converting back to locale timezone: " . $wrong_date->format("Y-m-d H:i:s");
Expected result:
----------------
Get an exception.
Actual result:
--------------
Wrong date in local timezone: 2013-03-31 02:30:00
Converting to UTC: 2013-03-31 01:30:00
Converting back to locale timezone: 2013-03-31 03:30:00
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64908&edit=1
--
PHP Documentation Bugs Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic