Things will break, and APIs will change. Do not use this in production yet.
Kosher Zmanim is a TS/JS port of the KosherJava library.
NPM:
npm install --save kosher-zmanim
UMD (browser):
<script src="https://unpkg.com/kosher-zmanim/dist/kosher-zmanim.min.js"></script>
ES6 modules / Typescript:
import KosherZmanim from "kosher-zmanim";
Node:
const KosherZmanim = require("kosher-zmanim");
UMD (browser):
For UMD, a global KosherZmanim
object is exposed.
const zmanimCalendar = new KosherZmanim.lib.ZmanimCalendar();
The KosherJava library has been ported to JS, following the original API as close as possible. This is exposed as KosherZmanim.lib.*
, following the above example. You can instatiate or extend those classes as necessary, the same way you would in Java.
Alternatively, KosherZmanim can be instatiated, and then there are 2 utility methods: getZmanimJson()
, and getZmanimXML()
.
const kosherZmanim = new KosherZmanim(options);
const zmanim = kosherZmanim.getZmanimJson();
(See here for an example).
The options
object has the following structure:
{
date: Date | string | number;
timeZoneId: string;
locationName: string;
latitude: number;
longitude: number;
elevation?: number;
complexZmanim?: boolean
}
The zmanim are calculated based on the day of year, which is not dependent on timezone. This means that the zmanim will be calculated for the location selected, on the day of year passed, and then displayed at the equivalent time in the selected timezone.
AstronomicalCalendar.getTemporalHour()
returnsnull
instead ofLong.MIN_VALUE
if the calculations cannot be completed.