php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #75064 There is no clear description of function jdtogregorian
Submitted: 2017-08-11 14:51 UTC Modified: 2017-08-13 00:45 UTC
From: daniel at ohr dot edu Assigned:
Status: Verified Package: Calendar related
PHP Version: 7.2.0beta2 OS: Mac OS X Sierra
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-08-11 14:51 UTC] daniel at ohr dot edu
Description:
------------
---
From manual page: http://www.php.net/function.jdtogregorian
---

jdgregorian works but it is not clear how dates are handled

JD 1099114
Returns 3/3/-1704 
which would be interpreted as 3 Mar 1704 B.C.E. Gregorian (0:00 am)
Meeus converts and gets MEU: 3/18/-1703 - i.e. 18 Mar 1703 B.C.E

1721425 returns 12/31/-1 
1721426 returns 1/1/1

which shows that there is no year 0
Meeus includes year 0 for astronomers

There needs to be clearer documentation about what formula is being used, and what is the starting point for the conversion (25 Nov -4712 Gregorian, JD 1)

Because at the moment JD 1 = 25 Nov -4714 which is not correct according to Meeus.




Test script:
---------------
function jd_to_greg_meeus($J) { 
     $Z = intval($J+0.5); 
     $F = ($J+0.5)-$Z;
   if ($Z < 2299161) {$A = $Z;}
   if ($Z >= 2299161) {
   		$alpha = floor(($Z-1867216.25)/36524.25);
  		 $A = $Z + 1 + $alpha - floor($alpha/4); }
         $B = $A + 1524;
         $C = floor( ($B-122.1)/365.25);
         $D = floor( 365.25*$C );
         $E = floor( ($B-$D)/30.6001 ); 
     $day = floor($B - $D - floor(30.6001*$E)); 
if ($E < 13.5) {   $month = $E - 1;}
if ($E > 13.5) {   $month = $E - 13;}
if ($month > 2.5) {  $year = $C - 4716; }
if ($month < 2.5) {  $year = $C - 4715; }
   return "$month/$day/$year"; 
} 



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-08-11 15:47 UTC] requinix@php.net
-Status: Open +Status: Verified -Package: Documentation problem +Package: *Calendar problems
 [2017-08-11 15:47 UTC] requinix@php.net
jdtogregorian uses the proleptic Gregorian calendar. JD 0 was Nov 24.

1099114 ≈ 365.2425 * 3009 + 100 ≈ 1099014 + 100
therefore JD 1099114 = Nov 23 -1705 + 100 days = Mar 3 -1704

You can see the code in ext/calendar/gregor.c.

Elsewhere I've said that the docs for most jd* functions looked fine. Maybe that's not the case. Even though the introduction
  http://php.net/manual/en/intro.calendar.php
gives a couple links, perhaps a short note/lnik with each of the Julian day functions is in order too.
 [2017-08-13 00:45 UTC] cmb@php.net
-Type: Bug +Type: Documentation Problem -Package: *Calendar problems +Package: Calendar related
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC