Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

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

License

NotificationsYou must be signed in to change notification settings

arashm/JDate

Repository files navigation

Build StatusNPM VersionNPM 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 fromlib directory and use it:

<head><scriptsrc="jdate.js"type="text/javascript"charset="utf-8"></script><scriptsrc="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 initializingJDate you may either pass an array of Jalali date to it or aDate object. If no parameter is passed, the default is today:

constJDate=require('jalali-date');constjdate=newJDate;// => default to todayconstjdate2=newJDate(1393,10,11);constjdate3=newJDate([1393,10,11]);constjdate4=newJDate(newDate(2014,1,3));

API

jdate.date//=> [1393, 5, 13] An Array of Jalali Datejdate._d// => Gregorian Date Object// Gettersjdate.getFullYear()// => 1393jdate.getMonth()// => 5jdate.getDate()// => 13jdate.getDay()// => 1// Settersjdate.setFullYear(1394)jdate.setMonth(6)jdate.setDate(12)// Formatting outputjdate.format('dddd DD MMMM YYYY')// => پنج‌شنبه 12 شهریور 1394// Static functionsJDate.isLeapYear(1393)// => falseJDate.daysInMonth(1393,5)// => 31JDate.toGregorian(1393,12,11)// => Gregorian Date objectJDate.toJalali(newDate)// => JDate object

Formatting output

Useformat() and following conversion identifiers as follows:

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

The conversion identifiers are as follows:

IdentifierDescriptionExample
YYY orYYYYFull Year (4 digits)1393
YYYear (2 digits)93
MMonth in numberreturns5 forامرداد
MMMonth in numberreturns05 forامرداد
MMM orMMMMMonth in stringامرداد
DDay in number26
DDDay in number06
d orddAbbreviation of day name in string۱ش (for یکشنبه)
ddd orddddFull day name in stringیکشنبه

Contribute

Report bugs and suggest feature inissue tracker. Feel free toFork and sendPull Requests.

License

MIT

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp