import dayjs from "dayjs";

function getCurrentTermString() {
  let now = dayjs();

  return getTermString(now);
}

function getTermString(date) {
  let month = date.month() + 1;
  let year = date.year();

  if (month >= 2 && month <= 6) {
    return `${year - 1}-${year}-2`;
  }

  if (month >= 7 && month <= 12) {
    return `${year}-${year + 1}-1`;
  } else if (month === 1) {
    return `${year - 1}-${year}-1`;
  }

  // 不可能到达的部分
  return `${year - 1}-${year}-1`;
}

export default {
  getCurrentTermString,
  getTermString
}
