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 * as KosherZmanim from "kosher-zmanim";
Or:
import { ComplexZmanimCalendar, getZmanimJson } from "kosher-zmanim";
CommonJS modules:
const KosherZmanim = require("kosher-zmanim");
Or:
const { ComplexZmanimCalendar, getZmanimJson } = require("kosher-zmanim");
UMD (browser):
For UMD, a global KosherZmanim
object is exposed.
The KosherJava library has been ported to JS, following the original API as close as possible. The classes are exposed as named exports. You can instatiate or extend those classes as necessary, the same way you would in Java.
const zmanimCalendar = new KosherZmanim.ZmanimCalendar();
Alternatively, there is a getZmanimJson()
utility method.
const zmanim = KosherZmanim.getZmanimJson(options);
(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.- JS/TS does not have a parallel to Java's
Long.MIN_VALUE
, soLong_MIN_VALUE
is set toNaN
.