yy property

String yy

year number string ensured to have length of 2

date.year should be between 1000 and 9999 or exception is thrown

Implementation

String get yy {
  final int year = date.year;

  if (year < 1000) {
    throw StateError('date.year = $year < 1000');
  }

  if (year > 9999) {
    throw StateError('date.year = $year > 9999');
  }

  final String str = (year % 100).toString();
  return str.length == 1 ? '0' + str : str;
}