|
|
@@ -6,6 +6,21 @@ export function timeFix() {
|
|
|
return hour < 9 ? '早上好' : hour <= 11 ? '上午好' : hour <= 13 ? '中午好' : hour < 20 ? '下午好' : '晚上好'
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 学期判断
|
|
|
+ * 返回 [学期开始时间戳, 当前时间戳]
|
|
|
+ */
|
|
|
+export function getSemesterTimestamps() {
|
|
|
+ const now = new Date()
|
|
|
+ const year = now.getFullYear()
|
|
|
+ const feb1ThisYear = new Date(year, 1, 1, 0, 0, 0, 0) // 当年 2-01
|
|
|
+ const aug31ThisYear = new Date(year, 7, 31, 0, 0, 0, 0) // 当年 8-31
|
|
|
+ // 下学期:2 月 1 日 ~ 8 月 31 日
|
|
|
+ // 上学期:8 月 31 日 ~ 次年 2 月 1 日
|
|
|
+ // 1 月属于上一年的上学期
|
|
|
+ return [(now >= feb1ThisYear && now < aug31ThisYear) ? feb1ThisYear : new Date(now < feb1ThisYear ? year - 1 : year, 7, 31, 0, 0, 0, 0).getTime(), now.getTime()]
|
|
|
+}
|
|
|
+
|
|
|
export async function getNotice(key) {
|
|
|
try {
|
|
|
const res = await GetNotice({ key })
|