Giter VIP home page Giter VIP logo

hijrinow's Introduction

HijriNow

NPM Version NPM Downloads

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: "التاسع من شوال سنة 1445 هجري" (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.

hijrinow's People

Contributors

itshnawy avatar

Stargazers

Mohamed Wagih avatar omarsabra avatar Kareem Ebrahim avatar Anss Khaled Farouk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.