Patch for Bug in SRFI-19 reference implementation: date->julian-day
Jon Wilson 28 Jun 2007 14:58 UTC
Hi,
I discovered a bug in the SRFI-19 reference implementation. The
procedure date->julian-day uses the timezone offset, but incorrectly.
The existing code winds up looking like (LaTeX math):
jdn - 1/2 + \frac{ \frac{H*60*60 + M*60 + s + ns/nano}{sid} }{-
offset}
Where as you can see, we are dividing the number of seconds from the
beginning of the day by the offset. Since the offset can be zero,
it is obvious that this is no good! Instead we should have:
jdn - 1/2 + \frac{ -offset + H*60*60 + M*60 + s + ns/nano}{sid}
Since the offset is in seconds, we do want to divide it by the number
of seconds in a day (sid). My patch is below.
Regards,
Jon Wilson
821,823c821,822
< (+ (/ (/ (+ (* hour 60 60)
< (* minute 60) second (/ nanosecond tm:nano)) tm:sid)
< (- offset))))))
---
> (+ (/ (+ (- offset) (* hour 60 60)
> (* minute 60) second (/ nanosecond tm:nano)) tm:sid)))))