/*
 * @Author: lixg lixg@dongwu-inc.com
 * @Date: 2022-12-19 11:35:37
 * @LastEditors: lixg lixg@dongwu-inc.com
 * @LastEditTime: 2023-03-10 03:44:17
 * @FilePath: /fe-stu/src/views/project/method.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// 修改时间格式---------start-----------------------------
function formatNumber(n) {
  n = n.toString();
  return n[1] ? n : "0" + n;
}

function toDate(number, format) {
  var formateArr = ["Y", "M", "D", "h", "m", "s"];
  var returnArr = [];

  if (number === 0) {
    return 0;
  } else {
    var date = new Date(number * 1000);
  }
  returnArr.push(date.getFullYear());
  returnArr.push(formatNumber(date.getMonth() + 1));
  returnArr.push(formatNumber(date.getDate()));

  returnArr.push(formatNumber(date.getHours()));
  returnArr.push(formatNumber(date.getMinutes()));
  returnArr.push(formatNumber(date.getSeconds()));

  for (var i in returnArr) {
    format = format.replace(formateArr[i], returnArr[i]);
  }
  return format;
}
// 修改时间格式---------end-----------------------------


// 修改时间格式
function changeTime(time) {
  // console.log('time', time)
  if (time) {
    let newtime = time.replaceAll("-", "/")
    return newtime
  }

}
export {
  toDate,
  changeTime
}