toWeekDay method
Implementation
String toWeekDay({bool isHalfName = false}) {
if (this < 1 || this > 7) {
throw Exception('Invalid day of the week');
}
switch (this) {
case 1:
return isHalfName ? "Mon" : "Monday";
case 2:
return isHalfName ? "Tue" : "Tuesday";
case 3:
return isHalfName ? "Wed" : "Wednesday";
case 4:
return isHalfName ? "Thu" : "Thursday";
case 5:
return isHalfName ? "Fri" : "Friday";
case 6:
return isHalfName ? "Sat" : "Saturday";
case 7:
return isHalfName ? "Sun" : "Sunday";
default:
throw Exception('Unexpected error');
}
}