endOf method
Manipulate the Dayfl object to the end of a unit of time.
Implementation
Dayfl endOf(DateLocationEnum type) {
if (_datetime == null) {
throw StateError('当前Dayfl对象包含无效的日期时间');
}
switch (type) {
case DateLocationEnum.year:
_datetime = DateTime(year, 12, 31, 23, 59, 59, 999);
break;
case DateLocationEnum.month:
final days = daysInMonth;
if (days == null) {
throw StateError('无法获取当前月份的天数');
}
_datetime = DateTime(year, month, days, 23, 59, 59, 999);
break;
case DateLocationEnum.day:
_datetime = DateTime(year, month, day, 23, 59, 59, 999);
break;
case DateLocationEnum.hour:
_datetime = DateTime(year, month, day, hour, 59, 59, 999);
break;
case DateLocationEnum.minute:
_datetime = DateTime(year, month, day, hour, minute, 59, 999);
break;
case DateLocationEnum.sec:
_datetime = DateTime(year, month, day, hour, minute, second, 999);
break;
default:
// For millisecondsSinceEpoch and any other unhandled cases, do nothing.
break;
}
_init();
return this;
}