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 🙏

© 2025 – Pkg Stats / Ryan Hefner

hijri-date-formatter

v1.0.2

Published

A lightweight library for converting and formatting Gregorian dates to Hijri dates with multilingual support

Downloads

264

Readme

Hijri Date Formatter

A lightweight JavaScript library for converting Gregorian dates to Hijri (Islamic) dates with multilingual support and Indian numeral formatting.

Features

  • 📅 Convert Gregorian dates to Hijri dates
  • 🌐 Multilingual support (Arabic & English)
  • 🔢 Indian numeral formatting for Arabic output
  • 📦 Zero dependencies (except hijri-converter)
  • 🏷️ TypeScript support included
  • 🎯 Simple and intuitive API

Installation

npm install hijri-date-formatter

Quick Start

Get up and running in seconds — examples below show ES Modules and CommonJS usage, plus common helper functions.

ES Modules

// ES Modules
import {
    hijriInputFormat,
    getCurrentHijriDate,
    normalToHijri,
    toIndian
} from 'hijri-date-formatter';

// Current Hijri date (English, DD/MM/YYYY)
console.log(getCurrentHijriDate()); // e.g. "15/06/1445"

// Format today's date in Arabic with Indian numerals
console.log(hijriInputFormat(new Date(), 'ar', false)); // e.g. "١٥/٠٦/١٤٤٥"

CommonJS

// CommonJS
const {
    hijriInputFormat,
    getCurrentHijriDate,
    normalToHijri,
    toIndian
} = require('hijri-date-formatter');

console.log(getCurrentHijriDate());

Examples

Basic conversion

import { hijriInputFormat } from 'hijri-date-formatter';
const date = new Date('2023-01-15');
console.log(hijriInputFormat(date, 'en', true)); // "15/6/1444"

Arabic format with Indian numerals

import { hijriInputFormat } from 'hijri-date-formatter';
console.log(hijriInputFormat(new Date(), 'ar', false)); // "١٥/٠٦/١٤٤٥"

Get raw Hijri object

import { normalToHijri } from 'hijri-date-formatter';
console.log(normalToHijri(new Date())); // { day: 15, month: 6, year: 1445 }

Convert to Indian numerals

import { toIndian } from 'hijri-date-formatter';
console.log(toIndian(1445));   // "١٤٤٥"
console.log(toIndian('2023')); // "٢٠٢٣"

TypeScript

import { hijriInputFormat, normalToHijri } from 'hijri-date-formatter';

const hijriDate: string = hijriInputFormat(new Date(), 'en', true);
const hijriObject: { day: number; month: number; year: number } = normalToHijri(new Date());

Contributing

Contributions are welcome! Please follow these steps to contribute:

  1. Fork the repository.
  2. Create your feature branch:
git checkout -b feature/AmazingFeature
  1. Commit your changes:
git commit -m "Add some AmazingFeature"
  1. Push to the branch:
git push origin feature/AmazingFeature
  1. Open a Pull Request describing your changes and any relevant context.

Please make sure your code follows the existing style, includes tests where appropriate, and documents new behavior.

License

This project is licensed under the MIT License — see the LICENSE file for details.

Acknowledgments

  • Built with hijri-converter for accurate date conversions
  • Indian numeral conversion for authentic Arabic display

Support

If you encounter any issues or have questions, please file an issue on the GitHub repository.

Note: This library uses astronomical calculations for date conversion. There might be slight variations (±1 day) compared to local moon-sighting observations in different regions.