DateService class
Centralized service for date/time operations
Constructors
- DateService({String? locale, bool? enableCaching})
- Creates a new DateService instance
Properties
- cacheSize → int
-
Gets the cache size
no setter
- enableCaching → bool
-
Whether to enable caching
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- locale → String
-
The locale to use for formatting
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addBusinessDays(
DateTime date, int days) → DateTime - Adds business days to a date
-
businessDaysBetween(
DateTime start, DateTime end) → int - Gets the number of business days between two dates
-
calculateAge(
DateTime birthdate) → int - Calculates age from a birthdate
-
clearCache(
) → void - Clears the format cache
-
daysBetween(
DateTime start, DateTime end) → int - Gets the number of days between two dates
-
endOfDay(
DateTime date) → DateTime - Gets the end of the day
-
formatCustom(
DateTime date, String pattern) → String - Formats a date using a custom pattern
-
formatDateTime(
DateTime date, {bool useLongFormat = false}) → String - Formats date and time together
-
formatFull(
DateTime date) → String - Formats a date in full format
-
formatLong(
DateTime date) → String - Formats a date in long format
-
formatMedium(
DateTime date) → String - Formats a date in medium format
-
formatShort(
DateTime date) → String - Formats a date in short format
-
formatSmart(
DateTime date) → String - Formats using smart formatting (context-aware)
-
formatTime12Hour(
DateTime date) → String - Formats time in 12-hour format
-
formatTime24Hour(
DateTime date) → String - Formats time in 24-hour format
-
getCacheStats(
) → Map< String, dynamic> - Gets cache statistics
-
getRelativeTime(
DateTime date) → String - Gets relative time string
-
isBetween(
DateTime date, DateTime start, DateTime end) → bool - Checks if a date is between two dates
-
isFuture(
DateTime date) → bool - Checks if a date is in the future
-
isPast(
DateTime date) → bool - Checks if a date is in the past
-
isSameDay(
DateTime date1, DateTime date2) → bool - Checks if two dates are the same day
-
isToday(
DateTime date) → bool - Checks if a date is today
-
isTomorrow(
DateTime date) → bool - Checks if a date is tomorrow
-
isValidDate(
String dateString) → bool - Validates if a string is a valid date
-
isWeekday(
DateTime date) → bool - Checks if a date is a weekday
-
isWeekend(
DateTime date) → bool - Checks if a date is a weekend
-
isYesterday(
DateTime date) → bool - Checks if a date is yesterday
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
parseDate(
String dateString) → DateTime? - Parses a date string
-
parseFlexible(
String dateString) → DateTime? - Parses a date string flexibly (tries multiple formats)
-
startOfDay(
DateTime date) → DateTime - Gets the start of the day
-
startOfMonth(
DateTime date) → DateTime - Gets the start of the month
-
startOfWeek(
DateTime date) → DateTime - Gets the start of the week
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited