DateTimeUtils extension

Extensions on DateTime for real-world utility operations.

on

Properties

age → int

Available on DateTime, provided by the DateTimeUtils extension

Returns the age in whole years from this date to now.
no setter
daysInMonth → int

Available on DateTime, provided by the DateTimeUtils extension

Returns the number of days in this date's month.
no setter
endOfDay → DateTime

Available on DateTime, provided by the DateTimeUtils extension

Returns the last moment (23:59:59.999) of this date.
no setter
endOfMonth → DateTime

Available on DateTime, provided by the DateTimeUtils extension

Returns the last moment of this date's month.
no setter
endOfWeek → DateTime

Available on DateTime, provided by the DateTimeUtils extension

Returns the Sunday of this date's week (end of week).
no setter
endOfYear → DateTime

Available on DateTime, provided by the DateTimeUtils extension

Returns the last moment of this date's year.
no setter
isAfternoon → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if the time is afternoon (12:00–17:59).
no setter
isEvening → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if the time is evening (18:00–22:59).
no setter
isFuture → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if this date is in the future.
no setter
isLeapYear → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if this year is a leap year.
no setter
isMorning → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if the time is morning (06:00–11:59).
no setter
isNight → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if the time is night (23:00–05:59).
no setter
isPast → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if this date is in the past.
no setter
isToday → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if this date is today.
no setter
isTomorrow → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if this date is tomorrow.
no setter
isWeekday → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if this date falls on a weekday.
no setter
isWeekend → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if this date falls on a weekend (Saturday or Sunday).
no setter
isYesterday → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if this date is yesterday.
no setter
quarterOfYear → int

Available on DateTime, provided by the DateTimeUtils extension

Returns the quarter of the year (1–4).
no setter
season → String

Available on DateTime, provided by the DateTimeUtils extension

Returns the season for this date (Northern Hemisphere).
no setter
startOfDay → DateTime

Available on DateTime, provided by the DateTimeUtils extension

Returns midnight (00:00:00.000) of this date.
no setter
startOfMonth → DateTime

Available on DateTime, provided by the DateTimeUtils extension

Returns the first day of this date's month.
no setter
startOfWeek → DateTime

Available on DateTime, provided by the DateTimeUtils extension

Returns the Monday of this date's week.
no setter
startOfYear → DateTime

Available on DateTime, provided by the DateTimeUtils extension

Returns the first day of this date's year.
no setter
timezoneOffsetString → String

Available on DateTime, provided by the DateTimeUtils extension

Returns the UTC offset as a string, e.g. "+05:30" or "-08:00".
no setter
toUtcIso8601 → String

Available on DateTime, provided by the DateTimeUtils extension

Returns a UTC ISO 8601 string suitable for API payloads.
no setter
weekOfYear → int

Available on DateTime, provided by the DateTimeUtils extension

Returns the ISO 8601 week number (1–53).
no setter

Methods

addWorkdays(int n) → DateTime

Available on DateTime, provided by the DateTimeUtils extension

Adds n working days (Mon–Fri) to this date.
copyWith({int? year, int? month, int? day, int? hour, int? minute, int? second, int? millisecond, int? microsecond}) → DateTime

Available on DateTime, provided by the DateTimeUtils extension

Returns a copy of this DateTime with the given fields replaced.
countdown() → Duration

Available on DateTime, provided by the DateTimeUtils extension

Returns the Duration from now until this date. Negative if this date is in the past.
daysUntil(DateTime other) → int

Available on DateTime, provided by the DateTimeUtils extension

Returns the number of days until other (negative if other is past).
daysUntilEndOfYear() → int

Available on DateTime, provided by the DateTimeUtils extension

Returns the number of days until the end of the year.
daysUntilWeekend() → int

Available on DateTime, provided by the DateTimeUtils extension

Returns the number of days until the next Saturday (0 if already weekend).
fiscalQuarter(int fiscalYearStartMonth) → int

Available on DateTime, provided by the DateTimeUtils extension

Returns the fiscal quarter (1–4) given a fiscal year start month.
format(String pattern) → String

Available on DateTime, provided by the DateTimeUtils extension

Formats this date using a simple pattern.
hoursUntil(DateTime other) → int

Available on DateTime, provided by the DateTimeUtils extension

Returns the number of hours until other.
isAheadByDays(DateTime other, int days) → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if this date is at least days days ahead of other.
isBehindByDays(DateTime other, int days) → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if this date is at least days days behind other.
isBetween(DateTime start, DateTime end) → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if this date is between start and end (inclusive).
isBusinessHours({int startHour = 9, int endHour = 17}) → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if the current time falls within business hours.
isSameDay(DateTime other) → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if this date is on the same calendar day as other.
isSameHour(DateTime other) → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if this date is in the same hour as other.
isSameMinute(DateTime other) → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if this date is in the same minute as other.
isSameMonth(DateTime other) → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if this date is in the same month and year as other.
isSameSecond(DateTime other) → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if this date is in the same second as other.
isSameYear(DateTime other) → bool

Available on DateTime, provided by the DateTimeUtils extension

Returns true if this date is in the same year as other.
nextWeekday(int targetWeekday) → DateTime

Available on DateTime, provided by the DateTimeUtils extension

Returns the next occurrence of weekday (1=Mon … 7=Sun) after this date.
timeAgo({DateTime? from}) → String

Available on DateTime, provided by the DateTimeUtils extension

Returns a human-readable relative time string.