Closed nassan closed 7 years ago
This would appear to be a bug.
~Sci
On Tue, May 3, 2016 at 4:39 PM, nassan notifications@github.com wrote:
I have the following code: var hdate = Hebcal.HDate().setLocation(31.783, 35.233); console.log(hdate.sunrise());
It gives me Mon May 02 2016 05:53:36 GMT+0300 (שעון קיץ ירושלים) which is in fact yesterday.
To support my argument that it is yesterday, I can run new Date(); and it gives me Tue May 03 2016 16:35:05 GMT+0300 (שעון קיץ ירושלים)
It does,however, give me the correct Hebrew date for today, Tue May 3: HDate {month: 1, day: 25, year: 5776, lat: 31.783, long: 35.233…}
Anyone can explain to me what I am missing? Is this a bug?
— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/hebcal/hebcal-js/issues/23
I see the bug being introduced in the fromJulian
function:
function fromJulian(j) { return new Date((j + 0.5 - J1970) * dayMs); }
This is the first time I see the 1 day old date introduced. The date getting passed to SunCalc.getTimes
is the correct date. The math done inside this function, I don't fully follow, but after the math, SunCalc.getTimes
calls the fromJulian
function mentioned above, putting it back into a Date
object, and at that point you can observe it is a day early.
Any suggestions?
What can we do about this bug?
I just found Hebcal JS and rather immediately found the same bug. For my purposes, it seems easy enough to just use hebcal.find('tomorrow') for my needs, but yes, this seems to be a real issue. Any updates on this would be greatly appreciated.
Issue seems to be caused by suncalc js dependency. Issue is described here https://github.com/mourner/suncalc/issues/11
This has been fixed. Thanks @ybudweiser.
I have the following code:
var hdate = Hebcal.HDate().setLocation(31.783, 35.233);
console.log(hdate.sunrise());
It gives me
Mon May 02 2016 05:53:36 GMT+0300 (שעון קיץ ירושלים)
which is in fact yesterday.To support my argument that it is yesterday, I can run
new Date();
and it gives meTue May 03 2016 16:35:05 GMT+0300 (שעון קיץ ירושלים)
It does,however, give me the correct Hebrew date for today, Tue May 3:
HDate {month: 1, day: 25, year: 5776, lat: 31.783, long: 35.233…}
Anyone can explain to me what I am missing? Is this a bug?