jewish-date
Version:
Converts Gregorian dates to Hebrew dates and vice versa.
63 lines (62 loc) • 3.31 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.
*
*/
import type { BasicJewishDate, JewishDate, JewishMonthType } from "./interfaces";
/**
* Checks if the given year is a leap year according to the Jewish calendar.
* @param {number} year - The year to check.
* @returns {boolean} True if the given year is a leap year according to the Jewish calendar, false otherwise.
*/
export declare const isLeapYear: (year: number) => boolean;
/**
* Returns the index of the given Jewish month in the Jewish calendar.
* @param {JewishMonthType} jewishMonth - The Jewish month to get the index for.
* @returns {number} The index of the given Jewish month in the Jewish calendar.
*/
export declare const getIndexByJewishMonth: (jewishMonth: JewishMonthType) => number;
/**
* Returns the Jewish month corresponding to the given index in the Jewish calendar of the given year.
* @param {number} index - The index of the Jewish month to get (1-based).
* @param {number} jewishYear - The year to get the Jewish month in.
* @returns {JewishMonthType} The Jewish month corresponding to the given index in the Jewish calendar of the given year.
*/
export declare const getJewishMonthByIndex: (index: number, jewishYear: number) => JewishMonthType;
/**
* Returns an array of the Jewish month names in the correct order for the given year.
* @param {number} year - The Jewish year to get the months for.
* @returns {string[]} An array of the Jewish month names in the correct order for the given year.
* */
export declare const getJewishMonthsInOrder: (year: number) => string[];
/**
* Returns a string representation of the given Jewish date.
* @param {JewishDate} jewishDate - The Jewish date to format.
* @param {string} [pattern] - Optional format pattern (e.g., "d MMMM yyyy", "dd/MM/yy").
* Supported tokens: d (day), dd (day padded), D (day), M (month), MM (month padded),
* MMMM (month name), yy (short year), YY (short year), yyyy (full year), YYYY (full year).
* Default pattern: "d MMMM yyyy"
* @returns {string} A string representation of the given Jewish date.
*/
export declare const formatJewishDate: (jewishDate: JewishDate, pattern?: string) => string;
/**
* Converts the given Gregorian date to a Jewish date.
* @param {Date} date - The Gregorian date to convert.
* @returns {JewishDate} The Jewish date corresponding to the given Gregorian date.
*/
export declare const toJewishDate: (date: Date) => JewishDate;
/**
* Converts the given Jewish date to a Gregorian date.
* @param {BasicJewishDate} jewishDate - The Jewish date to convert.
* @returns {Date} The Gregorian date corresponding to the given Jewish date.
* */
export declare const toGregorianDate: (jewishDate: BasicJewishDate) => Date;
/**
* Calculates the number of days in a Jewish month for a given Jewish year.
* @param {number} jewishYear - The Jewish year for which the calculation is performed.
* @param {JewishMonthType} jewishMonth - The type of Jewish month (e.g., 'Heshvan', 'Kislev').
* @returns {number} - The number of days in the specified Jewish month of the given year.
*/
export declare const calcDaysInMonth: (jewishYear: number, jewishMonth: JewishMonthType) => number;