ChronoDateTime extension

Calendar helpers available on every DateTime.

on

Properties

dateOnly → DateTime

Available on DateTime, provided by the ChronoDateTime extension

Midnight at the start of this day, same zone kind.
no setter
dayOfYear → int

Available on DateTime, provided by the ChronoDateTime extension

Day of the year, 1 to 366.
no setter
daysInThisMonth → int

Available on DateTime, provided by the ChronoDateTime extension

Number of days in this month.
no setter
endOfDay → DateTime

Available on DateTime, provided by the ChronoDateTime extension

The last microsecond of this day.
no setter
endOfMonth → DateTime

Available on DateTime, provided by the ChronoDateTime extension

Last day of this month (at midnight).
no setter
endOfQuarter → DateTime

Available on DateTime, provided by the ChronoDateTime extension

Last day of this quarter (at midnight).
no setter
endOfYear → DateTime

Available on DateTime, provided by the ChronoDateTime extension

Last day of this year (at midnight).
no setter
isLeap → bool

Available on DateTime, provided by the ChronoDateTime extension

Whether this year is a leap year.
no setter
isoWeekNumber → int

Available on DateTime, provided by the ChronoDateTime extension

ISO-8601 week number (weeks start Monday, week 1 holds the first Thursday of the year).
no setter
isoWeekYear → int

Available on DateTime, provided by the ChronoDateTime extension

The year that owns isoWeekNumber, which can differ from year in the first and last days of December/January.
no setter
isToday → bool

Available on DateTime, provided by the ChronoDateTime extension

Whether this is today in the device's local time.
no setter
isTomorrow → bool

Available on DateTime, provided by the ChronoDateTime extension

Whether this is tomorrow in the device's local time.
no setter
isYesterday → bool

Available on DateTime, provided by the ChronoDateTime extension

Whether this was yesterday in the device's local time.
no setter
quarter → int

Available on DateTime, provided by the ChronoDateTime extension

Calendar quarter, 1 to 4.
no setter
startOfMonth → DateTime

Available on DateTime, provided by the ChronoDateTime extension

First day of this month.
no setter
startOfQuarter → DateTime

Available on DateTime, provided by the ChronoDateTime extension

First day of this quarter.
no setter
startOfYear → DateTime

Available on DateTime, provided by the ChronoDateTime extension

First day of this year.
no setter

Methods

addDays(int days) → DateTime

Available on DateTime, provided by the ChronoDateTime extension

Adds days calendar days, keeping the time of day (DST safe).
addMonths(int months) → DateTime

Available on DateTime, provided by the ChronoDateTime extension

Adds months months, clamping the day to the target month's length (Jan 31 + 1 month = Feb 28/29).
addWeeks(int weeks) → DateTime

Available on DateTime, provided by the ChronoDateTime extension

Adds weeks calendar weeks.
addYears(int years) → DateTime

Available on DateTime, provided by the ChronoDateTime extension

Adds years years, clamping Feb 29 to Feb 28 in non-leap years.
atTime(int hour, [int minute = 0, int second = 0]) → DateTime

Available on DateTime, provided by the ChronoDateTime extension

Same calendar date with the time set from hour and minute.
clampTo(DateTime? min, DateTime? max) → DateTime

Available on DateTime, provided by the ChronoDateTime extension

Clamps this date into min..max (either may be null).
copyWith({int? year, int? month, int? day, int? hour, int? minute, int? second, int? millisecond, int? microsecond}) → DateTime

Available on DateTime, provided by the ChronoDateTime extension

Copy with some fields replaced.
daysUntil(DateTime other) → int

Available on DateTime, provided by the ChronoDateTime extension

Whole calendar days from this day to other (negative if other is earlier). Time of day and DST are ignored.
endOfWeek([int firstDayOfWeek = DateTime.monday]) → DateTime

Available on DateTime, provided by the ChronoDateTime extension

Last day of this week (at midnight).
isBetweenDays(DateTime start, DateTime end) → bool

Available on DateTime, provided by the ChronoDateTime extension

Whether this day lies between start and end, both inclusive, ignoring the time of day.
isSameDay(DateTime? other) → bool

Available on DateTime, provided by the ChronoDateTime extension

Whether this and other fall on the same calendar day.
isSameDayOrAfter(DateTime other) → bool

Available on DateTime, provided by the ChronoDateTime extension

Whether this is the same day as other or later.
isSameDayOrBefore(DateTime other) → bool

Available on DateTime, provided by the ChronoDateTime extension

Whether this is the same day as other or earlier.
isSameMonth(DateTime? other) → bool

Available on DateTime, provided by the ChronoDateTime extension

Whether this and other fall in the same month of the same year.
isSameYear(DateTime? other) → bool

Available on DateTime, provided by the ChronoDateTime extension

Whether this and other fall in the same year.
isWeekend([Set<int> weekendDays = const {DateTime.saturday, DateTime.sunday}]) → bool

Available on DateTime, provided by the ChronoDateTime extension

Whether this day is in weekendDays (Saturday and Sunday by default).
nextWeekday(int weekday) → DateTime

Available on DateTime, provided by the ChronoDateTime extension

The next date (strictly after this day) that falls on weekday.
nthWeekdayOfMonth(int n, int weekday) → DateTime?

Available on DateTime, provided by the ChronoDateTime extension

The nth weekday of this month; negative n counts from the end (-1 is the last). Returns null when it does not exist (5th Monday).
previousWeekday(int weekday) → DateTime

Available on DateTime, provided by the ChronoDateTime extension

The previous date (strictly before this day) that falls on weekday.
startOfWeek([int firstDayOfWeek = DateTime.monday]) → DateTime

Available on DateTime, provided by the ChronoDateTime extension

First day of this week, where weeks start on firstDayOfWeek.
weekOfYear({int firstDayOfWeek = DateTime.sunday}) → int

Available on DateTime, provided by the ChronoDateTime extension

Week number where weeks start on firstDayOfWeek and week 1 is the week containing January 1st (the US convention when Sunday).