DateOnly constructor
Constructs a DateOnly from year
, month
, and day
.
Throws ArgumentError if components do not represent a valid date.
Implementation
DateOnly(this.year, this.month, this.day) {
final dateTime = DateTime(year, month, day);
// if the processed components are different, an overflow happened
if (dateTime.year != year ||
dateTime.month != month ||
dateTime.day != day) {
throw ArgumentError('components do not form a valid date');
}
}