DateTimeUtils class abstract final

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 days as years, months, and optionally remaining days, or null if days is null or 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 month and year, or null if month is invalid.
isDateMonthFirst({required String localeName}) bool
Checks if the given localeName uses 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 true if 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 month and year.
tomorrow({DateTime? now, int? hour, int minute = 0, int second = 0}) DateTime
Returns the date for tomorrow at the specified time.