Date class

Date object

Constructors

Date({required int year, int month = 1, int day = 1})
Initialize Date object
const
Date.from(DateTime dt)
Date.now()
Constructs a Date instance with current date in the local time zone.
factory
Date.nowUtc()
Constructs a Date instance with current date in the UTC time zone.
factory
Date.today()
Today
factory
Date.tomorrow()
Tomorrow
factory
Date.yesterday()
Tomorrow
factory

Properties

asDateTime DateTime
no setter
asUtcDateTime DateTime
no setter
day int
Day
final
endOfDay DateTime
Return the end of day in DateTime
no setter
endOfISOWeek Date
Return the end of ISO week for this date. The result will be in the local timezone.
no setter
endOfMonth Date
Return the end of the month for this date. The result will be in the local timezone.
no setter
endOfQuarter Date
End of quarter
no setter
endOfWeek Date
Return the end of the week for this date. The result will be in the local timezone.
no setter
endOfWeekend Date
Get a Date representing end of weekend of this Date in local time.
no setter
endOfYear Date
Return the end of the year for this date. The result will be in the local timezone.
no setter
getDAY DAY
Return enum value of day of week
no setter
getISOWeek int
Get the ISO week index
no setter
getMONTH MONTH
Get the enum value of month
no setter
getMonth Month
Return the Month object for this date.
no setter
getWeek int
Get the week index
no setter
getYear Year
Return the Year object for this date.
no setter
hashCode int
The hash code for this object.
no setteroverride
isFirstDayOfMonth bool
Is the given date the first day of a month?
no setter
isFriday bool
Return true if this date day is friday
no setter
isFuture bool
Return true if this date isAfter Date.now
no setter
isLastDayOfMonth bool
Is the given date the last day of a month?
no setter
isLeapYear bool
Is the given date in the leap year?
no setter
isMonday bool
Return true if this date day is monday
no setter
isoWeek Week
Return the iso Week object for this date
no setter
isPast bool
Return true if this date isBefore Date.now
no setter
isSaturday bool
Return true if this date day is saturday
no setter
isSunday bool
Return true if this date day is sunday
no setter
isThisIsoWeek bool
Check if this date is in the same month than Date.today
no setter
isThisMonth bool
Check if this date is in the same month than Date.today
no setter
isThisQuarter bool
Check if this date is in the same month than Date.today
no setter
isThisWeek bool
Check if this date is in the same month than Date.today
no setter
isThisYear bool
Check if this date is in the same year than Date.today
no setter
isThursday bool
Return true if this date day is thursday
no setter
isToday bool
Check if this date is in the same day than Date.today
no setter
isTomorrow bool
Check if this date is in the same day than Date.today
no setter
isTuesday bool
Return true if this date day is tuesday
no setter
isWednesday bool
Return true if this date day is wednesday
no setter
isWeekend bool
Return true if this DateTime is a saturday or a sunday
no setter
isYesterday bool
Check if this date is in the same day than Date.today
no setter
key String
/////////////////////////////// KEY Convert Date to a unique id
no setter
month int
Month
final
nextDay Date
The day after this Date
no setter
nextMonth Date
The month after this Date
no setter
nextWeek Date
The week after this Date
no setter
nextYear Date
The year after this Date
no setter
previousDay Date
The day previous this Date
no setter
previousMonth Date
The month previous this Date
no setter
previousWeek Date
The week previous this Date
no setter
previousYear Date
The year previous this Date
no setter
quarter int
Quarter 1-4
no setter
quarterEndMonth int
Quarter end month
no setter
quarterStartMonth int
Quarter start month
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
startOfDay DateTime
Return the start of day in DateTime
no setter
startOfISOWeek Date
Get a Date representing start of week (ISO week) of this Date in local time.
no setter
startOfMonth Date
Get a Date representing start of month of this Date in local time.
no setter
startOfQuarter Date
Start of quarter
no setter
startOfWeek Date
Get a Date representing start of week of this Date in local time.
no setter
startOfWeekend Date
Get a Date representing start of week of this Date in local time.
no setter
startOfYear Date
Get a Date representing start of year of this Date in local time.
no setter
week Week
Return a non iso Week object for this date
no setter
weekday int
no setter
withoutSeparator String
no setter
year int
Year
final
yearOfISOWeek int
Returns the year for this Date ISO week
no setter
yearOfWeek int
Returns the year of this Date's week
no setter

Methods

add(Duration duration) Date
Add a Duration to this date
addDays(int amount) Date
Add days
addMonths(int amount) Date
Add a certain amount of months to this date
addQuarters(int amount) Date
Add a certain amount of quarters to this date
addWeeks(int amount) Date
Add a certain amount of weeks to this date
addYears(int amount) Date
Add a certain amount of years to this date
compareTo(Date other) int
////////////////////////////////// COMPARISON
copyWith({int? year, int? month, int? day}) Date
difference(Date other) int
////////////////////////////////// OPERATIONS Return the difference in days
format([String pattern = 'yMd', String? locale]) String
Convenient method to DateFormat
isAfter(Date other) bool
isBefore(Date other) bool
isOutsideRange(Date start, Date end) bool
Check if the date is out side start and end
isSameDay(Date other) bool
Check if this date is in the same day than other
isSameISOWeek(Date other) bool
Check if this date is in the same iso week than other
isSameMonth(Date other) bool
Check if this date is in the same month than other
isSameOrAfter(Date other) bool
Return true if other isEqual or isAfter to this date
isSameOrBefore(Date other) bool
Return true if other isEqual or isBefore to this date
isSameQuarter(Date other) bool
Check if this date is in the same quarter
isSameWeek(Date other) bool
Check if this date is in the same week than other
isSameYear(Date other) bool
Check if this date is in the same year than other
isWithinRange(Date start, Date end) bool
Check if the date is within start and end
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setDay(int day) Date
setMonth(int month) Date
setYear(int year) Date
subDays(int amount) Date
Subtracts an amount of days from this Date
subMonths(int amount) Date
Subtracts an amount of months from this Date
subQuarters(int amount) Date
Add a certain amount of quarters to this date
subtract(Duration duration) Date
Subtract a Duration to this date
subWeeks(int amount) Date
Subtracts an amount of weeks from this Date
subYears(int amount) Date
Subtracts an amount of years from this Date
toString() String
A string representation of this object.
override
withSeparator(String separator) String

Operators

operator <(Date other) bool
Less than
operator <=(Date other) bool
Less than or equal
operator ==(Object other) bool
The equality operator.
override
operator >(Date other) bool
Greater than
operator >=(Date other) bool
Greater than or equal

Static Methods

fromKey(String key) Date?
Convert a unique id to Date
parse(String dateStr, {String? format, bool utc = false}) Date
Constructs a new DateTime instance based on dateStr.
tryParse(String dateStr, {String? format, bool utc = false}) Date?
Constructs a new DateTime instance based on dateStr.

Constants

endOfTime → const Date
Const value to signify the end of time that can be used as a default value
epoch → const Date
Const value to signify the start of epoch that can be used as a default value
startOfTime → const Date
Const value to signify the start of time that can be used as a default value