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

@sherifnabil/hijri-gregorian-calendar-core

v1.0.13

Published

Framework-agnostic dual calendar (Hijri/Gregorian) logic

Readme

@sherifnabil/hijri-gregorian-calendar-core

Framework-agnostic calendar logic for Hijri and Gregorian calendars.

Installation

npm install @sherifnabil/hijri-gregorian-calendar-core

Features

  • Calendar Adapters: Gregorian (using date-fns) and Hijri (using moment-hijri with Umm al-Qura calendar)
  • Calendar Grid Generator: Generate calendar months with date constraints
  • Date Utilities: Formatting, parsing, and navigation
  • Locale Support: English and Arabic locales with RTL support
  • TypeScript: Full type definitions included

Usage

Calendar Adapters

import { GregorianAdapter, HijriAdapter } from '@sherifnabil/hijri-gregorian-calendar-core';

// Gregorian calendar
const gregorian = new GregorianAdapter();
const today = gregorian.today();
const formatted = gregorian.format(today, 'dd/MM/yyyy', getLocale('en'));

// Hijri calendar
const hijri = new HijriAdapter();
const todayHijri = hijri.today();
const formattedHijri = hijri.format(todayHijri, 'dd/MM/yyyy', getLocale('ar'));

Calendar Month Generation

import { generateCalendarMonth, GregorianAdapter, getLocale } from '@sherifnabil/hijri-gregorian-calendar-core';

const adapter = new GregorianAdapter();
const locale = getLocale('en');

const calendarMonth = generateCalendarMonth(
  2024,
  1, // January
  adapter,
  locale,
  { year: 2024, month: 1, day: 15 }, // selected date
  undefined, // selected range (optional)
  {
    minDate: { year: 2024, month: 1, day: 1 },
    maxDate: { year: 2024, month: 1, day: 31 },
    disabledDates: [
      { year: 2024, month: 1, day: 1 }
    ],
    disabledDaysOfWeek: [0, 6] // Sunday and Saturday
  }
);

Date Navigation

import { nextMonth, previousMonth, nextYear, previousYear, goToToday } from '@sherifnabil/hijri-gregorian-calendar-core';
import { GregorianAdapter } from '@sherifnabil/hijri-gregorian-calendar-core';

const adapter = new GregorianAdapter();
const date = { year: 2024, month: 1, day: 15 };

const next = nextMonth(date, adapter);
const prev = previousMonth(date, adapter);
const nextYr = nextYear(date, adapter);
const prevYr = previousYear(date, adapter);
const today = goToToday(adapter);

Locale Support

import { getLocale } from '@sherifnabil/hijri-gregorian-calendar-core';

const english = getLocale('en');
const arabic = getLocale('ar');

// Locale includes:
// - monthNames: Array of month names
// - dayNames: Array of day names
// - direction: 'ltr' or 'rtl'
// - code: locale code

API Reference

CalendarAdapter

Base interface for calendar adapters:

interface CalendarAdapter {
  today(): CalendarDate;
  format(date: CalendarDate, format: string, locale: LocaleConfig): string;
  parse(dateString: string, format: string, locale: LocaleConfig): CalendarDate | null;
  getMonthName(month: number, locale: LocaleConfig): string;
  getDayName(day: number, locale: LocaleConfig): string;
  // ... and more
}

Types

interface CalendarDate {
  year: number;
  month: number;  // 1-indexed
  day: number;    // 1-indexed
}

interface LocaleConfig {
  code: string;
  direction: 'ltr' | 'rtl';
  monthNames: string[];
  dayNames: string[];
  // ... and more
}

interface CalendarMonth {
  weeks: CalendarWeek[];
}

interface CalendarWeek {
  days: CalendarDay[];
}

interface CalendarDay {
  date: CalendarDate;
  isCurrentMonth: boolean;
  isToday: boolean;
  isSelected: boolean;
  isDisabled: boolean;
  isInRange?: boolean;
  isRangeStart?: boolean;
  isRangeEnd?: boolean;
}

Exports

Adapters

  • GregorianAdapter
  • HijriAdapter
  • BaseAdapter (abstract base class)

Calendar Generation

  • generateCalendarMonth

Navigation

  • nextMonth
  • previousMonth
  • nextYear
  • previousYear
  • goToToday

Utilities

  • getLocale
  • formatNumber

Types

  • CalendarDate
  • CalendarAdapter
  • LocaleConfig
  • CalendarMonth
  • CalendarDay
  • And more...

Requirements

  • date-fns ^3.3.1
  • moment ^2.30.1
  • moment-hijri ^3.0.0

Documentation

For complete documentation and examples, visit the main repository.

License

MIT