hebcal/hebcal-es6

HDate should collaborate with Nightfall

Closed this issue · 1 comments

I'm not sure how to express my issue, will try my best.
Currently, HDate is calculated based on a Gregorian date, but the problem is that the gregorian date changes at midnight while the hebrew date changes at nightfall..
If i want to check a datetime for any event, i can't just rely on HDate since it will return results based on the gregorian date which won't change till midnight. so i also need to check if it's after nightfall and considered next hebrew date.
Is it possible to add the functionality of calculating the HDate based on the time and GeoLocation which should change at nightfall?
I hope this is clear enough.
Thanks!

Thanks for your question. It is indeed clear enough.

The API is intentionally designed to keep the HDate class simple. It is a deliberate choice for HDate to store only a day, month and year and not have any complexity of time of day or location.

You can get the current Hebrew date using a few lines of code like this:

const {Location, Zmanim, HDate} = require('@hebcal/core');
const location = Location.lookup('Boston');
const now = new Date();
const zmanim = new Zmanim(location, now, false);
const sunset = zmanim.sunset();
let hd = new HDate(now);
if (now >= sunset) {
  hd = hd.next();
}