1.0.2 • Published 10 months ago

ethiopian-calendar-converter v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

Overview

The Ethiopian Calendar Converter is a JavaScript library for converting dates between the Ethiopian and Gregorian calendars. This documentation provides an overview of the library, installation instructions, and usage examples.

Installation

Install the library via npm:

npm install ethiopian-calendar-converter

Usage

First, import the library into your project:

import EthiopianCalendar from "ethiopian-calendar-converter";

Convert Gregorian Date to Ethiopian Date

To convert a Gregorian date to an Ethiopian date, use the `convertToEthiopian` method:

const gregorianDate = "2023-12-25";
const etCalendar = new EthiopianCalendar(gregorianDate);
const ethiopianDate = etCalendar.convertToEthiopian().date;
console.log(ethiopianDate); // Output: Ethiopian date equivalent

Convert Ethiopian Date to Gregorian Date

To convert an Ethiopian date to a Gregorian date, use the `convertToGregorian` method:

const ethiopianDate = "2015-04-15";
const etCalendar = new EthiopianCalendar(ethiopianDate);
const gregorianDate = etCalendar.convertToGregorian().date;
console.log(gregorianDate); // Output: Gregorian date equivalent

API Reference

Class: `EthiopianCalendar`

Constructor

new EthiopianCalendar(rawDate);
  • rawDate: The raw date input to initialize the calendar. It can be a string (in "YYYY-MM-DD" format), a Date object, or a custom object with a `date` property.

Methods

  • convertToEthiopian()

    • Converts the provided date to Ethiopian date.
    • Returns: An object with the Ethiopian date properties.
  • convertToGregorian()

    • Converts the provided date to Gregorian date.
    • Returns: An object with the Gregorian date properties.

Month Names

Ethiopian Month Names

const ETHIOPIAN_MONTH_NAMES = [
  "መስከረም",
  "ጥቅምት",
  "ህዳር",
  "ታህሳስ",
  "ጥር",
  "የካቲት",
  "መጋቢት",
  "ሚያዛ",
  "ግንቦት",
  "ሰኔ",
  "ሃምሌ",
  "ነሃሴ",
  "ፗጉሜ",
];

Gregorian Month Names

const GREGORIAN_MONTH_NAMES = [
  "January",
  "February",
  "March",
  "April",
  "May",
  "June",
  "July",
  "August",
  "September",
  "October",
  "November",
  "December",
];

Example

Here is an example of converting today's date to Ethiopian and then back to Gregorian:

import EthiopianCalendar from "ethiopian-calendar-converter";

const today = new Date();
const etCalendar = new EthiopianCalendar(today);
const ethiopianDate = etCalendar.convertToEthiopian().date;
console.log(`Ethiopian Date: ${ethiopianDate}`);

const grCalendar = new EthiopianCalendar(ethiopianDate);
const gregorianDate = grCalendar.convertToGregorian().date;
console.log(`Gregorian Date: ${gregorianDate}`);

License

This project is licensed under the MIT License - see the LICENSE.md file for details. `;

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago