DateTimeExtensions extension

Extensions on the DateTime class to provide additional functionality.

on

Properties

isMidnight bool

Available on DateTime, provided by the DateTimeExtensions extension

Checks if the current time is midnight (00:00:00).
no setter
isYearCurrent bool

Available on DateTime, provided by the DateTimeExtensions extension

Checks if the date is in the current calendar year.
no setter
yearEnd DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Gets the end date of the year.
no setter
yearStart DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Gets the start date of the year.
no setter

Methods

addDays(int days) DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Adds the specified number of days to the current DateTime.
addHours(int hours) DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Adds the specified number of hours to the current DateTime.
addMinutes(int minutes) DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Adds the specified number of minutes to the current DateTime.
addMonths(int months) DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Adds the specified number of months to the current DateTime.
addYears(int years) DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Adds the specified number of years to the current DateTime.
alignDateTime({required Duration alignment, bool roundUp = false}) DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Aligns the current DateTime to the specified duration.
calculateAgeFromDate(DateTime fromDate) int

Available on DateTime, provided by the DateTimeExtensions extension

Calculates the age based on a given date.
calculateAgeFromNow({DateTime? now}) int

Available on DateTime, provided by the DateTimeExtensions extension

Calculates the age based on the current date.
dayOfMonthOrdinal() String?

Available on DateTime, provided by the DateTimeExtensions extension

Returns the ordinal representation of the day of the month.
generateDayList(int days, {bool startOfDay = true}) List<DateTime>

Available on DateTime, provided by the DateTimeExtensions extension

Generates a list of DateTime objects for consecutive days.
getNthWeekdayOfMonthInYear(int n, int dayOfWeek) DateTime?

Available on DateTime, provided by the DateTimeExtensions extension

Returns the date of the nth occurrence of a specific weekday in a given month and year.
getTimeDifferenceMs(DateTime? compareTo, {bool alwaysPositive = true}) int?

Available on DateTime, provided by the DateTimeExtensions extension

Calculates the time difference in milliseconds between the current DateTime and another DateTime.
getUtcTimeFromLocal(double offset) DateTime?

Available on DateTime, provided by the DateTimeExtensions extension

Converts the current DateTime to UTC and adds the specified offset.
isAfterNow([DateTime? now]) bool

Available on DateTime, provided by the DateTimeExtensions extension

Checks if the date is in the future compared to the current date and time.
isAfterNullable(DateTime? other) bool

Available on DateTime, provided by the DateTimeExtensions extension

Extension method to check if this DateTime is after another DateTime.
isAnnualDateInRange(DateTimeRange<DateTime>? range, {bool inclusive = true}) bool

Available on DateTime, provided by the DateTimeExtensions extension

Checks if the current DateTime is within the specified range, considering all years in the range if the current year is 0.
isBeforeNow([DateTime? now]) bool

Available on DateTime, provided by the DateTimeExtensions extension

Checks if the date is in the past compared to the current date and time.
isBeforeNullable(DateTime? other) bool

Available on DateTime, provided by the DateTimeExtensions extension

Extension method to check if this DateTime is before another DateTime.
isBetween(DateTime start, DateTime end, {bool inclusive = true}) bool

Available on DateTime, provided by the DateTimeExtensions extension

Checks if the current DateTime is between the specified start and end dates.
isBetweenRange(DateTimeRange<DateTime>? range, {bool inclusive = true}) bool

Available on DateTime, provided by the DateTimeExtensions extension

Checks if the current DateTime is within the specified range.
isDateAfterToday(DateTime dateToCheck) bool

Available on DateTime, provided by the DateTimeExtensions extension

Checks if a given date is after today.
isLeapYear() bool

Available on DateTime, provided by the DateTimeExtensions extension

Checks if the current year is a leap year using DateTimeUtils.isLeapYear
isSameDateOnly(DateTime other) bool

Available on DateTime, provided by the DateTimeExtensions extension

Checks if the current DateTime has the same date (year, month, day) as another DateTime.
isSameDateOrAfter(DateTime other) bool

Available on DateTime, provided by the DateTimeExtensions extension

Returns true if this date is the same as or after other date.
isSameDateOrBefore(DateTime other) bool

Available on DateTime, provided by the DateTimeExtensions extension

Returns true if this date is the same as or before other date.
isSameDayMonth(DateTime other) bool

Available on DateTime, provided by the DateTimeExtensions extension

Checks if the current DateTime has the same day and month as another DateTime.
isSameMonth(DateTime other) bool

Available on DateTime, provided by the DateTimeExtensions extension

Checks if the current DateTime has the same month as another DateTime.
isToday({DateTime? now, bool ignoreYear = false}) bool

Available on DateTime, provided by the DateTimeExtensions extension

Checks if the current DateTime matches the current date (today).
isUnder13({DateTime? today}) bool

Available on DateTime, provided by the DateTimeExtensions extension

Determines if the date (of birth) is under 13 years old.
nextDay({bool startOfDay = true}) DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Returns the next day.
prevDay({bool startOfDay = true}) DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Returns the previous day.
setTime({required TimeOfDay time}) DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Sets the time of the current DateTime to the specified TimeOfDay.
subtractDays(int? days) DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Subtracts the specified number of days from the current DateTime.
subtractHours(int hours) DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Subtracts the specified number of hours from the current DateTime.
subtractMinutes(int minutes) DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Subtracts the specified number of minutes from the current DateTime.
subtractMonths(int months) DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Subtracts the specified number of months from the current DateTime.
subtractYears(int years) DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Subtracts the specified number of years from the current DateTime.
toDateInYear(int setYear) DateTime?

Available on DateTime, provided by the DateTimeExtensions extension

Ignores the year of the current DateTime and returns a new DateTime with the specified setYear.
toDateOnly() DateTime

Available on DateTime, provided by the DateTimeExtensions extension

Removes the time component from the DateTime object, returning only the date part (year, month, and day).