19 lines
384 B
Dart
19 lines
384 B
Dart
|
class Year {
|
||
|
final String comment;
|
||
|
final int year;
|
||
|
final bool isLeap;
|
||
|
|
||
|
Year(this.comment, {required this.year}) : isLeap = _isLeapYear(year);
|
||
|
|
||
|
static bool _isLeapYear(int year) {
|
||
|
if (year % 4 != 0) {
|
||
|
return false;
|
||
|
} else if (year % 100 != 0) {
|
||
|
return true;
|
||
|
} else if (year % 400 != 0) {
|
||
|
return false;
|
||
|
} else {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
}
|