hebrew-date-ts
v1.0.0
Published
Convert date objects into Hebrew calendar dates. TypeScript fork of hebrew-date.
Maintainers
Readme
hebrew-date-ts
Convert date objects into Hebrew calendar dates. TypeScript fork of hebrew-date.
This package is a TypeScript port of the original hebrew-date package by Ionică Bizău. The only change is the addition of TypeScript support and type definitions. All credit for the original implementation goes to the original author.
If you'd like to support the original author, please visit: https://github.com/IonicaBizau/hebrew-date
Installation
# Using npm
npm install hebrew-date-ts
# Using yarn
yarn add hebrew-date-ts
# Using pnpm
pnpm add hebrew-date-tsUsage
import { hebrewDate } from "hebrew-date-ts";
// Using year, month, day (month is one-indexed, January = 1)
console.log(hebrewDate(2016, 10, 2));
// { year: 5776, month: 13, date: 29, month_name: 'Elul' }
// Using a Date object
const october = 9; // zero-indexed for Date constructor
console.log(hebrewDate(new Date(2016, october, 3)));
// { year: 5777, month: 1, date: 1, month_name: 'Tishri' }CommonJS
const { hebrewDate } = require("hebrew-date-ts");
console.log(hebrewDate(2016, 10, 2));
// { year: 5776, month: 13, date: 29, month_name: 'Elul' }API
hebrewDate(inputDate: Date): HebrewDateResult
hebrewDate(year: number, month: number, day: number): HebrewDateResult
Convert Gregorian dates into Hebrew calendar dates.
Parameters
- inputDate (
Date): A Date object representing the Gregorian date, OR - year (
number): The Gregorian year - month (
number): The Gregorian month (one-indexed, January being1!) - day (
number): The Gregorian day of month
Returns
HebrewDateResult - An object containing:
year(number): The Hebrew yearmonth(number): The Hebrew month (1-13)date(number): The Hebrew day of monthmonth_name(string): The Hebrew month name
TypeScript
Full TypeScript support with exported types:
import { hebrewDate, HebrewDateResult } from "hebrew-date-ts";
const result: HebrewDateResult = hebrewDate(new Date());
console.log(result.year); // number
console.log(result.month); // number
console.log(result.date); // number
console.log(result.month_name); // stringContributing
For issues related to the TypeScript port, please open an issue at https://github.com/MendyLanda/hebrew-date-ts/issues.
For issues related to the core date conversion logic, please consider contributing to the original project at https://github.com/IonicaBizau/hebrew-date.
License
MIT - Original implementation by Ionică Bizău, TypeScript port by Mendy Landa.
