Gregorian class
Gregorian (Miladi or Milaadi) 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
- Implemented types
Constructors
- Gregorian(int year, [int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0])
-
Create a Gregorian date by using
year
,month
andday
- Gregorian.fromDateTime(DateTime dateTime)
-
Create a Gregorian date by using DateTime object
factory
- Gregorian.fromJalali(Jalali date)
-
Create a Gregorian date from Jalali date
factory
- Gregorian.fromJulianDayNumber(int julianDayNumber)
-
Calculates Gregorian and Julian calendar dates from the Julian Day number
julianDayNumber
for the period since jdn=-34839655 (i.e. the year -100100 of both calendars) to some millions years ahead of the present.factory - Gregorian.now()
-
Get Gregorian date for now
factory
Properties
- day → int
-
Gregorian day of the month (1 to 28/29/30/31)
final
- formatter → GregorianFormatter
-
Formatter for this date object
no setteroverride
- hashCode → int
-
hashcode operator
no setteroverride
- hour → int
-
Hour
final
- julianDayNumber → int
-
Calculates the Julian Day number from Gregorian or Julian
calendar dates. This integer number corresponds to the noon of
the date (i.e. 12 hours of Universal Time).
no setteroverride
- minute → int
-
Minute
final
- month → int
-
Gregorian month (1 to 12)
final
- monthLength → int
-
Computes number of days in a given month in a Gregorian year.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- second → int
-
second
final
- weekDay → int
-
Week day number
monday
= 1sunday
= 7no setteroverride - year → int
-
Gregorian year (years BC numbered 0, -1, -2, ...)
final
Methods
-
add(
{int years = 0, int months = 0, int days = 0}) → Gregorian -
makes a new date instance and
add
days
,months
andyears
separatelyoverride -
addDays(
int days) → Gregorian -
makes a new date object with
added
days
to this dateoverride -
addMonths(
int months) → Gregorian -
Makes a new date object with
added
months
to this dateoverride -
addYears(
int years) → Gregorian -
Makes a new date object with
added
years
to this dateoverride -
compareTo(
Gregorian other) → int -
Compare dates
override
-
copy(
{int? year, int? month, int? day, int? hour, int? minute, int? second}) → Gregorian -
Copy this date object with some fields changed
override
-
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 Gregorian date to DateTime object
override
-
toJalali(
) → Jalali - Converts a Gregorian date to Jalali.
-
toString(
) → String -
Default string representation:
Gregorian(YYYY, MM, DD)
. use formatter for custom formatting.override -
withDay(
int day) → Gregorian -
Make a new date object with changed
day
override -
withMonth(
int month) → Gregorian -
Make a new date object with changed
month
override -
withYear(
int year) → Gregorian -
Make a new date object with changed
year
override
Operators
-
operator +(
int days) → Gregorian -
Add
days
override -
operator -(
int days) → Gregorian -
Subtract
days
override -
operator <(
Gregorian other) → bool - less than operator
-
operator <=(
Gregorian other) → bool - less than or equal operator
-
operator ==(
Object other) → bool -
equals operator
override
-
operator >(
Gregorian other) → bool - bigger than operator
-
operator >=(
Gregorian other) → bool - bigger than or equal operator