Bug #70335 [NEW]: DateTime doesn't take into account leap seconsa
| From: | teo8976 at gmail dot com | Date: | Sun, 23 Aug 2015 16:15:55 +0000 |
| Subject: | Bug #70335 [NEW]: DateTime doesn't take into account leap seconsa | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-195445@lists.php.net to get a copy of this message | ||
From: teo8976 at gmail dot com
Operating system:
PHP version: 7.0.0RC1
Package: Date/time related
Bug Type: Bug
Bug description:DateTime doesn't take into account leap seconsa
Description:
------------
https://en.wikipedia.org/wiki/Leap_second#Insertion_of_leap_seconds
Test script:
---------------
https://3v4l.org/DL88F
<?php
$date=date_create("Jun 30 2015 23:59:59", new DateTimeZone("UTC"));
print_r($date);
print_r($date->getTimeStamp());
echo "\n";
$date= $date->add(new DateInterval("PT1S"));
print_r($date);
print_r($date->getTimeStamp());
$date2=date_create("now", new DateTimeZone("UTC"));
$date2->setTimeStamp("1435708799");
print_r($date2);
$date2->setTimeStamp("1435708801");
print_r($date2);
Expected result:
----------------
Adding one second to jun 30 2015 23:59:59 UTC should yield jun 30 2015
23:59:60 UTC because of the leap second. Same for 2012 (and a few more
years).
If the timestamp 1435708799 corresponds to jun 30 2015 23:59:59, which
it shouldn't because it is calculated without taking into account the 25
leap seconds occurred since the beginning of the Unix Epoch until that
date, but if it was, then 1435708800 should correspond to jun 30 2015
23:59:60 and 1435708801 should be jul 1 2015 00:00:00
Actual result:
--------------
Leap seconds are not taken into account, as if they didn't exist. No
23:59:60 time exists for the days where it should, and the conversion
between timestamps and UTC is therefore offset of a few seconds
depending on the date, up to 26 seconds today.
--
Edit bug report at https://bugs.php.net/bug.php?id=70335&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70335&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70335&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70335&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70335&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70335&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70335&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70335&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70335&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70335&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70335&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70335&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70335&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70335&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70335&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70335&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70335&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70335&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70335&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70335&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70335&r=mysqlcfg