"use strict";

exports.__esModule = true;
exports.formatMonth = exports.getYears = exports.format = void 0;

// 时间对象格式为中文文本
var format = function format(date) {
  if (!date) {
    return '';
  }

  var _date = new Date(date);

  var y = _date.getFullYear();

  var m = _date.getMonth() + 1;
  m = m < 10 ? '0' + m : m;
  return y + "\u5E74" + m + "\u6708";
}; // 获取年数组


exports.format = format;

var getYears = function getYears(arr) {
  var num = arr[1];
  var years = [];

  while (num >= arr[0]) {
    years.unshift(num);
    num = num - 1;
  }

  return years;
}; // 格式统一格式为时间戳


exports.getYears = getYears;

var formatMonth = function formatMonth(month) {
  var _month = null;

  if (typeof month === 'string') {
    var m = month.replace(/-/g, "/").split('/');
    _month = new Date(m[0] + "/" + m[1] + "/01");
  } else {
    var d = new Date(month);
    _month = new Date(d.getFullYear() + "/" + (d.getMonth() + 1) + "/01");
  }

  return +_month;
};

exports.formatMonth = formatMonth;