ID:               49558
 Comment by:       colin at viebrock dot ca
 Reported By:      eclipsechasers2 at yahoo dot com
 Status:           Open
 Bug Type:         Date/time related
 Operating System: *
 PHP Version:      5.2.10
 New Comment:

The comments from the sun.c file are also in PHP's ext/date/lib/astro.c

(around line 187).

>From my reading of things, this upper-limb value should be pegged at 1

in php_date.c

Which, of course, means that most systems have been generating 
sunrise/set times that are off by about 26 seconds.  Think of all the 
angry emails you're gonna get from The Weather Network!


Previous Comments:
------------------------------------------------------------------------

[2009-09-15 18:11:10] kr dot shaishav at gmail dot com

This is from the original sun.c file
Written as DAYLEN.C, 1989-08-16
Modified to SUNRISET.C, 1992-12-01
(c) Paul Schlyter, 1989, 1992
Released to the public domain by Paul Schlyter, December 1992
Portions Modified to SUNDOWN.NLM by Cliff Haas 98-05-22

the comment states
/*         upper_limb: non-zero -> upper limb, zero -> center       */
/*               Set to non-zero (e.g. 1) when computing rise/set   */
/*               times, and to zero when computing start/end of     */
/*               twilight.                                          */

Therefore, if we are calculating sunrise-sunset time the value of
upper_limb will be set to permanently non zero.
If twilight time is needed then it has to be 0.


(PS - just for clearing what this upper limb is. Sunrise happens when
the sun's centre is visible. But for the twilight to occur, the sun's
top should come over the horizon. that means,centre angle - sradius:)

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

[2009-09-15 17:43:04] ras...@php.net

Hardcoding that upper_limit to correction flag to either 0 or 1 does
remove the quirk in the series.  So, is it correct that for the sunrise
function we should just peg it at 1?

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

[2009-09-15 17:39:59] kr dot shaishav at gmail dot com

i think the bug is being caused by this 
altitude > -1 ? 1:0 ,line 3930 in php_date.c. 
becoz of this upper_limb correction is being applied here....
if (upper_limb) {altit -= sradius;} line 253, astro.c 

the series gets advanced because of the altit-=sradius;. 
and hence the anamoly. i dont knw if its a bug. don't know about the
upper limb correction and why is it being selectively beyond -1 applied.
but the bug can be removed if we remove the uppr_limb if code. or add it
without an if. and if the correction is correctly applied, then i guess
thats the way it is.not a bug.

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

[2009-09-15 17:21:46] colin at viebrock dot ca

TYPO IN LAST COMMENT - SHOULD READ:

Altitude is 90-zenith, so when you are below 91, the code sets that 
param to 0 ... which I think means it calculates the twilight 
time instead of sunrise/set.  I would say this param should always be 1

if you are calculating sunrise/set (see note on line 187 of 
ext/date/lib/astro.c).

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

[2009-09-15 17:18:18] colin at viebrock dot ca

I'd say that all the times from 91 degrees onward are off.  Graphing
the 
data shows it "jumps" at that point, but is smooth before and after.

Could it be some error related to line 3930 in ext/date/php_date.c

rs = timelib_astro_rise_set_altitude(t, longitude, latitude, altitude,

altitude > -1 ? 1 : 0, &h_rise, &h_set, &rise, &set, &transit);

Altitude is 90-zenith, so when you get to 91, the code would set that 
param from 0 to 1 ... which I think means it calculates the twilight 
time instead of sunrise/set.  I would say this param should always be
1, 
if you are calculating sunrise/set (see note on line 187 of 
ext/date/lib/astro.c).

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

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
    http://bugs.php.net/49558

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

Reply via email to