Gathering detailed insights and metrics for @calidy/dayjs-calendarsystems
Gathering detailed insights and metrics for @calidy/dayjs-calendarsystems
Gathering detailed insights and metrics for @calidy/dayjs-calendarsystems
Gathering detailed insights and metrics for @calidy/dayjs-calendarsystems
Day.js Calendar Systems Plugin : extends Day.js library to allow the use of non-gregorian calendar systems.
npm install @calidy/dayjs-calendarsystems
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
16 Stars
69 Commits
3 Forks
2 Watching
1 Branches
1 Contributors
Updated on 13 Sept 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-70%
9
Compared to previous day
Last week
-78%
51
Compared to previous week
Last month
4%
519
Compared to previous month
Last year
13.3%
3,265
Compared to previous year
41
Install | License | Usage | Contributing
Day.js Calendar Systems Plugin extends Day.js library to allow the use of different non-gregorian calendar systems like:
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.
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
NPM
1npm install --save @calidy/dayjs-calendarsystems
YARN
1yarn add --save @calidy/dayjs-calendarsystems
1import dayjs from "dayjs"; 2import calendarSystems from "@calidy/dayjs-calendarsystems"; 3 4// Note: Gregorian Calendar System is included by default, 5// so there is no need to import the `GregoryCalendarSystem` file here. 6 7import PersianCalendarSystem from "@calidy/dayjs-calendarsystems/calendarSystems/PersianCalendarSystem"; 8 9// ... 10// ALL YOU OTHER dayjs.extend() calls 11// ... 12// After all other dayjs plugins are initialized, extend dayjs with our calendar systems plugin: 13dayjs.extend(calendarSystems); 14 15// Register new calendar system 16dayjs.registerCalendarSystem("persian", new PersianCalendarSystem()); 17 18// Set default dayjs config (for all following instances) to a specific calendar system: 19// dayjs.toCalendarSystem("persian"); 20 21// Convert a dayjs instance to a specific calendar system. 22let date = dayjs().toCalendarSystem("persian"); 23 24// Convert a date from a specific calendar system without initializing a dayjs instance. 25date = dayjs.fromCalendarSystem('persian', 1402, 2, 17); 26
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.This project is DUAL LICENSED.
Please see the LICENSE.md file for details.
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.
If you have any issues or feature requests, please file issues and feature requests on the GitHub repo.
No vulnerabilities found.
No security vulnerabilities found.