export function getCurrentDate(date) {
  let w = date.getDay(); // 星期
  let z = getWeek(date); // 周
  //   let qut = Math.floor((date.getMonth() + 3) / 3).toString(); // 季度
  let year = date.getFullYear().toString();
  let month = (date.getMonth() + 1).toString();
  let day = date.getDate().toString();
  let hours = date.getHours().toString();
  let minutes = date.getMinutes().toString();
  let seconds = date.getSeconds().toString();

  // 是否加前缀0
  function addZero(str) {
    return str > 9 ? str : "0" + str;
  }
  month = addZero(month);
  day = addZero(day);
  hours = addZero(hours);
  minutes = addZero(minutes);
  seconds = addZero(seconds);

  // 中文数字 (星期)
  const week = {
    0: "Sun",
    1: "Mon",
    2: "Tue",
    3: "Wed",
    4: "Thu",
    5: "Fri",
    6: "Sat",
  };
  //   // 中文数字（季度）
  //   const quarter = {
  //     1: "一",
  //     2: "二",
  //     3: "三",
  //     4: "四",
  //   };
  let str = "";
  str +=
    year +
    "-" +
    month +
    "-" +
    day +
    " " +
    hours +
    ":" +
    minutes +
    ":" +
    seconds +
    " " +
    week[w] +
    " 第" +
    z +
    "周";
  return str;
}
export function getWeek(dateTime) {
  let temptTime = new Date(dateTime.getTime());
  // 周几
  let weekday = temptTime.getDay() || 7;
  // 周1+5天=周六
  temptTime.setDate(temptTime.getDate() - weekday + 1 + 5);
  let firstDay = new Date(temptTime.getFullYear(), 0, 1);
  let dayOfWeek = firstDay.getDay();
  let spendDay = 1;
  if (dayOfWeek != 0) spendDay = 7 - dayOfWeek + 1;
  firstDay = new Date(temptTime.getFullYear(), 0, 1 + spendDay);
  let d = Math.ceil((temptTime.valueOf() - firstDay.valueOf()) / 86400000);
  let result = Math.ceil(d / 7);
  return result;
}
