DateTimeRangeExtensions extension

An extension on the DateTimeRange class that provides helpful methods.

on

Properties

asLocal DateTimeRange<DateTime>

Available on DateTimeRange<DateTime>, provided by the DateTimeRangeExtensions extension

Returns a DateTimeRange with the DateTimes as local values without converting them.
no setter
asUtc DateTimeRange<DateTime>

Available on DateTimeRange<DateTime>, provided by the DateTimeRangeExtensions extension

Returns a DateTimeRange with the DateTimes as UTC values without converting them.
no setter
dominantMonthDate DateTime

Available on DateTimeRange<DateTime>, provided by the DateTimeRangeExtensions extension

Returns the DateTime that has the most days in the dates of this DateTimeRange.
no setter
isUtc bool

Available on DateTimeRange<DateTime>, provided by the DateTimeRangeExtensions extension

Check if both the start and end times are in utc.
no setter
monthDifference int

Available on DateTimeRange<DateTime>, provided by the DateTimeRangeExtensions extension

The difference in months between the start and end dates of this range.
no setter
weekNumbers → (int, int?)

Available on DateTimeRange<DateTime>, provided by the DateTimeRangeExtensions extension

Returns the ISO week number(s) that this DateTimeRange spans.
no setter

Methods

dates({bool inclusive = false}) List<DateTime>

Available on DateTimeRange<DateTime>, provided by the DateTimeRangeExtensions extension

Generates a list of DateTime objects representing the dates within this DateTimeRange.
dateTimeRangeOnDate(DateTime date) DateTimeRange<DateTime>?

Available on DateTimeRange<DateTime>, provided by the DateTimeRangeExtensions extension

Returns a DateTimeRange representing the portion of this DateTimeRange that falls on the given date, or null if the date is not within this range.
overlaps(DateTimeRange<DateTime> other, {bool touching = false}) bool

Available on DateTimeRange<DateTime>, provided by the DateTimeRangeExtensions extension

Checks if this DateTimeRange overlaps with another DateTimeRange.
shiftByDays(int numberOfDays) DateTimeRange<DateTime>

Available on DateTimeRange<DateTime>, provided by the DateTimeRangeExtensions extension

Returns a DateTimeRange shifted by the given number of numberOfDays.
toLocal() DateTimeRange<DateTime>

Available on DateTimeRange<DateTime>, provided by the DateTimeRangeExtensions extension

Converts the start and end times to local time.
toUtc() DateTimeRange<DateTime>

Available on DateTimeRange<DateTime>, provided by the DateTimeRangeExtensions extension

Converts the start and end times to utc.