Bug #68367 [NEW]: Before 1915 datetime->diff works wrong

From: Date: Thu, 06 Nov 2014 17:51:09 +0000
Subject: Bug #68367 [NEW]: Before 1915 datetime->diff works wrong
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188489@lists.php.net to get a copy of this message
From:             xguiga at gmail dot com
Operating system: OSX Maveriks and Ubuntu 14.10
PHP version:      5.5.18
Package:          Date/time related
Bug Type:         Bug
Bug description:Before 1915 datetime->diff works wrong

Description:
------------
I tried make an diff in 1899-01-01 and 1970-01-01 and don't return only
year difference, return months, days, hours, minutes and seconds.
I made some tests, and date before 1915 this happend.

Test script:
---------------
var_dump((new \DateTime('1912-01-01'))->diff(new
\DateTime('1915-01-01')));

Expected result:
----------------
object(DateInterval)[2405]
  public 'y' => int 3
  public 'm' => int 0
  public 'd' => int 0
  public 'h' => int 0
  public 'i' => int 0
  public 's' => int 0
  public 'weekday' => int 0
  public 'weekday_behavior' => int 0
  public 'first_last_day_of' => int 0
  public 'invert' => int 0
  public 'days' => int 1095
  public 'special_type' => int 0
  public 'special_amount' => int 0
  public 'have_weekday_relative' => int 0
  public 'have_special_relative' => int 0


Actual result:
--------------
object(DateInterval)[2405]
  public 'y' => int 2
  public 'm' => int 11
  public 'd' => int 30
  public 'h' => int 23
  public 'i' => int 53
  public 's' => int 32
  public 'weekday' => int 0
  public 'weekday_behavior' => int 0
  public 'first_last_day_of' => int 0
  public 'invert' => int 0
  public 'days' => int 1095
  public 'special_type' => int 0
  public 'special_amount' => int 0
  public 'have_weekday_relative' => int 0
  public 'have_special_relative' => int 0

-- 
Edit bug report at https://bugs.php.net/bug.php?id=68367&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=68367&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=68367&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=68367&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=68367&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=68367&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=68367&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=68367&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=68367&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=68367&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=68367&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=68367&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=68367&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=68367&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68367&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=68367&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=68367&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=68367&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68367&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=68367&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=68367&r=mysqlcfg



Thread (5 messages)

« previous php.bugs (#188489) next »