New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

jalali-date

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jalali-date

A Jalali to Gregorian converter with support of formatting output

latest
Source
npmnpm
Version
1.2.0
Version published
Weekly downloads
46
21.05%
Maintainers
0
Weekly downloads
 
Created
Source

JDate

Build Status NPM Version NPM License

A Jalali to Gregorian converter in JavaScript with support of formatting output

Installation

Install via NPM/Yarn:

npm install jalali-date

You could grab the latest version from lib directory and use it:

<head>
  <script src="jdate.js" type="text/javascript" charset="utf-8"></script>
  <script src="jdate.min.js" type="text/javascript" charset="utf-8"></script>
</head>

The full-version is useful for debugging. You may want to use minified version in production as it is smaller.

Initialization

For initializing JDate you may either pass an array of Jalali date to it or a Date object. If no parameter is passed, the default is today:

const JDate = require('jalali-date');
const jdate = new JDate; // => default to today
const jdate2 = new JDate(1393, 10, 11);
const jdate3 = new JDate([1393, 10, 11]);
const jdate4 = new JDate(new Date(2014, 1, 3));

API

jdate.date //=> [1393, 5, 13] An Array of Jalali Date
jdate._d // => Gregorian Date Object

// Getters
jdate.getFullYear() // => 1393
jdate.getMonth() // => 5
jdate.getDate() // => 13
jdate.getDay() // => 1

// Setters
jdate.setFullYear(1394)
jdate.setMonth(6)
jdate.setDate(12)

// Formatting output
jdate.format('dddd DD MMMM YYYY') // => پنج‌شنبه 12 شهریور 1394

// Static functions
JDate.isLeapYear(1393) // => false
JDate.daysInMonth(1393, 5) // => 31
JDate.toGregorian(1393, 12, 11) // => Gregorian Date object
JDate.toJalali(new Date) // => JDate object

Formatting output

Use format() and following conversion identifiers as follows:

date.format('dddd DD MMMM YYYY') //=> دوشنبه 6 امرداد 1393

The conversion identifiers are as follows:

IdentifierDescriptionExample
YYY or YYYYFull Year (4 digits)1393
YYYear (2 digits)93
MMonth in numberreturns 5 for امرداد
MMMonth in numberreturns 05 for امرداد
MMM or MMMMMonth in stringامرداد
DDay in number26
DDDay in number06
d or ddAbbreviation of day name in string۱ش (for یکشنبه)
ddd or ddddFull day name in stringیکشنبه

Contribute

Report bugs and suggest feature in issue tracker. Feel free to Fork and send Pull Requests.

License

MIT

Keywords

jalali

FAQs

Package last updated on 15 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts