npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ethiopian-date-converter-lib

v1.0.1

Published

ethiopian date converter

Downloads

3

Readme

Here's the updated documentation for the EthiopianDate class, including details on date-time conversion:


EthiopianDate Class Documentation

Overview

The EthiopianDate class provides functionality to work with dates and times in the Ethiopian calendar system. This class allows you to create, convert, and manipulate Ethiopian dates and times, as well as interact with the Gregorian calendar.

This code provides a detailed implementation of the EthiopianDate class, which models dates according to the Ethiopian calendar and provides methods to convert between the Ethiopian and Gregorian calendars. Here’s a brief overview of its features and functionality:

Constructor

  • constructor(year, month, date): Initializes an EthiopianDate object and validates the provided date.

Conversion Methods

  • toGregorian(): Converts the Ethiopian date to the corresponding Gregorian date.
  • fromGregorian(gregorianDate): Static method to create an EthiopianDate object from a Gregorian date.

Leap Year and Current Date

  • isLeapYear(year): Static method to check if a given Ethiopian year is a leap year.
  • now(): Static method to get the current Ethiopian date based on the current Gregorian date.

Formatting and Parsing

  • format(formatString): Formats the Ethiopian date as a string according to the specified format.
  • parse(dateString, formatString): Static method to parse a formatted date string and create an EthiopianDate object.

Validation and Date Manipulation

  • isValid(): Validates whether the current Ethiopian date object is valid.
  • nextMonth(): Moves to the next month in the Ethiopian calendar.
  • prevMonth(): Moves to the previous month in the Ethiopian calendar.
  • getMaxDaysInMonth(year, month): Static method to get the maximum number of days in a specified Ethiopian month.

Additional Utility Methods

  • calculateDaysInEthiopianCalendar(): Calculates the number of days since the start of the Ethiopian calendar to the current date.
  • compare(date1, date2): Static method to compare two EthiopianDate objects.
  • toString(): Returns a string representation of the Ethiopian date in the default format (YYYY-MM-DD).

Example Usage

Here are a few examples of how to use the class:

// Creating an EthiopianDate object
const etDate = new EthiopianDate(2013, 1, 1);

// Converting to Gregorian date
const gregDate = etDate.toGregorian();
console.log(gregDate); // Outputs Gregorian date

// Parsing a formatted date string
const parsedDate = EthiopianDate.parse('2013-01-01', 'YYYY-MM-DD');
console.log(parsedDate); // Outputs EthiopianDate object

// Formatting the Ethiopian date
const formattedDate = etDate.format('YYYY-MM-DD');
console.log(formattedDate); // Outputs '2013-01-01'

// Moving to the next month
const nextMonthDate = etDate.nextMonth();
console.log(nextMonthDate); // Outputs the date in the next month

// Comparing two Ethiopian dates
const comparison = EthiopianDate.compare(etDate, new EthiopianDate(2013, 2, 1));
console.log(comparison); // Outputs -1, 0, or 1

Overall, this class should be quite useful for working with dates in the Ethiopian calendar and converting between Ethiopian and Gregorian systems. If you have specific questions or need further modifications, feel free to ask!