Jalali class

Jalali (Jalaali, Shamsi or Persian) Date class

Date objects are required to be immutable

Dates should be uniquely specified by year, month and day Or by using julian day number

Date objects are valid dates once constructed, It should throw exception when there is a validity or calculation problem

For example constructing date with day being out of month length or date being out of computable region throws DateException

Inheritance
Available extensions

Constructors

Jalali(int year, [int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0, int millisecond = 0])
Create a Gregorian date by using year, month and day
factory
Jalali.fromDateTime(DateTime dateTime)
Create a Jalali date by using DateTime object
factory
Jalali.fromGregorian(Gregorian date)
Create a Jalali date from Gregorian date
factory
Jalali.fromJulianDayNumber(int julianDayNumber, [int hour = 0, int minute = 0, int second = 0, int millisecond = 0])
Converts the Julian Day number to a date in the Jalali calendar.
factory
Jalali.fromMillisecondsSinceEpoch(int milliseconds, {bool isUtc = false})
Create a Jalali date from milliseconds since epoch
factory
Jalali.now()
Get Jalali date for now
factory

Properties

day int
Jalali day (1 to 29/31)
final
formatter JalaliFormatter
Formatter for this date object
no setteroverride
hashCode int
hashcode operator
no setterinherited
hour int
Hour 0..23
final
julianDayNumber int
Julian Day Number
final
millisecond int
Milliseconds 0..999
final
millisecondsSinceEpoch int

Available on Jalali, provided by the JalaliExt extension

Convert Jalali to milliseconds since epoch
no setter
minute int
Minute 0..59
final
month int
Jalali month (1 to 12)
final
monthLength int
Computes number of days in a given month in a Jalali year.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
second int
Second 0..59
final
time Duration
Returns the time part as Duration.
no setterinherited
weekDay int
Week day number Shanbe = 1 Jomee = 7
no setteroverride
year int
Jalali year (1 to 3100)
final

Methods

add({int years = 0, int months = 0, int days = 0, int hours = 0, int minutes = 0, int seconds = 0, int milliseconds = 0}) Jalali
makes a new date instance and add days, months and years separately
override
addDays(int days) Jalali
makes a new date object with added days to this date
override
addHours(int hours) Jalali

Available on Jalali, provided by the JalaliExt extension

Adds the specified number of hours to the current Jalali date.
addMonths(int months) Jalali
Makes a new date object with added months to this date
override
addYears(int years) Jalali
Makes a new date object with added years to this date
override
compareTo(Date other) int
Compare dates
inherited
copy({int? year, int? month, int? day, int? hour, int? minute, int? second, int? millisecond}) Jalali
Copy this date object with some fields changed
override
copyWith({int? year, int? month, int? day, int? hour, int? minute, int? second, int? millisecond}) Jalali

Available on Jalali, provided by the JalaliExt extension

copyWith method to allow partial updates to a Jalali instance
datePickerMediumDate() String

Available on Jalali, provided by the JalaliExt extension

formats
distanceFrom(Date other) int
distance between two dates
inherited
distanceTo(Date other) int
distance between two dates
inherited
formatCompactDate() String

Available on Jalali, provided by the JalaliExt extension

formatFullDate() String

Available on Jalali, provided by the JalaliExt extension

formatMediumDate() String

Available on Jalali, provided by the JalaliExt extension

formatMonthYear() String

Available on Jalali, provided by the JalaliExt extension

formatShortDate() String

Available on Jalali, provided by the JalaliExt extension

formatShortMonthDay() String

Available on Jalali, provided by the JalaliExt extension

formatYear() String

Available on Jalali, provided by the JalaliExt extension

isAfter(Jalali date) bool

Available on Jalali, provided by the JalaliExt extension

isAtSameMomentAs(Jalali other) bool

Available on Jalali, provided by the JalaliExt extension

isBefore(Jalali date) bool

Available on Jalali, provided by the JalaliExt extension

isLeapYear() bool
Checks if a year is a leap year or not
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDateTime() DateTime
Converts Jalali date to DateTime object
override
toGregorian() Gregorian
Converts a Jalali date to Gregorian.
toJalaliDateTime() String

Available on Jalali, provided by the JalaliExt extension

toString() String
Default string representation: Jalali(year, month, ...). use formatter for custom formatting.
override
toUtcDateTime() DateTime
Converts Jalali date to DateTime object
override
withDay(int day) Jalali
Make a new date object with changed day
override
withMonth(int month) Jalali
Make a new date object with changed month
override
withYear(int year) Jalali
Make a new date object with changed year
override

Operators

operator +(int days) Jalali
Add days
override
operator -(int days) Jalali
Subtract days
override
operator <(Date other) bool
less than operator
inherited
operator <=(Date other) bool
less than or equal operator
inherited
operator ==(Object other) bool
equals operator
inherited
operator >(Date other) bool
bigger than operator
inherited
operator >=(Date other) bool
bigger than or equal operator
inherited
operator ^(Date other) int
distance between two dates
inherited

Constants

max → const Jalali
Maximum computable Jalali date
min → const Jalali
Minimum computable Jalali date