|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29205 NaN in php_sunrise_sunset()
Submitted: 2004-07-16 11:54 UTC Modified: 2005-03-18 01:00 UTC
From: bjdouma at xs4all dot nl Assigned: momo (profile)
Status: No Feedback Package: Date/time related
PHP Version: 5.0.0 OS: Linux 2.6.7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: bjdouma at xs4all dot nl
New email:
PHP Version: OS:


 [2004-07-16 11:54 UTC] bjdouma at xs4all dot nl
Good morning,

Re. php-5.0.0   

I noticed in sunfuncs.c/php_sunrise_sunset() there's this commented out snippet:

  /* XXX: What's the use of this block.. ?
   * if (!calc_sunset && cosH > 1 || calc_sunset && cosH < -1) {
   *    throw doesnthappen(); 
   * }

What the 'if' clause actually would detect is cases where you have no sunrise or sunset, i.e. during the midnight sun period, on the Northern hemisphere around June 21st, above ca. 66.5 deg latitude.        

For instance, try:

        php_sunrise_sunset( 182, 66, 0, 90.83, 0 );

this should give a good value for sunrise, very early in the morning.

Now try
        php_sunrise_sunset( 182, 67, 0, 90.83, 0 );

this should give NaN.

The reason is obvious: above ca. 66.56 deg latitude in the summer (here day 182) you have the midnight sun period: the sun doesn't set and/or rise.

However, this function isn't used anywhere -- is it?



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-21 08:33 UTC]
date_sunrise(gmmktime(1,1,1,7,21,2004),SUNFUNCS_RET_STRING, 67, 0, 90.83);

returns 03:42 but yes i need to activate the check.
 [2005-03-06 20:48 UTC]
Please try using this CVS snapshot:
For Windows:

 [2005-03-18 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Aug 01 19:01:24 2021 UTC