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

@calidy/dayjs-calendarsystems

v1.11.3

Published

Calendar Systems Management for Day.js

Downloads

328

Readme


Day.js Calendar Systems Plugin extends Day.js library to allow the use of different non-gregorian calendar systems like:

  • Persian (a.k.a.: Jalaali, Shamsi, Khorshidi),
  • Arabic (a.k.a: Hijri, Islamic, Umalqura, Ghamari),
  • Hebrew (a.k.a: Jewish),
  • Amazigh (a.k.a: Berber),
  • and more to come (PRs are welcome).

With this plugin, Day.js will be available to more than 200 million additional users worldwide (Estimated number of non-gregorian calendar users).

With the @calidy/dayjs-calendarsystems plugin, we bring the capacity to run and use all non-gregorian calendar systems to Dayjs.


Features

  • Register and use different calendar systems.
  • Typescript exports and definitions.
  • Compatible with all official Dayjs plugins.
  • No need for hacks, use dayjs apis in the standard way.
  • Small and light plugin, no overhead.
  • Convert between different calendar systems.
  • 🌍 🗓️ 📅 Default Gregorian calendar system included.
  • 🌍 🗓️ 🇮🇷 Persian Calendar system available.
  • 🌍 🗓️ 🇸🇦 Islamic (Hijri, Umalqura) Calendar system. Note: we will use the default "islamic-umalqura" calendar system for "islamic" calendar system.
  • 🌍 🗓️ 🇮🇱 Hebrew (Jewish) Calendar system.
  • 🌍 🗓️ ⵣ Amazigh (Berber) Calendar system.
  • 🌍 🗓️ 🇪🇹 [WIP] Ethiopian Calendar system.
  • 🌍 🗓️ 🇮🇳 [TODO] Indian Calendar system.
  • 🌍 🗓️ 🇨🇳 [TODO] Chinese Calendar system.
  • 🌍 ✅ Fixes translations of month names in Dayjs for non-gregorian and gregorian calendar systems (This is based on my knowledge, please PR to add more fixes).
  • [TODO] Parse date strings from different calendar systems
  • [TODO] Add more tests for all Dayjs Plugins

API

All API operations and Dayjs plugins may be used as instructed by Dayjs with the specific calendar system when this plugin is used, for more information checkout Dayjs Documentation

Installation

NPM

npm install --save @calidy/dayjs-calendarsystems

YARN

yarn add --save @calidy/dayjs-calendarsystems

Usage

import dayjs from "dayjs";
import calendarSystems from "@calidy/dayjs-calendarsystems";

// Note: Gregorian Calendar System is included by default,
//       so there is no need to import the `GregoryCalendarSystem` file here.

import PersianCalendarSystem from "@calidy/dayjs-calendarsystems/calendarSystems/PersianCalendarSystem";

// ...
// ALL YOU OTHER dayjs.extend() calls
// ...
// After all other dayjs plugins are initialized, extend dayjs with our calendar systems plugin:
dayjs.extend(calendarSystems);

// Register new calendar system
dayjs.registerCalendarSystem("persian", new PersianCalendarSystem());

// Set default dayjs config (for all following instances) to a specific calendar system:
// dayjs.toCalendarSystem("persian");

// Convert a dayjs instance to a specific calendar system.
let date = dayjs().toCalendarSystem("persian");

// Convert a date from a specific calendar system without initializing a dayjs instance.
date = dayjs.fromCalendarSystem('persian', 1402, 2, 17);

Adding Custom Calendar Systems

This plugin allows you to add your own custom calendar systems. Each calendar system must be an object with the following properties:

  • convertToGregorian(year: number, month: number, day: number): { year: number; month: number; day: number; } | void: a function that converts a date from the current calendar system to the Gregorian calendar.
  • convertFromGregorian(date: Date | string | number | undefined | null): { year: number; month: number; day: number; } | void: a function that converts a Gregorian date to the current calendar system.

License

This project is DUAL LICENSED.

  • For non-commercial use, this project uses the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) licence.
  • For commercial use (when you or your company earns revenue directly or indirectly using this project), a valid commercial licensed is required.

Please see the LICENSE.md file for details.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Please see the CONTRIBUTING.md file for details. Please see the CODE_OF_CONDUCT.md file for details.

Support

If you have any issues or feature requests, please file issues and feature requests on the GitHub repo.

Acknowledgements