Idate
Iranian Date constractor for Javascript, Just like native Javascript Date.
Install / Use
/learn @nainemom/IdateREADME
IDate
Iranian Date constractor for Javascript, Just like native javascript Date.
Date convertor functions hard copied from
jalaali-js
Installation
npm install idate --save
# or
yarn add idate
Browser
<head>
<script src="path/to/idate/dist/idate.js"></script>
<!-- or -->
<script src="path/to/idate/dist/idate.min.js"></script>
</head>
Node, ESM
import IDate from 'idate'
// or
const IDate = require('idate')
Initialization
For initializing IDate you may either pass parameteres of Jalali date to it just like native Date. Other type of params like Date || IDate object or ISOString or Milliseconds also supported.
new IDate()
new IDate(milliseconds)
new IDate(gregorianDateString)
new IDate(jalaliYear, jalaliMonth, jalaliDay, hours, minutes, seconds, milliseconds)
API
const date = new IDate(1396, 5, 5)
// Getters
date.getFullYear() // 1396
date.getMonth() // 5 (indexed from zero, so 5 is شهریور)
date.getDate() // 5 (day in month)
date.getDay() // 4 (day of week started from saturday and indexed from zero, so 4 is چهارشنبه)
// Setters
date.setFullYear(1371)
date.setMonth(6)
date.setDate(1)
// Formated output
date.toString(persianString = true) // چهارشنبه ۱ مهر ۱۳۷۱ ساعت ۰۰:۰۰:۰۰ or Chaharshanbe 1 Mehr 1371 00:00:00
date.toISOString() // 1992-09-22T20:30:00.000Z
Difference with native Date?
IDate is an instance of native Date. All methods act just like the native API, so you can send IDate by AJAX libs to server or run JSON.stringify on it. Everything else works as well. It will also automatically convert to ISO.
Related Skills
node-connect
343.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
90.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
