jalali_date 1.3.4
jalali_date: ^1.3.4 copied to clipboard
Persian (Jalali, Shamsi, Solar Hijri) and lunar Hijri calendars for Dart and Flutter: conversion, date arithmetic, parsing, formatting with Persian names and digits. Pure Dart.
1.3.4 #
Changed #
- README: Flutter in the headline, links to the docs site and the Persian guide, a Support section.
- pub.dev topics:
flutterreplaceskhorshidi.
1.3.2 #
Changed #
- Faster lunar Hijri dates after the official record: month starts predicted through Dhu al-Hijjah 1550 (past Jalali 1500) are stored, calculated in advance the same way, instead of being calculated on first use. The first
HijriDatein 1460 takes 0.3 ms instead of 4.7 ms, and a Hijri year after 1448 no longer costs a crescent calculation per month. Months after 1550 are still calculated. Every month start is the same as before. - The first
HijriDateno longer calculates four crescents to check the supported range: 0.2 ms instead of 16 ms. parseFormatandtryParseFormatreuse the regular expression of a pattern: 8 µs instead of 141 µs per call ford MMMM yyyy.- Faster
format,toPersianDigits, andtoLatinDigits. - The VSOP87, nutation, and Moon tables are stored as flat number lists, so web builds that use
nowruzMomentare about 1.9 KB smaller gzipped.
1.3.1 #
Changed #
- README: the introduction, in English and Persian, lists the 1.3.0 features and says that holidays come from iranian_holidays, calculated offline or fetched online. "Building a date picker" points to jalali_calendar_picker, the notes for code generators cover the new APIs, and the API reference on nodets.com is linked.
1.3.0 #
Added #
PersianDate.nowruzMoment: the March equinox that begins a Jalali year (سال تحویل), in UTC, from VSOP87 with observed Delta T; within 4 seconds of every moment the University of Tehran announced from 2003 to 2026.PersianDate.parseFormatandtryParseFormat: read text written with aformatpattern, such as۴ فروردین ۱۴۰۳withd MMMM yyyy, including Persian, Latin, and Dari month names, weekday names,aandBfor 12-hour times, Persian and Arabic-Indic digits, and Arabic letters.dayPeriodand theBandBBBBformat tokens: the part of the day in Persian (صبح,ظهر,عصر,شب) on CLDR's hours, soformat('h B')gives4 عصر.toPersianWords: numbers in Persian words,هزار و چهارصد و سه, and ordinals withordinal: true,بیست و چهارم.formattokensdw(ordinal day in words) andyw(year in words, followingera) onPersianDateandHijriDate:format('EEEE dw MMMM yw')givesچهارشنبه بیست و چهارم مرداد هزار و چهارصد و سه.relativeToandfromNow: relative time in Persian such asدیروز,3 روز پیش, andماه آینده, with the CLDR words thatIntl.RelativeTimeFormat('fa')uses,numeric, andpersianDigits.differenceInMonthsanddifferenceInYears: whole Jalali months and years between two dates, counted likeaddMonths, sodate.addMonths(n).differenceInMonths(date) == n.
Fixed #
- Hijri month starts from Muharram 1265 (1848) to Shawwal 1448 (Jalali 1405/12) follow Iran's official record, the calendars of the University of Tehran's Calendar Center from 1423 on and historical sources before that, as collected by the qamari project. 282 months start a day earlier or later than before, 17 of them since 1423, for example Jumada al-Ula 1448 now starts on 1405/07/20 as on the published calendar instead of 1405/07/21.
HijriDatevalues in those months move by a day. - Where the crescent was seen on a different day than the calendar had predicted, the day it was seen counts: Ramadan 1432 starts on 1390/05/11.
Changed #
- The README explains the leap-year rule and where other software differs, from 1502 on.
dw,yw,B, andBBBBare nowformattokens. Quote them to keep them literal:format("'B'").
1.2.1 #
Changed #
- The package description and the README introduction mention the lunar Hijri calendar and Shahanshahi years.
1.2.0 #
Added #
JalaliErawithsolarHijriandshahanshahi, and aneraparameter onformat,toString,PersianDate.parse, andPersianDate.tryParse: the year is written and read as Solar Hijri (1405) or Shahanshahi (2585). The storedyearstays Solar Hijri.shahanshahiYear:yearplus 1180.HijriDate: the lunar Hijri date as Iran's official calendar counts it, with validation (ArgumentError), equality, ordering,monthName,monthLength,weekday,weekdayName,format,toPersianDate,toDateTime,HijriDate.min, andHijriDate.max.IranianHijri: the calendar behindHijriDate, moved fromjalali_holidays(nowiranian_holidays), withmonthStart,monthLength,date, andmonthStartsfor announced month starts.PersianDate.toHijri(),HijriDate.fromPersianDate,HijriDate.fromDateTime, andDateTime.toHijriDate().
1.1.0 #
Added #
- Date arithmetic:
addDays,addMonths,addYears(months and years clamp the day), anddifferenceInDays. - Comparisons:
isBefore,isAfter,isSameDay,isSameMonth,isSameYear,isToday, and the<,<=,>,>=operators. - Calendar anchors:
firstDayOfMonth,lastDayOfMonth,firstDayOfYear,lastDayOfYear,dayOfYear,daysInYear,quarter,season,seasonName, andseasonNames. - Persian week:
weekdayPersian(1 is Saturday),weekdayNameShort,weekdayNamesShort,isWeekend(Friday),startOfWeek,endOfWeek, andweekOfYear. - Parsing:
PersianDate.parseandPersianDate.tryParseforyyyy/MM/ddandyyyy-MM-ddstrings with an optional time and Persian or Arabic-Indic digits. - Persian digits:
toPersianDigits,toLatinDigits, and apersianDigitsflag ontoStringandformat. - Bounds and copies:
PersianDate.min,PersianDate.max, andcopyWith. - Time of day:
hasTime,hour,minute,second, andPersianDate.withTime. - JSON:
toJsonandPersianDate.fromJson. DateTime.toPersianDate()extension.formattokensE,D,Q,hh,h, anda, and single-quote escaping for literal text.- Latin names:
monthNameLatin,weekdayNameLatin,monthNamesLatin, andweekdayNamesLatin. - Dari month names used in Afghanistan:
monthNameDariandmonthNamesDari. daysUntilandPersianDateRangefor day sequences and range pickers.- README: Persian introduction, search keywords, a full quick reference, a date picker recipe, and notes for code generators.
Changed #
formattreats a single quote as the start of literal text, anda,E,D,Q,h, andhhare now tokens. Quote them to keep them literal.weekdayis computed from the day number instead of building aDateTime; the values are unchanged.- Homepage moved to https://nodets.com/jalali.
1.0.0 #
Breaking #
- Requires Dart 3. The Flutter dependency is gone; the package is pure Dart.
- The
ldfield and the publicmonthsLengthandkabiseMonthsLengthtables are removed. year,month, anddayare final;greToJalis no longer public.toStringpads the date toyyyy/MM/ddand the time toHH:mm:ss.PersianDate(year, month, day)validates its arguments and throwsArgumentError.toStringthrowsArgumentErrorinstead of a genericExceptionwhen nothing would be shown.
Fixed #
- Gregorian to Jalali conversion is correct for Gregorian century years and across Jalali leap cycles (port of jalaali-js).
Added #
toDateTime()for Jalali to Gregorian conversion.isLeapYearandmonthLength.- Equality on
(year, month, day)andComparableordering. monthName,monthNames,weekday,weekdayName, andweekdayNames.showHour,showMinute, andshowSecondflags ontoString.format(pattern)for custom date strings.
0.0.1 July 10 2018 #
- Convert Gregorian date to Jalali date