getMonth static method

String getMonth(
  1. int month, [
  2. dynamic type = 2
])

月转换

Implementation

static String getMonth(int month, [type = 2]) {
  String monthString = '';
  List data = [];

  List data1 = [
    "January",
    "February",
    "March",
    "April",
    "May",
    "June",
    "July",
    "August",
    "September",
    "October",
    "November",
    "December"
  ];
  List data2 = [
    "Jan",
    "Feb",
    "Mar",
    "Apr",
    "May",
    "Jun",
    "Jul",
    "Aug",
    "Sep",
    "Oct",
    "Nov",
    "Dec"
  ];

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

  if (0 < month && month < 13) {
    monthString = data[month - 1];
  }

  return monthString;
}