Period class

A period of time between two DateTimes.

Implemented types
Mixed in types
Implementers
Annotations

Constructors

Period({required DateTime start, required DateTime end})
Creates a period of time between two DateTimes.

Properties

duration Duration
The difference between the start and end plus one microsecond. If start and end are equal, returns Duration(microseconds: 1).
no setter
end DateTime
The end of the period. It is included in the period.
final
hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
If start and end are equal.
no setter
isNotEmpty bool
If start and end are different.
no setter
props List<Object?>
The list of properties that will be used to determine whether two instances are equal.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
start DateTime
The start of the period. It is included in the period.
final
stringify bool?
If set to true, the toString method will be overridden to output this instance's props.
no setterinherited

Methods

compareTo(Period other) int
Compares this object to another object.
override
containedFullyBy(Period other) bool
Returns true if this is contained fully by other.
containedPartiallyBy(Period other) bool
Returns true if this is contained partially by other.
contains(DateTime date) bool
Returns true if this contains the given date. If the date is equal to the start or end or is between the two dates, it will return true.
containsFully(Period other) bool
Returns true if this fully contains other.
containsPartially(Period other) bool
Returns true if this contains partially other.
copyWith({DateTime? start, DateTime? end}) Period
Returns a new Period with the given start and end values. If start or end are not provided, the corresponding value of this is used.
differenceBetween(Period other) List<Period>
Returns a list of Periods that are the difference between this and other.
doesNotOverlapWith(Period other) bool
Returns true if this does not overlap with other.
endsAfter(DateTime date) bool
Returns true if this ends after the given date.
endsBefore(DateTime date) bool
Returns true if this ends before the given date.
getDateTimeValues(DateTime? next(DateTime last)) List<DateTime>
Returns a list of DateTime values that are contained in this Period. The next function is used to calculate the DateTime values for the returned list. The next function is called with the last DateTime value, or start. The next function must return a DateTime value that is contained in this Period. The next function must return a DateTime value that is not after the end value of this Period. When the next function returns null, the iteration stops.
getIntersection(Period other) Period?
Returns a Period that is the intersection of this and other.
getNext<T extends Period>(PeriodGeneratorMixin<T> generator) → T
Returns a new Period that starts after this using generator.
getPrevious<T extends Period>(PeriodGeneratorMixin<T> generator) → T
Returns a new Period that starts before this using generator.
mergeWith(Period other) Period?
Returns a Period that is the union of this and other.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
occursAfter(Period other) bool
Returns true if this occurs after other.
occursBefore(Period other) bool
Returns true if this occurs before other.
overlapsWith(Period other) bool
Returns true if this overlaps with other.
shift(Duration duration) Period
Returns a new Period that is shifted by the given duration .
splitAt(Set<DateTime> dates, {Duration periodBetween = Duration.zero}) List<Period>
Splits the period in multiple periods at the given dates. The periodBetween is the duration between each period. The dates not included in the period are ignored. The dates will be sorted before splitting.
splitIn(int times, {Duration periodBetween = Duration.zero}) List<Period>
Split the period in multiple periods. The times is the number of periods to split the period in.
startsAfter(DateTime date) bool
Returns true if this starts after the given date.
startsBefore(DateTime date) bool
Returns true if this starts before the given date.
subtract(List<Period> periods) List<Period>
Returns a list of Periods that are the difference between this Period and the periods passed as argument.
toString({String dateFormat(DateTime date)?}) String
A string representation of this object.
override
trim(List<Period> periods) List<Period>
Removes periods that do not overlap with this period and trims the ones that do overlap and are not fully contained by this period.

Operators

operator &(Period other) Period?
Returns a Period that is the intersection of this and other.
operator <<(Duration duration) Period
Returns a new Period that is shifted by the given duration backwards.
operator ==(Object other) bool
The equality operator.
override
operator >>(Duration duration) Period
Returns a new Period that is shifted by the given duration forwards.
operator |(Period other) List<Period>
Returns a list of Periods.

Static Methods

calculateEndDifference(Period first, Period second) Period?
Returns the period between the end of the first period and the end of the second period.
calculateStartDifference(Period first, Period second) Period?
Returns the period between the start of the first period and the start of the second period.
inBetween(Period first, Period second) Period?
Returns the period between first and second.
intersections(List<Period> periods, {bool sort = true}) List<Period>
Returns a list of periods that are the intersection of the given periods.
mergeOverlappingPeriods(List<Period> periods, {bool sort = true}) List<Period>
Returns a list of periods that are the union of the given periods.