toWeekDay method

String toWeekDay({
  1. bool isHalfName = false,
})

Implementation

String toWeekDay({bool isHalfName = false}) {
  if (!(this! >= 1 && this! <= 7)) {
    throw Exception('Invalid day of month');
  }
  String weekName = '';

  if (this == 1) {
    return weekName = isHalfName ? "Mon" : "Monday";
  } else if (this == 2) {
    return weekName = isHalfName ? "Tue" : "Tuesday";
  } else if (this == 3) {
    return weekName = isHalfName ? "Wed" : "Wednesday";
  } else if (this == 4) {
    return weekName = isHalfName ? "Thu" : "Thursday";
  } else if (this == 5) {
    return weekName = isHalfName ? "Fri" : "Friday";
  } else if (this == 6) {
    return weekName = isHalfName ? "Sat" : "Saturday";
  } else if (this == 7) {
    return weekName = isHalfName ? "Sun" : "Sunday";
  }
  return weekName;
}