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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@yassabdulrhman/hijri-gregorian-calendar

v1.0.0

Published

Gregorian and Hijri calendar utilities

Downloads

56

Readme

@yassabdulrhman/hijri-gregorian-calendar

A TypeScript library for converting between Gregorian and Hijri dates, with support for full month calendars and prediction awareness for future Hijri dates.

This package uses the AlAdhan Islamic Calendar API.

Features

  • Convert Gregorian date to Hijri date
  • Convert Hijri date to Gregorian date
  • Get Gregorian month with Hijri dates
  • Get Hijri month with Gregorian dates
  • Detect future Hijri dates as predicted
  • Block future predicted dates using confirmed mode
  • TypeScript support

Installation

npm install @yassabdulrhman/hijri-gregorian-calendar

Usage

import {
  toHijri,
  toGregorian,
  getGregorianMonth,
  getHijriMonth,
} from "@yassabdulrhman/hijri-gregorian-calendar";

Gregorian to Hijri

const result = await toHijri("13-06-2026");

console.log(result.hijri.date);

Hijri to Gregorian

const result = await toGregorian("27-12-1447");

console.log(result.gregorian.date);

Gregorian Month Calendar

const month = await getGregorianMonth(6, 2026);

console.log(month.days);

Hijri Month Calendar

const month = await getHijriMonth(12, 1447);

console.log(month.days);

Future Date Prediction

Hijri months depend on moon sighting, so future Hijri dates may not be final.

By default, future dates are allowed and marked as predicted:

const result = await toHijri("01-01-2030");

console.log(result.confidence);
// "predicted"

To block future predicted dates:

await toHijri("01-01-2030", {
  mode: "confirmed",
});

This will throw an error if the date is in the future.

Result Model

{
  gregorian: {
    date: "13-06-2026",
    day: "13",
    month: "June",
    year: "2026"
  },
  hijri: {
    date: "27-12-1447",
    day: "27",
    month: "Dhū al-Ḥijjah",
    year: "1447"
  },
  confidence: "confirmed",
  source: "aladhan",
  isFuture: false
}

API Source

This package uses the AlAdhan Islamic Calendar API:

  • gToH — Convert Gregorian date to Hijri date
  • hToG — Convert Hijri date to Gregorian date
  • gToHCalendar/:month/:year — Gregorian month with Hijri dates
  • hToGCalendar/:month/:year — Hijri month with Gregorian dates

API base URL:

https://api.aladhan.com/v1

AlAdhan provides REST APIs for Gregorian/Hijri conversion and full Islamic calendar month data.

Important Note About Accuracy

Past Hijri dates are generally fixed.

Future Hijri dates are predictions because the Hijri calendar follows moon sighting. A future date may shift by one day depending on official moon-sighting announcements.

For this reason, this package marks future dates as:

confidence: "predicted"

License

MIT