-
Notifications
You must be signed in to change notification settings - Fork 14
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
JS doesn't produce the same results as Java #8
Comments
P.S. I'd love to get involved in solving this issue. I just first wanted to know if you were aware of it. |
There were several bugs in the last version. Please try again with v0.6.0 and let me know if there is still an issue. As far as we know, MyZmanim uses their own proprietary calculations, and does not use KosherJava or any of its ports. The author of KosherJava frequently gets complaints that his calculations are different than MyZmanim. |
Amazing! Both libraries now produce the exact same result, down to the millisecond! I used the Java zmanim project directly this time so I could get an exact comparison. This is what I got from Java: ComplexZmanimCalendar cal = new ComplexZmanimCalendar(
new GeoLocation(
"Hasmonaim",
31.93263,
35.02327,
255.18,
TimeZone.getTimeZone("Asia/Jerusalem"))
);
cal.getCalendar().set(2020, Calendar.APRIL, 10);
System.out.println(cal.getCandleLighting().getTime()); // 1586533670912 (Fri Apr 10 2020 18:47:50) And the JS using the updated kosher-zmanim: const { ComplexZmanimCalendar, GeoLocation } = require("kosher-zmanim");
const cal = new ComplexZmanimCalendar(
new GeoLocation("Hashmonaim", 31.93263, 35.02327, 255.18, "Asia/Jerusalem")
);
cal.setDate("2020-04-10");
console.log(cal.getCandleLighting().toJSDate().getTime()); // 1586533670912 (Fri Apr 10 2020 18:47:50) Awesome stuff 👍 |
I'd like to start off by saying that I am a huge fan of this port. In my opinion it's miles ahead of anything else out there for JS. Even though the README states this project is in alpha stage, I've found it to be quite complete and reliable.
With that out of the way, something I just realized is that the results of lib seem to be a few seconds off from what the Java library produces. To illustrate this:
I used the Zmanim Calendar Generator to generate zmanim for my location (Hashmonaim) and used this as a reference for the Java results.
Taking a look at candle lighting for 2020-04-10:
![zmanim-excel](https://user-images.githubusercontent.com/17168026/79053904-8429a500-7c49-11ea-9b29-6790036fa506.png)
This matches up exactly with MyZmanim.com. I even compared several zmanim and different days. The largest discrepancy I found was 1 second (!). I'm pretty convinced MyZmanim uses the Java zmanim project.
However, when I try to produce the results in JS using this lib, I get results that are on average 5 seconds off:
Its just a couple seconds but they're crucial when minutes are rounded. I hope I'm missing something simple. Struck me as really strange especially because the source of this project is so similar to the Java. Makes me think that this might have to do with a loss of precision when handling big numbers in JS. Although, from a few quick greps I couldn't find any huge number literals.
The text was updated successfully, but these errors were encountered: