isBefore method

bool isBefore(
  1. DateTime first,
  2. DateTime second, {
  3. bool needDayComparison = true,
})

returns true if first is before second

Implementation

bool isBefore(
  DateTime first,
  DateTime second, {
  bool needDayComparison = true,
}) {
  return first.year < second.year ||
      (first.year == second.year && first.month < second.month) ||
      (needDayComparison &&
          (first.year == second.year &&
              first.month == second.month &&
              first.day < second.day));
}