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

hijri-now

v1.5.1

Published

A JavaScript library for converting between Gregorian and Hijri (Islamic) calendar dates.

Downloads

17

Readme

HijriNow

HijriNow is a JavaScript library that provides functionality for working with the Hijri calendar. This library allows you to convert dates between the Gregorian and Hijri calendars, retrieve information about the current date in the Hijri calendar, and more.

Installation

To use HijriNow in your project, you can include it via a CDN or install it using npm:

CDN

<script src="https://cdn.jsdelivr.net/npm/hijri-now/hijriNow.min.js"></script>

NPM

npm i hijri-now

Features

today() function

  • Description: Retrieves the current date in the Hijri calendar.

Usage:

const today = HijriNow.today();
console.log(today); // Output: "9/10/1445 هجري" (depending on the current date)

month() function

  • Description: Retrieves the current month in the Hijri calendar.

Usage:

const month = HijriNow.month();
console.log(month); // Output: "10" (depending on the current date)

year() function

  • Description: Retrieves the current year in the Hijri calendar.

Usage:

const year = HijriNow.year();
console.log(year); // Output: "1445" (depending on the current date)

day() function

  • Description: Retrieves the current day in the Hijri calendar.

Usage:

const day = HijriNow.day();
console.log(day); // Output: "9" (depending on the current date)

getMonthName() function

  • Description: Retrieves the name of the current month in the Hijri calendar.

Usage:

HijriNow.getMonthName()
  .then(monthName => {
    console.log(monthName); // Output: "شوال" (depending on the current date)
  })
  .catch(error => {
    console.error(error);
  });

getDayName() function

  • Description: Retrieves the name of the current day.

Usage:

HijriNow.getDayName()
  .then(dayName => {
    console.log(dayName); // Output: "الخميس" (depending on the current date)
  })
  .catch(error => {
    console.error(error);
  });

CongratsNow() function

  • Description: Retrieves congratulations message if today is a special occasion like Eid.

Usage:

HijriNow.CongratsNow()
  .then(congratsMessage => {
    console.log(congratsMessage); // Output: "عيد مبارك علينا وعليكم"  if today is eid (depending on the current date)
  })
  .catch(error => {
    console.error(error);
  });

addHijriDays() function

  • Description: Adds a specified number of days to a given Hijri date.
  • Parameters:
    • dateString: A string representing the Hijri date in the format "day/month/year".
    • days: The number of days to add.

Usage:

const newDate = HijriNow.addHijriDays("9/10/1445", 10);
console.log(newDate); // Output: "19/10/1445" (depending on the input date and days)

isTodayEid() function

  • Description: Checks if today is Eid in the Hijri calendar.

Usage:

HijriNow.isTodayEid()
  .then(isEid => {
    console.log(isEid); // Output: true or false (depending on the current date)
  })
  .catch(error => {
    console.error(error);
  });

todayInText() function

  • Description: Retrieves the current date in text format in the Hijri calendar.

Usage:

HijriNow.todayInText()
  .then(dateText => {
    console.log(dateText); // Output: "التاسع من شوال سنة 1446 هجري" (depending on the current date)
  })
  .catch(error => {
    console.error(error);
  });

toGregorian() function

  • Description: Converts a Hijri date to Gregorian.
  • Parameters:
    • dateString: A string representing the Hijri date in the format "day/month/year".
    • splitter: (Optional) The character used to split the date components.

Usage:

const gregorianDate = HijriNow.toGregorian("9/10/1445");
console.log(gregorianDate); // Output: "18/04/2024" (depending on the input date)

toHijri() function

  • Description: Converts a Gregorian date to Hijri.
  • Parameters:
    • dateString: A string representing the Gregorian date in the format "day/month/year".
    • splitter: (Optional) The character used to split the date components.

Usage:

const hijriDate = HijriNow.toHijri("18/04/2024");
console.log(hijriDate); // Output: "9/10/1445" (depending on the input date)

Language

The current language is Arabic. You can set it to English using this code:

HijriNow.currentLanguage = 'en'

Usage

Once included in your project, you can start using the HijriNow library in your JavaScript code as demonstrated in the feature descriptions above.

Note

HijriNow relies on the user's system date and time settings to determine the current date in the Hijri calendar. Ensure that the user's system date and time settings are correctly configured for accurate results.