formatWeekday function

String formatWeekday(
  1. DateTime dateTime,
  2. {int? characters}
)

Implementation

String formatWeekday(DateTime dateTime, {int? characters}) {
  switch (dateTime.weekday) {
    case 1:
      return 'Lunes'.substring(
          0,
          (characters != null && characters > 0 && characters <= 'Lunes'.length)
              ? characters
              : null);

    case 2:
      return 'Martes'.substring(
          0,
          (characters != null &&
                  characters > 0 &&
                  characters <= 'Martes'.length)
              ? characters
              : null);

    case 3:
      return 'Miércoles'.substring(
          0,
          (characters != null &&
                  characters > 0 &&
                  characters <= 'Miércoles'.length)
              ? characters
              : null);

    case 4:
      return 'Jueves'.substring(
          0,
          (characters != null &&
                  characters > 0 &&
                  characters <= 'Jueves'.length)
              ? characters
              : null);

    case 5:
      return 'Viernes'.substring(
          0,
          (characters != null &&
                  characters > 0 &&
                  characters <= 'Viernes'.length)
              ? characters
              : null);

    case 6:
      return 'Sábado'.substring(
          0,
          (characters != null &&
                  characters > 0 &&
                  characters <= 'Sábado'.length)
              ? characters
              : null);

    case 7:
      return 'Domingo'.substring(
          0,
          (characters != null &&
                  characters > 0 &&
                  characters <= 'Domingo'.length)
              ? characters
              : null);

    default:
      return '';
  }
}