jdate 0.1.0 copy "jdate: ^0.1.0" to clipboard
jdate: ^0.1.0 copied to clipboard

outdated

Simple yet flexible Dart Jalali date and time for developers.

logo
Simple yet flexible Dart Jalali date and time for developers

new JDate() #

new JDate() creates a new jalali date object with the current date and time:

var jd = JDate();
print(jd);

~~>    پنج‌شنبه، 15 اسفند 1398 ساعت 20:44:58

new JDate(year, month, ...) #

new JDate(year, month, ...) creates a new jalali date object with a specified date and time. 7 numbers specify year, month, day, hour, minute, second, and millisecond (in that order):

 JDate()                         ~~> پنج‌شنبه، 15 اسفند 1398 ساعت 20:44:58
 JDate(2019)                     ~~> سه‌شنبه، 11 دی 1397 ساعت 00:00:00
 JDate(2019, 4)                  ~~> چهارشنبه، 11 اردیبهشت 1398 ساعت 00:00:00
 JDate(2019, 4, 3)               ~~> جمعه، 13 اردیبهشت 1398 ساعت 00:00:00
 JDate(2019, 4, 3, 10)           ~~> جمعه، 13 اردیبهشت 1398 ساعت 10:00:00
 JDate(2019, 4, 3, 10, 33)       ~~> جمعه، 13 اردیبهشت 1398 ساعت 10:33:00
 JDate(2019, 4, 3, 10, 33, 30)   ~~> جمعه، 13 اردیبهشت 1398 ساعت 10:33:30

new JDate(year, month, ...) with shamsi date parameters #

You can creates a new jalali date object with a specified shamsi date and time.

 JDate()                         ~~> پنج‌شنبه، 15 اسفند 1398 ساعت 20:44:58
 JDate(1398)                     ~~> پنج‌شنبه، 01 فروردین 1398 ساعت 00:00:00
 JDate(1398, 1)                  ~~> یکشنبه، 01 اردیبهشت 1398 ساعت 00:00:00
 JDate(1398, 1, 13)              ~~> جمعه، 13 اردیبهشت 1398 ساعت 00:00:00
 JDate(1398, 1, 13, 3)           ~~> جمعه، 13 اردیبهشت 1398 ساعت 03:00:00
 JDate(1398, 1, 13, 3, 14)       ~~> جمعه، 13 اردیبهشت 1398 ساعت 03:14:00
 JDate(1398, 1, 13, 3, 14, 30)   ~~> جمعه، 13 اردیبهشت 1398 ساعت 03:14:30

new JDate(...).echo #

var jd = JDate(2019, 4, 3, 10, 33, 30, 0);
print(jd.echo('l، d F Y ساعت H:i:s'));

~~>     جمعه، 13 اردیبهشت 1398 ساعت 10:33:30
Character Description Range Example
aBefore noon and afternoonق.ظ - ب.ظق.ظ
bNumeric representation of a season, without leading zeros0-31
dDay of the month, 2 digits with leading zeros01-3113
fSeason nameبهار-زمستانبهار
g12-hour format of an hour without leading zeros0-1211
h12-hour format of an hour with leading zeros00-1203
iMinutes with leading zeros00-5913
jDay of the month without leading zeros1-314
lA full textual representation of the day of the weekشنبه-جمعهیکشنبه
mNumeric representation of a month, with leading zeros01-1202
nNumeric representation of a month, without leading zeros1-122
sSeconds, with leading zeros00-5903
tNumber of days in the given month0-3128
uMillisecond00000028
vShort year display in lettersیک-نهصد و نود و نهنود و هشت | چهارصد و دو
wNumeric representation of the day of the week0-66
yA two or three digit representation of a year1-99998 | 402
ABefore noon and afternoonبعد از ظهر - قبل از ظهرقبل از ظهر
DPersian ordinal suffix for the day of the month, 2 charactersشن‍ - جم‍سه
FA full textual representation of a monthفروردین - اسفنداردیبهشت
G24-hour format of an hour without leading zeros0-243
H24-hour format of an hour with leading zeros00-2403
JDay of the monthیک-سی و یکسیزده
LWhether it’s a leap year0-11
MA short textual representation of a month, two lettersفر-اس‍ار
ODifference to Greenwich time (GMT) in hours-1200 - +1400+0330
VFull year display in lettersصفر-...یک هزار و سیصد و نود و هشت
YA full numeric representation of a year, 4 digits0-...1398

JDate.parse(...) #

You can parse specified shamsi or gregorian date from valid date string to convert it to milliseconds.

JDate.parse('1399');                    ~~> 1584649800000 ~~> 1399/01/01 - 00:00:00
JDate.parse('1399/02');                 ~~> 1587324600000 ~~> 1399/02/01 - 00:00:00
JDate.parse('1399/02/13');              ~~> 1588361400000 ~~> 1399/02/13 - 00:00:00
JDate.parse('1399/02/13 03:14:30');     ~~> 1588373070000 ~~> 1399/02/13 - 03:14:30
JDate.parse('2019/05/03 01:02:03');     ~~> 1556829123000 ~~> 1398/02/13 - 01:02:03

Get JDate Methods #

These methods can be used for getting information from a jalali date object:

Method Description
getDate()Get the day as a number (1-31)
getDay()Get the weekday as a number (0-6)
getFullYear()Get the year as a four digit number (yyyy)
getShortYear()Get the year as a two or three digit number (yy | yyy)
getHours()Get the hour (0-23)
getMilliseconds()Get the millisecond (0-999)
getMinutes()Get the minute (0-59)
getMonth()Get the month as a number (0-11)
getSeconds()Get the second (0-59)
getTime()Get the time (milliseconds)
getTimezone()Difference to Greenwich time (GMT) in hours
getTimezoneOffset()Difference between UTC and Local Time
isLeapYear()Whether it’s a leap year (0-1)

Set JDate Methods #

These methods can be used for set date values (years, months, days, hours, minutes, seconds, milliseconds) for a jalali date object:

Method Description
setDate(date)Set the day as a number (1-31)
setMonth(month, date)Set the month (0-11)
setFullYear(year, month, date)Set the year (optionally month and day)
setHours(hours, min, sec, ms)Set the hour (0-23)
setMilliseconds(ms)Set the milliseconds (0-999)
setMinutes(min, sec, ms)Set the minutes (0-59)
setSeconds(sec, ms)Set the seconds (0-59)
setTime(ms)Set the time (milliseconds)

License #

JDate.js is available under the MIT license.

This library written based on JDate.js by Reza Moghaddam.
Date Conversion methods based on Roozbeh Pournader and Mohammad Toossi work

15
likes
0
pub points
74%
popularity

Publisher

verified publisheramiralitaheri.ir

Simple yet flexible Dart Jalali date and time for developers.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on jdate