jalali_date library
Persian (Jalali, Shamsi, Khorshidi) calendar: conversion between Gregorian and Jalali dates, leap years, month lengths, and formatting with Persian month and weekday names.
The main type is the immutable PersianDate. PersianDateRange holds an
inclusive range of days, toPersianDigits and toLatinDigits convert
digits, JalaliEra picks Solar Hijri or Shahanshahi year numbers for
text, HijriDate and IranianHijri give the lunar Hijri date as Iran's
official calendar counts it, and DateTime.toPersianDate() and
DateTime.toHijriDate() convert a DateTime.
final date = PersianDate.fromGregorian(2021, 3, 21);
print(date); // 1400/01/01
print(date.format('EEEE d MMMM yyyy')); // یکشنبه 1 فروردین 1400
print(date.addMonths(1).toString(persianDigits: true)); // ۱۴۰۰/۰۲/۰۱
print(PersianDate.parse('1357/11/22').toDateTime()); // 1979-02-11 00:00:00.000
Classes
- HijriDate
- A day of the lunar Hijri (Islamic) calendar as Iran's official calendar counts it.
- IranianHijri
- The lunar Hijri calendar as Iran's official calendar uses it.
- PersianDate
- An immutable Jalali (Persian) calendar date.
- PersianDateRange
- An inclusive range of days from start to end.
Enums
- JalaliEra
- How Jalali years are numbered in text.
Extensions
- PersianDateTime on DateTime
- Converts a DateTime to a PersianDate or a HijriDate.
Functions
-
toLatinDigits(
String input) → String -
Replaces Persian (۰ to ۹) and Arabic-Indic (٠ to ٩) digits in
inputwith the ASCII digits 0 to 9. -
toPersianDigits(
String input) → String -
Replaces the ASCII digits 0 to 9 in
inputwith Persian digits ۰ to ۹. -
toPersianWords(
int number, {bool ordinal = false}) → String -
numberwritten in Persian words, for exampleهزار و چهارصد و سهfor 1403, or as an ordinal withordinal:بیست و چهارمfor 24.