Logo Lanfrica

michael-gizaw/ethiopian-dates

Domaine:

natural language processing

Type de record:

software
Créateur:
mic
Hôte:
A modern TypeScript library for converting between Gregorian and Ethiopian calendars, with support for Amharic month names, Geez numerals, and Ethiopian holidays. # ethiopian-dates You're building something for Ethiopian users and you need the date to read **Sene 4, 2018** instead of June 11, 2026. This package does that conversion in both directions, and handles the parts you'd rather not write yourself: the 13th month, the leap-year rule, Geez numerals, Amharic names, and the full public holiday list including the movable ones. Zero dependencies. Written in TypeScript, so you get types without installing anything extra. ```sh npm install ethiopian-dates ``` ## Convert a date Pass year, month, day. Months are 1-indexed in both directions, and month 13 is Pagume. ```ts import { toEthiopian, toGregorian } from 'ethiopian-dates'; toEthiopian(2024, 9, 11); // { year: 2017, month: 1, day: 1, monthName: 'Meskerem', monthNameAmharic: 'መስከረም' } toGregorian(2017, 1, 1); // { year: 2024, month: 9, day: 11, monthName: 'September' } ``` Bad dates throw a `RangeError` instead of silently converting to something wrong. February 30 won't get past you, and neither will Pagume 6 in a year where Pagume only has 5 days. ## Get today ```ts import { todayInEthiopian } from 'ethiopian-dates'; todayInEthiopian(); // { year: 2018, month: 10, day: 4, monthName: 'Sene', monthNameAmharic: 'ሰኔ' } ``` Uses the local timezone. Pass a `Date` if you mean a different moment: `todayInEthiopian(someDate)`. ## Write Geez numerals ```ts import { toGeez } from 'ethiopian-dates'; toGeez(2017); // '፳፻፲፯' toGeez(1); // '፩' toGeez(100); // '፻' ``` Handles the quirks for you: there's no zero, and the coefficient ፩ is dropped before ፻ (100) and ፼ (10,000). Works up to 99,999,999. ## Look up holidays ```ts import { getHolidays, isHoliday } from 'ethiopian-dates'; getHolidays(2017); // All public holidays that year, sorted, each with its Gregorian equivalent: // [ // { name: 'Enkutatash', nameAmharic: 'እንቁጣጣሽ', month: 1, day: 1, movable: false, // year: 2017, gregorian: { year: 2024, month: 9, day: 11, monthName: 'September' } }, // …

Languages

Licenses