DateRange class

Represents a range of dates.

Implemented types
Available extensions

Constructors

DateRange(date startDate, [date? endDate])
Creates a new instance of the DateRange class with the specified start and end dates.
DateRange.daysAfter(date date, int days)
Creates a DateRange representing the specified number of days after the specified date.
factory
DateRange.daysAgo(int days)
Creates a DateRange representing the specified number of days before today.
factory
DateRange.daysBefore(date date, int days)
Creates a DateRange representing the specified number of days before the specified date.
factory
DateRange.daysFromNow(int days)
Creates a DateRange representing the specified number of days after today.
factory
DateRange.duration(DateTime date, Duration duration)
DateRange.lastBimester()
Creates a DateRange representing the previous bimester.
factory
DateRange.lastMonth()
Creates a DateRange representing the previous month.
factory
DateRange.lastQuarter()
Creates a DateRange representing the previous quarter.
factory
DateRange.lastSemester()
Creates a DateRange representing the previous semester.
factory
DateRange.lastWeek()
Creates a DateRange representing the previous week.
factory
DateRange.lastYear()
Creates a DateRange representing the previous year.
factory
DateRange.nextBimester()
Creates a DateRange representing the next bimester.
factory
DateRange.nextMonth()
Creates a DateRange representing the next month.
factory
DateRange.nextQuarter()
Creates a DateRange representing the next quarter.
factory
DateRange.nextSemester()
Creates a DateRange representing the next semester.
factory
DateRange.nextWeek()
Creates a DateRange representing the next week.
factory
DateRange.nextYear()
Creates a DateRange representing the next year.
factory
DateRange.thisBimester()
Creates a DateRange representing the current bimester.
factory
DateRange.thisMonth()
Creates a DateRange representing the current month.
factory
DateRange.thisQuarter()
Creates a DateRange representing the current quarter.
factory
DateRange.thisSemester()
Creates a DateRange representing the current trimester.
factory
DateRange.thisWeek()
Creates a DateRange representing the current week.
factory
DateRange.thisYear()
Creates a DateRange representing the current year.
factory
DateRange.today()
Creates a DateRange representing today.
factory
DateRange.tomorrow()
Creates a DateRange representing tomorrow.
factory
DateRange.yesterday()
Creates a DateRange representing yesterday.
factory
DateRange.yesterdayToToday()
Creates a DateRange representing yesterday and today.
DateRange.yesterdayToTomorrow()
Creates a DateRange representing testerday, today and tomorrow.

Properties

duration Duration
Gets the duration of the date range.
no setter
endDate date
Gets the end date of the date range.
getter/setter pair
formatted String

Available on Duration, provided by the DurationExtensions extension

no setter
hashCode int
Returns the hash code for this DateRange object.
no setteroverride
inDays int
The number of entire days spanned by this Duration.
no setteroverride
inHours int
The number of entire hours spanned by this Duration.
no setteroverride
inMicroseconds int
The time offset of this duration in microseconds.
no setteroverride
inMilliseconds int
The number of whole milliseconds spanned by this Duration.
no setteroverride
inMinutes int
The number of whole minutes spanned by this Duration.
no setteroverride
inSeconds int
The number of whole seconds spanned by this Duration.
no setteroverride
isFuture bool
Returns true if the date range is in the future.
no setter
isNegative bool
Whether this Duration is negative.
no setteroverride
isNow bool
Returns true if today is in the date range.
no setter
isPast bool
Returns true if the date range is in the past.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
startDate date
Gets the start date of the date range.
getter/setter pair

Methods

abs() Duration
A positive Duration with the same absolute length as this Duration.
override
compareTo(Duration other) int
Compares this Duration to other.
override
contains(date date) bool
Returns true if yesterday is in the date range.
containsRange(DateRange range) bool
Checks if the date range contains the specified date range.
days() Iterable<DateTime>
Generates an iterable of DateTime objects representing each day within the date range.
delay<F>([FutureOr<F> callback()?]) Future<F>

Available on Duration, provided by the DurationExtensions extension

format({bool? includeMilliseconds, bool? includeMicroseconds}) string

Available on Duration, provided by the DurationExtensions extension

hours() Iterable<DateTime>
Generates an iterable of DateTime objects representing each hour within the date range.
intersects(DateRange range) bool
Checks if the date range intersects the specified date range.
minutes() Iterable<DateTime>
Generates an iterable of DateTime objects representing each minute within the date range.
months() Iterable<DateTime>
Generates an iterable of DateTime objects representing each month within the date range.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Returns a JSON-encodable representation of this DateRange object.
toString() String
Returns a string representation of this DateRange object.
override
weeks() Iterable<DateTime>
Generates an iterable of DateTime objects representing each week within the date range.
years() Iterable<DateTime>
Generates an iterable of DateTime objects representing each year within the date range.

Operators

operator *(num factor) DateRange
This Duration scaled by factor.
override
operator +(Duration other) DateRange
Adds this Duration and other and returns the sum as a new Duration object.
override
operator -(Duration other) DateRange
The offset of this duration minus the offset of other.
override
operator <(Duration other) bool
Whether this duration's offset is smaller than that of other.
override
operator <=(Duration other) bool
Whether this duration's offset is not greater than that of other.
override
operator ==(Object other) bool
Overrides the equality operator to compare the current DateRange object with another object. Returns true if the objects are equal, false otherwise. Checks if the current DateRange object is equal to the other object.
override
operator >(Duration other) bool
Whether this duration's offset is greater than that of other.
override
operator >=(Duration other) bool
Whether this duration's offset is not smaller than that of other.
override
operator unary-() Duration
The offset of this duration minus the offset of other.
override
operator ~/(int quotient) Duration
One-quotientth of this duration.
override