A utility class for working with DateTime objects.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
calculateAgeAtDeath(
{required DateTime? dob, required DateTime? dod}) → int? - Calculates the age at death based on the date of birth (DOB) and date of death (DOD).
-
convertDaysToYearsAndMonths(
int? days, {bool includeRemainingDays = false}) → String? -
Returns a human-readable string representing
daysas years, months, and optionally remaining days, ornullifdaysisnullor less than 1. -
extractYear(
String input) → int? - Extracts a 4-digit year from a given string.
-
firstDayNextMonth(
{required int month, required int year}) → DateTime? -
Returns the first day of the month following the given
monthandyear, ornullifmonthis invalid. -
isDateMonthFirst(
{required String localeName}) → bool -
Checks if the given
localeNameuses a month-first date format. -
isLeapYear(
{required int year}) → bool - Checks if the given year is a leap year.
-
isValidDateParts(
{int? year, int? month, int? day, int? hour, int? minute, int? second, int? millisecond, int? microsecond}) → bool -
Returns
trueif all provided date/time components are within valid ranges. -
maxDate(
DateTime date1, DateTime? date2) → DateTime - Returns the later of two dates.
-
minDate(
DateTime date1, DateTime? date2) → DateTime - Returns the earlier of two dates.
-
monthDayCount(
{required int year, required int month}) → int -
Returns the number of days in the given
monthandyear. -
tomorrow(
{DateTime? now, int? hour, int minute = 0, int second = 0}) → DateTime - Returns the date for tomorrow at the specified time.