Date class
A calendar date in the proleptic Gregorian calendar.
Uses an UTC DateTime for all calculations, so has the same behavior and limits as that.
- Implemented types
- Available extensions
Constructors
- Date.new(int year, [int month = 1, int day = 1])
-
Calendar date of the
year
,month
andday
. - Date.from(DateTime dateAndTime)
-
The calendar date of the
dateAndTime
. - Date.fromDaysSinceZero(int days)
-
Date of
days
since 0000-01-01. - Date.fromJulianDay(int julianDay)
-
Date of the
julianDay
th Julian Day. - Date.lastDateAs(int weekday)
-
factory
- Date.parse(String formattedDate)
-
Parses a formatted date.
factory
- Date.today()
- Today's date.
Properties
- day → int
-
Day in month.
no setter
- dayInYear → int
-
Day in year.
no setter
- daysInMonth → int
-
The number of days in the current month.
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- isLeapYear → bool
-
Whether this year is a leap-year.
no setter
- isToday → bool
-
Available on Date, provided by the DateExtension extension
no setter - julianDay → int
-
Julian day of the day.
no setter
- millisecondsSinceEpoch → int
-
no setter
- month → int
-
Calendar month.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sundayBefore → Date
-
Available on Date, provided by the DateExtension extension
no setter - weekday → int
-
no setter
- weekOfYear → int
-
no setter
- year → int
-
Calendar year.
no setter
Methods
-
add(
{int years = 0, int months = 0, int days = 0}) → Date - Modifies the year, month and day by adding to their values.
-
addDays(
int days) → Date -
A calendar date
days
later than this one, or earlier ifdays
is negative. -
buildWeekRange(
{int startWeekday = DateTime.monday}) → DateRange -
Available on Date, provided by the DateExtension extension
-
compareTo(
Date other) → int -
Compares this object to another object.
override
-
dayDifference(
Date other) → int -
The number of whole days from this date to
other
. -
difference(
Date other) → Duration -
Returns a Duration of the time between
this
andother
. -
formatBy(
DateFormat dateFormat) → String -
Available on Date, provided by the DateExtension extension
-
formated(
) → String -
Available on Date, provided by the DateExtension extension
-
isAfter(
Date other) → bool -
Returns if this date is after
other
. -
isBefore(
Date other) → bool -
Returns if this date is before
other
. -
isBetween(
DateRange range) → bool -
Available on Date, provided by the DateExtension extension
-
isSameDayAs(
DateTime date) → bool -
Available on Date, provided by the DateExtension extension
-
lastDateAs(
int weekday, {bool returnIfToday = false}) → Date -
nextDateAs(
int weekday, {bool returnIfToday = false}) → Date -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDateString(
) → String - This date as a simple "year-month-day" string.
-
toDateTime(
{bool local = false}) → DateTime -
Creates a
DateTime
object with the current date, at midnight. -
toString(
) → String -
A string representation of this object.
override
-
update(
{int? year, int? month, int? day}) → Date - Updates the individual year, month or day to a new value.
Operators
-
operator <(
Date other) → bool -
Whether this date is strictly before
other
. -
operator <=(
Date other) → bool -
Whether this date is no later than
other
. -
operator ==(
Object other) → bool -
Whether this date is the same as
other
.override -
operator >(
Date other) → bool -
Whether this date is strictly after
other
. -
operator >=(
Date other) → bool -
Whether this date is no earlier than
other
.