
function transforDay(time, type) {
  if (time == null || type == '') {
    return ''
  }
  if (arguments.length === 0) {
    return null
  }
  var  time_cur=0
  if(typeof time=="string"){
    var reg = getRegExp("-", "g");
  var timeS=time.replace(reg, '/');
    time_cur = getDate(timeS).getTime();
  }else{
    time_cur=time*1000
  }
  var date = getDate(time_cur);//在wxs中不能使用new Date()来处理日期
  console.log("date", date);
  var y = date.getFullYear();
  var m = addZero(date.getMonth() + 1);
  var d = addZero(date.getDate());
  var h =addZero(date.getHours());
  var i = addZero(date.getMinutes());
  var s =addZero(date.getSeconds());
  var a = addZero(date.getDay());
  var time_str = "";
  if (type == 'month') {
    time_str = y + '-' + m;
  }else if(type=='day'){
    time_str = m + '-' + d;
  } else if(type=='HM'){
    time_str =h + ':' + s;
  }else if (type == 'date') {
    time_str = y + '-' + m + '-' + d;
  } else if(type == 'dateminute'){
    time_str = y + '-' + m + '-' + d + ' ' + h + ':' + i 
  }else if (type == 'datetime') {
    time_str = y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s;
  } else if (type == 'onlyMonth') {
    time_str = m;
  } else if (type == 'onlyYear') {
    time_str = y;
  }
  return time_str
};
function addZero(n) {
  n = n.toString()
  return n[1] ? n : '0' + n
};

module.exports = {
    transforDay: transforDay
};