getWeek static method

String getWeek(
  1. int week, [
  2. dynamic type = 2
])

周转换

Implementation

static String getWeek(int week, [type = 2]) {
  String weekString = '';
  List data = [];

  List data1 = [
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
    "Sunday"
  ];
  List data2 = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
  List data3 = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"];

  if (type == 1) {
    data = data1;
  } else if (type == 2) {
    data = data2;
  } else if (type == 3) {
    data = data3;
  }

  if (0 < week && week < 8) {
    weekString = data[week - 1];
  }

  return weekString;
}