isLeapYear property

bool get isLeapYear

Whether this year is a leap-year.

A year in the proleptic Gregorian calendar is a leap year if:

  • It's divisible by 4, and
  • It's not divisible by 100, unless
  • It's also divisble by 400.

This gives 97 leap years per 400 years.

Implementation

bool get isLeapYear {
  final year = this.year;
  return (year & 0x3 == 0) && ((year & 0xC != 0) || (year % 25 == 0));
}