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
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
andday
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 - 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
= 1Jomee
= 7no 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
andyears
separatelyoverride -
addDays(
int days) → Jalali -
makes a new date object with
added
days
to this dateoverride -
addMonths(
int months) → Jalali -
Makes a new date object with
added
months
to this dateoverride -
addYears(
int years) → Jalali -
Makes a new date object with
added
years
to this dateoverride -
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
-
distanceFrom(
Date other) → int -
distance between two dates
inherited
-
distanceTo(
Date other) → int -
distance between two dates
inherited
-
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.
-
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