hebcal / hebcal-js

⛔️ DEPRECATED - a perpetual Jewish Calendar (JavaScript)
GNU General Public License v3.0
124 stars 40 forks source link

Zemanim #66

Closed chlaudan closed 5 years ago

chlaudan commented 5 years ago

Running new Hebcal.HDate().getZemanim() gets this result, the times seem to be off very off, I tested on runkit.

alot_hashachar: Sun Jun 30 2019 00:54:29 GMT-0400 (Eastern Daylight Time) alot_hashacher: Sun Jun 30 2019 00:54:29 GMT-0400 (Eastern Daylight Time) chatzot: Sun Jun 30 2019 08:04:44 GMT-0400 (Eastern Daylight Time) chatzot_night: Sat Jun 29 2019 20:04:38 GMT-0400 (Eastern Daylight Time) mincha_gedola: Sun Jun 30 2019 08:35:02 GMT-0400 (Eastern Daylight Time) mincha_ketana: Sun Jun 30 2019 11:36:50 GMT-0400 (Eastern Daylight Time) misheyakir: Sun Jun 30 2019 01:14:37 GMT-0400 (Eastern Daylight Time) misheyakir_machmir: Sun Jun 30 2019 01:20:18 GMT-0400 (Eastern Daylight Time) neitz_hachama: Sun Jun 30 2019 02:01:06 GMT-0400 (Eastern Daylight Time) plag_hamincha: Sun Jun 30 2019 12:52:36 GMT-0400 (Eastern Daylight Time) shkiah: Sun Jun 30 2019 14:08:21 GMT-0400 (Eastern Daylight Time) sof_zman_shma: Sun Jun 30 2019 05:02:55 GMT-0400 (Eastern Daylight Time) sof_zman_tfilla: Sun Jun 30 2019 06:03:31 GMT-0400 (Eastern Daylight Time) tzeit: Sun Jun 30 2019 14:41:44 GMT-0400 (Eastern Daylight Time)

mennyg commented 5 years ago

I am having the same issue. This seems to be caused by Hebcal finding zmanim based on the geolocation, and displaying the times based on the computer's locale code, which throws everything off by a few hours. I am running a computer on EST and getting Zmanim for Jerusalem which should be displaying Shkiah as approximately 7:44 PM. Instead, I am getting "Sun Jul 21 2019 12:44:36 GMT-0400 (Eastern Daylight Time)", which is 7 hours off. Maybe we can get the default locale code included in the cities list in cities.js and base the getZmanim off that? I'm new to NPM and JS, so I am not sure how to do this...

Scimonster commented 5 years ago

It's a Date object which stores a moment in time. There are various date libraries you can use on top of it such as moment.js or Luxon, which can display it according to whatever locale and timezone you want.

gdoron commented 5 years ago

@Scimonster I think we need to add to the City object the Timezone it's in. For example, for Jerusalem, I need to use this:

obj.eventExit = holiday.YOM_TOV_ENDS && holiday.havdalah().toLocaleTimeString('en-US', { timeZone: 'Asia/Jerusalem', hour12: false, hour: "2-digit", minute: "2-digit" }) || '';

While I would rather prefer having a way of getting the timezone for the city from the library itself.