Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getZemanim is returning values for previous day #23

Closed
nassan opened this issue May 3, 2016 · 6 comments
Closed

getZemanim is returning values for previous day #23

nassan opened this issue May 3, 2016 · 6 comments

Comments

@nassan
Copy link

nassan commented May 3, 2016

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?

@Scimonster
Copy link
Contributor

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
#23

@nassan
Copy link
Author

nassan commented May 5, 2016

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?

@nassan
Copy link
Author

nassan commented Jun 7, 2016

What can we do about this bug?

@dannycohn
Copy link

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.

@ybudweiser
Copy link
Contributor

Issue seems to be caused by suncalc js dependency. Issue is described here mourner/suncalc#11

Scimonster added a commit that referenced this issue May 17, 2017
fixed previous date issue with suncalc workaround
closes issue #23
@Scimonster
Copy link
Contributor

This has been fixed. Thanks @ybudweiser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants