dayjalali
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

dayjalali

npm (scoped with tag) npm TypeScript CircleCI Codecov Dependencies js-standard-style

Persian (Jalali, Khorshidi) Calendar Plugin for Day.js with full TypeScript support. This plugin adds multi-calendar functionality to Day.js core, allowing seamless switching between Gregorian and Jalali calendars regardless of locale.

Key Features:

  • 🎯 Full TypeScript Support
  • 🔄 Seamless Calendar Switching
  • 📅 Standard Format Support
  • 🌐 Multi-language Support
  • ⚡ Lightweight and Immutable
  • 🐛 Fixed Leap Year Calculations

📖 Release Notes

Installation

# NPM
npm install --save dayjalali

# YARN
yarn add dayjalali

# PNPM
pnpm add dayjalali

Usage

import dayjs from 'dayjs'
import dayjalali from 'dayjalali'

dayjs.extend(dayjalali)

Calendar Management

// Set default calendar
dayjs.calendar('jalali')  // Jalali Calendar
dayjs.calendar('gregory') // Gregorian Calendar

// Create a jalali date instance
const date = dayjs()
const jalaliDate = date.calendar('jalali')

Date Parsing

// Parse Gregorian date
const gregDate = dayjs('2024-03-20T16:00:00.000Z')

// Parse Jalali date
const jalaliDate = dayjs('1403-01-01', { jalali: true })

Multi-language Support

// Jalali calendar with English locale
dayjs().calendar('jalali').locale('en').format('DD MMMM YYYY')
// Output: '01 Farvardin 1403'

// Gregorian calendar with Persian locale
dayjs().calendar('gregory').locale('fa').format('DD MMMM YYYY')
// Output: '20 مارس 2024'

API

All Api operations of dayjalali is same as Dayjs itself but calendar based, for more information checkout Dayjs API For a glance:

Package Sidebar

Install

npm i dayjalali

Weekly Downloads

7

Version

1.0.1

License

MIT

Unpacked Size

77.2 kB

Total Files

9

Last publish

Collaborators

  • sedmedgh