StringDateExtension extension

Date validation and comparison utilities for date strings.

Assumes ISO 8601 format (yyyy-MM-dd or yyyy-MM-ddTHH:mm:ss) unless otherwise noted. Behavior with non-date strings is undefined — guard with isDate first when input is untrusted.

final raw = '2024-03-15';
if (raw.isDate && raw.isFuture) {
  scheduleReminder(raw);
}
on

Properties

isDate → bool

Available on String, provided by the StringDateExtension extension

Whether this string is a recognizable date value.
no setter
isFuture → bool

Available on String, provided by the StringDateExtension extension

Whether this date is strictly after today.
no setter
isLeapYear → bool

Available on String, provided by the StringDateExtension extension

Whether the year of this date is a leap year.
no setter
isPast → bool

Available on String, provided by the StringDateExtension extension

Whether this date is strictly before today.
no setter
isToday → bool

Available on String, provided by the StringDateExtension extension

Whether this date represents today's date (UTC).
no setter
isWeekday → bool

Available on String, provided by the StringDateExtension extension

Whether this date falls on a Monday through Friday.
no setter
isWeekend → bool

Available on String, provided by the StringDateExtension extension

Whether this date falls on a Saturday or Sunday.
no setter

Methods

isAfter([String? reference]) → bool

Available on String, provided by the StringDateExtension extension

Whether this date is after reference.
isBefore([String? reference]) → bool

Available on String, provided by the StringDateExtension extension

Whether this date is before reference.
isBetween(String from, String to) → bool

Available on String, provided by the StringDateExtension extension

Whether this date falls within the range [from, to] exclusively.