1.0.0 • Published 2 months ago
ec-converter v1.0.0
EC-Converter
A JavaScript/TypeScript library for converting between Ethiopian calendar and Gregorian calendar.
Features
- Convert dates from Gregorian to Ethiopian calendar
- Convert dates from Ethiopian to Gregorian calendar
- Validate dates in both calendar systems
- Written in TypeScript with full type definitions
- Zero dependencies
- Comprehensive test coverage
Installation
npm install ec-converter
or
yarn add ec-converter
Usage
Converting from Gregorian to Ethiopian
import { toEthiopian } from 'ec-converter';
// September 11, 2023 (Gregorian) -> Meskerem 1, 2016 (Ethiopian)
const ethiopianDate = toEthiopian({ year: 2023, month: 9, day: 11 });
console.log(ethiopianDate);
// Output: { year: 2016, month: 1, day: 1 }
Converting from Ethiopian to Gregorian
import { toGregorian } from 'ec-converter';
// Meskerem 1, 2016 (Ethiopian) -> September 11, 2023 (Gregorian)
const gregorianDate = toGregorian({ year: 2016, month: 1, day: 1 });
console.log(gregorianDate);
// Output: { year: 2023, month: 9, day: 11 }
Validating Dates
import { isValidEthiopianDate, isValidGregorianDate } from 'ec-converter';
// Check if a Gregorian date is valid
console.log(isValidGregorianDate({ year: 2023, month: 2, day: 29 }));
// Output: false (2023 is not a leap year)
// Check if an Ethiopian date is valid
console.log(isValidEthiopianDate({ year: 2016, month: 13, day: 6 }));
// Output: true (2016 is a leap year in Ethiopian calendar)
Ethiopian Calendar Overview
The Ethiopian calendar:
- Is approximately 7-8 years behind the Gregorian calendar
- Has 13 months: 12 months of 30 days each and a 13th month of 5 or 6 days
- Has a leap year every 4 years, similar to the Gregorian calendar but with different rules
- Starts its new year on what is September 11 (or September 12 in leap years) in the Gregorian calendar
Month Names
- Meskerem (መስከረም) - 30 days
- Tikimt (ጥቅምት) - 30 days
- Hidar (ኅዳር) - 30 days
- Tahsas (ታኅሣሥ) - 30 days
- Tir (ጥር) - 30 days
- Yekatit (የካቲት) - 30 days
- Megabit (መጋቢት) - 30 days
- Miyazya (ሚያዝያ) - 30 days
- Ginbot (ግንቦት) - 30 days
- Sene (ሰኔ) - 30 days
- Hamle (ሐምሌ) - 30 days
- Nehase (ነሐሴ) - 30 days
- Pagume (ጳጉሜ) - 5 or 6 days
License
MIT