guanghulab/scripts/gdrive/check-hibernation.js
Guanghu Domestic Migration d1e47f4565
Some checks are pending
自动更新代码和重启 / update-and-restart (push) Waiting to run
CI检查 + 自动部署 / check (push) Waiting to run
CI检查 + 自动部署 / deploy (push) Blocked by required conditions
重启聊天服务 / restart (push) Waiting to run
chore: import sanitized domestic snapshot for REPO-002
Source snapshot: ca48d3ddf926d79aa138306164169baf764bb829
2026-07-17 15:54:41 +08:00

41 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* check-hibernation.js
*
* 检查当前是否在天眼休眠期内
*
* 休眠规则(从天眼治理层配置读取):
* - 周休眠:每周六 20:00 ~ 00:00 CST4小时
* - 日休眠:每日 04:00 ~ 04:10 CST默认窗口
*
* 对于生命线任务:输出提示但不阻止执行
* 对于普通任务:输出提示并建议延迟
*
* 守护: PER-ZY001 铸渊
* 系统: SYS-GLW-0001
* 主控: TCS-0002∞ 冰朔
*/
function isInHibernation() {
const now = new Date();
// 转换为北京时间UTC+8使用 UTC 偏移计算避免 locale 差异
const utcMs = now.getTime() + now.getTimezoneOffset() * 60 * 1000;
const cst = new Date(utcMs + 8 * 60 * 60 * 1000);
const day = cst.getDay(); // 0=周日, 6=周六
const hour = cst.getHours();
const minute = cst.getMinutes();
// 周休眠:周六 20:00 ~ 周日 00:00
if (day === 6 && hour >= 20) {
return { hibernating: true, type: 'weekly', endsAt: '周日 00:00 CST' };
}
// 日休眠:每日 04:00 ~ 04:10默认窗口
if (hour === 4 && minute < 10) {
return { hibernating: true, type: 'daily', endsAt: '04:10 CST' };
}
return { hibernating: false };
}
module.exports = { isInHibernation };