Bug #69205 [Nab]: DateTime for December 31st fails once every 400 years

From: Date: Thu, 08 Apr 2021 07:53:08 +0000
Subject: Bug #69205 [Nab]: DateTime for December 31st fails once every 400 years
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233308@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69205&edit=1

 ID:                 69205
 User updated by:    nd dot wortel at gmail dot com
 Reported by:        nd dot wortel at gmail dot com
 Summary:            DateTime for December 31st fails once every 400
                     years
 Status:             Not a bug
 Type:               Bug
 Package:            Date/time related
-Operating System:   Ubuntu 14.04
+Operating System:   Ubuntu 20.04
-PHP Version:        5.5.22
+PHP Version:        8.0.3
 Assigned To:        derick
 Block user comment: N
 Private report:     N

 New Comment:

Please have a look at https://3v4l.org/fliGH. It seems like
2369-12-31 has been fixed with PHP 7.2.0, but 2769-12-31, 3169-12-31, etc. are still affected.


Previous Comments:
------------------------------------------------------------------------
[2021-04-05 16:04:21] derick@php.net

Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP --
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

This got fixed in PHP 7.2 already.

------------------------------------------------------------------------
[2020-09-02 18:20:31] kevin at arcpointgroup dot com

This appears to be an incorrect implementation of the Gregorian calendar system. Note that years
divisible by 100 are not leap years, but those divisible by 400 are leap years in the Gregorian
calendar.

Running some spot checks on this bug reveals a pattern:

- Years that round up to a value evenly divisible by 400 present this issue.
- Years that round up to a value not evenly divisibly by 400 do not.

Examples:

- 2769 rounds to 2800 (a leap year) and presents the bug.
- 2869 rounds to 2900 (non leap year) and does not present the bug.

- 3169 rounds to 3200 (a leap year) and presents the bug.
- 3269 rounds to 3300 (non leap year) and does not present the bug.

- 3569 rounds to 3600 (a leap year) and presents the bug.
- 3669 rounds to 3700 (non leap year) and does not present the bug.

...

------------------------------------------------------------------------
[2019-05-11 23:44:17] cmb@php.net

You're right.  Thanks!

------------------------------------------------------------------------
[2019-05-11 13:31:11] nic at nicwortel dot nl

No, this is still an issue in PHP 7.2+: https://3v4l.org/pj2EK

------------------------------------------------------------------------
[2019-05-11 11:10:00] cmb@php.net

Indeed, still good for all actively supported versions[1].

<https://www.php.net/supported-versions.php>

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=69205


--
Edit this bug report at https://bugs.php.net/bug.php?id=69205&edit=1


Thread (11 messages)

« previous php.bugs (#233308) next »