DateTimeExtensions extension

Useful extensions for working with DateTime objects.

on

Properties

asLocal DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Returns a DateTime as a local value without converting it.
no setter
asUtc DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Returns a DateTime as a UTC value without converting it.
no setter
dayNameEnglish String

Available on DateTime, provided by the DateTimeExtensions extension

Gets the day name in English (backwards compatibility).
no setter
dayRange DateTimeRange<DateTime>

Available on DateTime, provided by the DateTimeExtensions extension

Gets the DateTimeRange representing the entire day in which this DateTime falls.
no setter
endOfDay DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Gets the end of the date. (aka the start of the next day).
no setter
endOfMonth DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Gets the end of the month. (aka start of the next month)
no setter
endOfYear DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Gets the end of the year. (aka start of the next year)
no setter
isLeapYear bool

Available on DateTime, provided by the DateTimeExtensions extension

True if this date is on a leap year.
no setter
isToday bool

Available on DateTime, provided by the DateTimeExtensions extension

Check if the DateTime is today in the current time zone.
no setter
monthNameEnglish String

Available on DateTime, provided by the DateTimeExtensions extension

Gets the month name in English (backwards compatibility).
no setter
monthRange DateTimeRange<DateTime>

Available on DateTime, provided by the DateTimeExtensions extension

Gets a DateTimeRange representing the entire month in which this DateTime occurs.
no setter
ordinalDate int

Available on DateTime, provided by the DateTimeExtensions extension

The ordinal date, the number of days since December 31st the previous year.
no setter
startOfDay DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Gets the start of the date.
no setter
startOfMonth DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Gets the start of the month.
no setter
startOfYear DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Gets the start of the year.
no setter
weekNumber int

Available on DateTime, provided by the DateTimeExtensions extension

TODO: Proposal depend on the intl package so this can be removed. If we do start depending on the intl package, then we might as well look into allowing the calendar to display events for different timezones. This will open a lot of possibilities for the calendar package.
no setter
workWeekRange DateTimeRange<DateTime>

Available on DateTime, provided by the DateTimeExtensions extension

Get the work week range.
no setter
yearRange DateTimeRange<DateTime>

Available on DateTime, provided by the DateTimeExtensions extension

Gets a DateTimeRange representing the entire year in which this DateTime occurs.
no setter

Methods

addDays(int days) DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Add specific amount of days (ignoring DST)
customDateTimeRange(int numberOfDays) DateTimeRange<DateTime>

Available on DateTime, provided by the DateTimeExtensions extension

Returns a DateTimeRange with the DateTime as the start that spans the given number of days.
dayNameLocalized([dynamic locale]) String

Available on DateTime, provided by the DateTimeExtensions extension

Gets the day name in a specific locale.
dayNameShortLocalized([dynamic locale]) String

Available on DateTime, provided by the DateTimeExtensions extension

Gets the abbreviated day name in a specific locale.
endOfWeek({int firstDayOfWeek = DateTime.monday}) DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Gets the end of the week. The end of the week is calculated as the start of the next week, which is midnight of the next corresponding firstDayOfWeek.
isSameDay(DateTime date) bool

Available on DateTime, provided by the DateTimeExtensions extension

Checks if the DateTime is the same day as the calling object.
isWithin(DateTimeRange<DateTime> dateTimeRange, {bool includeStart = true, bool includeEnd = false}) bool

Available on DateTime, provided by the DateTimeExtensions extension

Checks if this DateTime occurs during the given DateTimeRange.
monthNameLocalized([dynamic locale]) String

Available on DateTime, provided by the DateTimeExtensions extension

Gets the month name in a specific locale.
monthNameShortLocalized([dynamic locale]) String

Available on DateTime, provided by the DateTimeExtensions extension

Gets the abbreviated month name in a specific locale.
startOfWeek({int firstDayOfWeek = DateTime.monday}) DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Gets the start of the week.
subtractDays(int days) DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Subtract specific amount of days (ignoring DST)
weekRange({int firstDayOfWeek = DateTime.monday}) DateTimeRange<DateTime>

Available on DateTime, provided by the DateTimeExtensions extension

Get the week range.