isBefore function

bool isBefore(
  1. String str, [
  2. String? reference
])

Returns true if str represents a date before reference.

When reference is omitted the current UTC time is used.

Implementation

bool isBefore(String str, [String? reference]) {
  final date = tryParseDate(str);
  if (date == null) return false;
  final ref =
      reference == null ? DateTime.now().toUtc() : tryParseDate(reference);
  if (ref == null) return false;
  return date.isBefore(ref);
}