|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-03-18 22:49 UTC] reidw at rawsound dot com
[2008-03-19 00:56 UTC] reidw at rawsound dot com
[2008-03-28 21:34 UTC] reidw at rawsound dot com
[2009-04-25 14:08 UTC] jani@php.net
[2009-05-03 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 09:00:01 2025 UTC |
Description: ------------ The function gregroiantojd() returns the wrong value. This was also tested with PHP 5.2.2 on Linux FC3 and PHP 5.1.2 on Windows Server 2003 with the same results. Results are off by one day for positive years, and further off for zero and negative years. By definition, when using negative years rather than a suffix the pattern should be: ..., -2, -1, 0, 1, 2, ... . Year 2 corresponds to 2AD, year 1 corresponds to 1AD, year 0 corresponds to 1BC, and year -1 corresponds to 2BC, etc. Information can be found from the links in the PHP manual. Code for comparison is taken from those links and given below. Reproduce code: --------------- built-in: echo gregoriantojd(3,16,1)."\n"; echo gregoriantojd(3,16,0)."\n"; echo gregoriantojd(3,16,-1); reproduced from PHP manual links: echo GtoJD(3,16,1)."\n"; echo GtoJD(3,16,0)."\n"; echo GtoJD(3,16,-1); function GtoJD($m,$d,$y) { return (int) (((int) ( 1461 * ( $y + 4800 + ($m-14) / 12 ) ) / 4) + ((int) ( 367 * ( $m - 2 - 12 * ( ($m-14) / 12 ) ) ) / 12) - ((int) ( 3 * (int)( ( $y + 4900 + ($m-14) / 12 ) / 100 ) ) / 4) + $d - 32075); } Expected result: ---------------- The expected results are (from the reproduced code): 1721501 1721137 1720771 Actual result: -------------- Actual results (from the built-in gregoriantojd()): 1721500 0 1721135