convertYearTo4Digits method

int convertYearTo4Digits(
  1. int year
)

Convert the two-digit year to four-digit year if necessary

Implementation

static int convertYearTo4Digits(int year) {
  if (year < 100 && year >= 0) {
    var now = DateTime.now();
    String currentYear = now.year.toString();
    String prefix = currentYear.substring(0, currentYear.length - 2);
    year = int.parse('$prefix${year.toString().padLeft(2, '0')}');
  }
  return year;
}