Port of the KosherJava library to TS/JS for NodeJS
Clone or download
Latest commit ef135da Aug 21, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist v0.2.4 Aug 21, 2018
examples/frontend-example Add README and example Oct 3, 2017
src Fix a bug in AstonomicalCalendar.setMoment() Aug 21, 2018
README.md Fix typo in the README Aug 21, 2018
jest.config.js Fix styling Nov 13, 2017
package-lock.json Update dependencies Jul 10, 2018
package.json v0.2.4 Aug 21, 2018
webpack.config.js Fix default exports for ES5 Nov 13, 2017

README.md

This project is at an alpha stage.

Things will break, and APIs will change. Do not use this in production yet.

Introduction

Kosher Zmanim is a TS/JS port of the KosherJava library.

Installation

NPM:

npm install --save kosher-zmanim

UMD (browser):

<script src="https://unpkg.com/kosher-zmanim/dist/kosher-zmanim.min.js"></script>

Usage and Documentation

Importing

ES6 modules / Typescript:

import KosherZmanim from "kosher-zmanim";

Node:

const KosherZmanim = require("kosher-zmanim");

UMD (browser):

For UMD, a global KosherZmanim object is exposed.

Library Usage:

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.

Simple usage

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).

options object

The options object has the following structure:

{
    date: Date | string | number;
    timeZoneId: string;
    locationName: string;
    latitude: number;
    longitude: number;
    elevation?: number;
    complexZmanim?: boolean
}

Note about how zmanim are calculated

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.

Breaking changes from KosherJava

  • AstronomicalCalendar.getTemporalHour() returns null instead of Long.MIN_VALUE if the calculations cannot be completed.