MCPcopy Index your code
hub / github.com/BehindTheMath/KosherZmanim

github.com/BehindTheMath/KosherZmanim @v0.9.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.9.0 ↗ · + Follow
619 symbols 1,638 edges 28 files 517 documented · 84%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

This project is at an alpha stage.

Things will break, and APIs might change. Be cautious using this in production. Additionally, not all methods have been tested for accuracy.

Introduction

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

Installation

NPM:

npm install kosher-zmanim

UMD (browser):

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

It is highly recommended that you pin the version (e.g. https://unpkg.com/kosher-zmanim@0.6.0/dist/kosher-zmanim.min.js), so updates don't break your app.

Usage and Documentation

Importing

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.

Library Usage:

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 instantiate or extend those classes as necessary, the same way you would in Java.

const zmanimCalendar = new KosherZmanim.ZmanimCalendar();

See the KosherJava API documentation for more details.

Simple usage

Alternatively, there is a getZmanimJson() utility method.

const zmanim = KosherZmanim.getZmanimJson(options);

Check out the demo, and look at the code to see an example of how it's used.

options object

The options object has the following structure and defaults:

{
    date: Date | string | number = new Date(),
    timeZoneId: string
    locationName?: string,
    latitude: number,
    longitude: number,
    elevation?: number = 0,
    complexZmanim?: boolean = false,
}

Note about how zmanim are calculated

This library uses Luxon as a date/time library, since Javascript's Date object does not support setting timezones other than the system timezone. All class methods that return a DateTime object will be in UTC.

Breaking changes from KosherJava

  • AstronomicalCalendar.getTemporalHour() returns null instead of Long.MIN_VALUE if the calculations cannot be completed.
  • JS/TS does not have a parallel to Java's Long.MIN_VALUE, so Long_MIN_VALUE is set to NaN.
  • The following methods are not supported:
  • AstronomicalCalendar.toString()
  • AstronomicalCalendar.toJSON() (Use ZmanimFormatter.toJSON(astronomicalCalendar) instead).
  • AstronomicalCalculator.getDefault() (Use new NOAACalculator() instead).
  • JewishCalendar.getDafYomiBavli() (Use YomiCalculator.getDafYomiBavli(jewishCalendar) instead).
  • JewishCalendar.getDafYomiYerushalmi() (Use YerushalmiYomiCalculator.getDafYomiYerushalmi(jewishCalendar) instead).
  • Time.toString() (Use new ZmanimFormatter(TimeZone.getTimeZone("UTC")).format(time) instead).
  • ZmanimFormatter.toXML()
  • Some method signatures are different, due to the differences between Java and JS.
  • The Zman class uses public members instead of getters and setters.

Extension points exported contracts — how you extend this code

Options (Interface)
(no doc)
src/kosher-zmanim.ts
JsonOutput (Interface)
(no doc)
src/util/ZmanimFormatter.ts
OutputMetadata (Interface)
(no doc)
src/util/ZmanimFormatter.ts

Core symbols most depended-on inside this repo

getJewishDayOfMonth
called by 52
src/hebrewcalendar/JewishDate.ts
getTimeOffset
called by 44
src/AstronomicalCalendar.ts
getSunsetOffsetByDegrees
called by 32
src/AstronomicalCalendar.ts
getJewishMonth
called by 31
src/hebrewcalendar/JewishDate.ts
getDate
called by 26
src/hebrewcalendar/JewishDate.ts
getElevationAdjustedSunset
called by 25
src/ZmanimCalendar.ts
getLatitude
called by 24
src/util/GeoLocation.ts
getYomTovIndex
called by 23
src/hebrewcalendar/JewishCalendar.ts

Shape

Method 545
Class 45
Function 25
Interface 3
Enum 1

Languages

TypeScript100%

Modules by API surface

src/ComplexZmanimCalendar.ts189 symbols
src/hebrewcalendar/JewishDate.ts62 symbols
src/hebrewcalendar/JewishCalendar.ts57 symbols
src/AstronomicalCalendar.ts40 symbols
src/ZmanimCalendar.ts37 symbols
src/hebrewcalendar/HebrewDateFormatter.ts35 symbols
src/util/NOAACalculator.ts25 symbols
src/util/GeoLocation.ts25 symbols
src/util/ZmanimFormatter.ts22 symbols
src/util/SunTimesCalculator.ts21 symbols
src/hebrewcalendar/Daf.ts19 symbols
src/util/Time.ts15 symbols

For agents

$ claude mcp add KosherZmanim \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact