isSameYear method
Return if date is the same year as other
other
- date to compare
ignoreTime
- if true, time will be ignored
ignoreTimezone
- if true, timezone will be ignored
ignoreDay
- if true, day will be ignored
ignoreMonth
- if true, month will be ignored
Implementation
bool isSameYear(DateTime other,
{bool ignoreTime = true,
bool ignoreTimezone = true,
bool ignoreDay = true,
bool ignoreMonth = true}) {
if (ignoreTimezone) {
return year == other.year &&
(ignoreMonth || month == other.month) &&
(ignoreDay || day == other.day) &&
(ignoreTime ||
(hour == other.hour &&
minute == other.minute &&
second == other.second &&
millisecond == other.millisecond &&
microsecond == other.microsecond));
} else {
return year == other.year &&
(ignoreMonth || month == other.month) &&
(ignoreDay || day == other.day) &&
(ignoreTime ||
(hour == other.hour &&
minute == other.minute &&
second == other.second &&
millisecond == other.millisecond &&
microsecond == other.microsecond &&
timeZoneOffset == other.timeZoneOffset));
}
}