jewish-date
Version:
Converts Gregorian dates to Hebrew dates and vice versa.
52 lines (51 loc) • 2.32 kB
TypeScript
/**
* Copyright (c) Shmulik Kravitz.
*
* This source code is licensed under the MIT license.
* See the LICENSE file in the root directory for more information.
*
*/
/**
* Computes the remainder of the division of `a` by `b`.
* Unlike the built-in JavaScript `%` operator, this function handles negative numbers properly.
* For example, `mod(-1, 5)` returns `4`, not `-1`.
* @param {number} a - The number to compute the remainder of.
* @param {number} b - The divisor.
* @returns {number} - The remainder of `a` divided by `b`.
*/
export declare function mod(a: number, b: number): number;
/**
* Converts Gregorian date to Julian Day.
* @param {number} year - The year in the Gregorian calendar.
* @param {number} month - The month in the Gregorian calendar (January = 1).
* @param {number} day - The day of the month in the Gregorian calendar.
* @returns {number} The Julian Day corresponding to the Gregorian date.
*/
export declare function gregorianToJd(year: number, month: number, day: number): number;
/**
* Converts a Julian day number to Gregorian date.
* @param {number} jd - The Julian day number to convert.
* @returns {[number, number, number]} The Gregorian date as a tuple in the form of [year, month, day].
*/
export declare function jdToGregorian(jd: number): [number, number, number];
/**
* Calculates the number of days in the specified month of the Hebrew year.
* @param {number} year - The Hebrew year.
* @param {number} month - The month of the year, where Nisan is 1 and Adar II (in leap years) is 13.
* @returns {number} - The number of days in the specified month.
*/
export declare function hebrewMonthDays(year: number, month: number): 29 | 30;
/**
* Converts a Hebrew date to the corresponding Julian day.
* @param {number} year - The Hebrew year.
* @param {number} month - The Hebrew month (1-13).
* @param {number} day - The day of the month.
* @returns {number} The Julian day corresponding to the Hebrew date.
*/
export declare function hebrewToJd(year: number, month: number, day: number): number;
/**
* Converts a Julian date to a Hebrew date.
* @param jd - The Julian date to convert.
* @returns The Hebrew date as a tuple in the form of [year, month, day].
*/
export declare function jdToHebrew(julianDate: number): [number, number, number];