checkBefore method

bool checkBefore({
  1. required DateTime target,
})

Implementation

bool checkBefore({required DateTime target}) {
  bool checkYear = false;
  bool checkMonth = false;
  bool checkDay = false;

  if (this.year == target.year) {
    checkYear = true;
    if (this.month == target.month) {
      checkMonth = true;
      if (this.day < target.day) {
        checkDay = false;
      } else {
        checkDay = true;
      }
    } else if (this.month > target.month) {
      checkMonth = true;
      checkDay = true;
    }
  } else if (this.year > target.year) {
    checkYear = true;
    checkMonth = true;
    checkDay = true;
  }
  return checkYear && checkMonth && checkDay;
}