Date class
- Implemented types
Constructors
- Date(int year, [int month = 1, int day = 1])
-
Creates a date only.
The
year
month
day
. - Date.fromDateTime(DateTime dateTime)
- Creates a time of day based on the given time.
- Date.fromMicrosecondsSinceEpoch(int microsecondsSinceEpoch, {bool isUtc = false})
- Date.fromMillisecondsSinceEpoch(int millisecondsSinceEpoch, {bool isUtc = false})
- Date.now()
-
Creates a day date based on the current time.
factory
- Date.tomorrow()
-
Creates a tomorrow date based on the current time.
factory
- Date.withFields({required int year, int month = 1, int day = 1})
- Date.yesterday()
-
Creates a yesterday date based on the current time.
factory
Properties
- day → int
-
no setter
- firstDayOfMonth → Date
-
no setter
- firstDayOfWeek → Date
-
no setter
- formatApiDay → String
-
yyyy-MM-dd
no setter
- formatDay → String
-
dd
no setter
- formatFirstDay → String
-
MMM dd
no setter
- formatFullDay → String
-
EEE MMM dd, yyyy
no setter
- formatMonth → String
-
MMMM yyyy
no setter
- formatMonthOnly → String
-
MMMM
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- isFirstDayOfMonth → bool
-
no setter
- isFuture → bool
-
is after now
no setter
- isLastDayOfMonth → bool
-
no setter
- isPast → bool
-
is before now
no setter
- isToday → bool
-
is equal to the same day
no setter
- isTomorrow → bool
-
is equal to the next day
no setter
- isYesterday → bool
-
is equal to the last day
no setter
- lastDayOfMonth → Date
-
The last day of a given month
no setter
- microsecondsSinceEpoch → int
-
The number of microseconds since
the "Unix epoch" 1970-01-01T00:00:00Z (UTC).
no setter
- millisecondsSinceEpoch → int
-
no setter
- month → int
-
no setter
- nextMonth → Date
-
The previousMonth
no setter
- previousMonth → Date
-
The previousMonth
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- timeZoneName → String
-
The time zone name.
no setter
- timeZoneOffset → Duration
-
The time zone offset, which
is the difference between local time and UTC.
no setter
- weekday → int
-
The day of the week
monday
..sunday
.no setter - year → int
-
no setter
Methods
-
add(
dynamic other) → Date - Add 2 dates
-
compareTo(
Date other) → int -
Compares this object to another object.
override
-
copyWith(
{int? year, int? month, int? day}) → Date - Returns a new TimeOfDay with the hour and/or minute replaced.
-
difference(
dynamic other) → Duration - Get difference duration between 2 dates
-
equals(
Date other) → bool - Whether or not two times are on the same day. === isSameAs(other)
-
format(
[String? dateFormat]) → String - Returns the localized string representation of this time of day.
-
formatWithDateFormat(
[DateFormat? dateFormat]) → String -
isAfter(
Date other) → bool -
isBefore(
Date other) → bool -
isEqualOrAfter(
Date other) → bool -
isEqualOrBefore(
Date other) → bool -
isSameAs(
Date other) → bool - Whether or not two times are on the same day.
-
isSameMonth(
Date other) → bool - Whether or not two times are on the same month.
-
isSameWeek(
Date other) → bool - Whether or not two times are on the same week.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
subtract(
dynamic other) → Date - subtract 2 dates
-
toDateTime(
[TimeOfDay? time]) → DateTime -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator +(
dynamic other) → Date -
operator -(
dynamic other) → Date -
operator <(
Date other) → bool -
operator <=(
Date other) → bool -
operator ==(
Object other) → bool -
The equality operator.
override
-
operator >(
Date other) → bool -
operator >=(
Date other) → bool
Static Properties
- defaultDateFormat ↔ String
-
getter/setter pair
Static Methods
-
daysInMonth(
Date monthDate) → List< Date> - The list of days in a given month
-
daysInRange(
Date start, Date end) → Iterable< Date> -
getFirstDayOfMonth(
Date date) → Date -
getLastDayOfMonth(
Date date) → Date -
getLastDayOfWeek(
Date day) → Date -
getNextMonth(
Date m) → Date - The nextMonth
-
getPreviousMonth(
Date m) → Date - The previousMonth
-
nextWeek(
Date w) → Date - The nextWeek
-
parse(
String formattedString, {String? dateFormat}) → Date -
previousWeek(
Date w) → Date - The previousWeek
-
tryParse(
String formattedString) → Date? -
Constructs a new DateTime instance based on
formattedString
.
Constants
- maxDaysPerMonth → const int
- monthsPerYear → const int