Commit 1d6237f2 by Haohao Jiang

fix: only trigger at Monday 11am in Beijing

parent 7b54de04
docker build -t reg.i.strikingly.com/falcon:v0.7 .
docker push reg.i.strikingly.com/falcon:v0.7
\ No newline at end of file
docker build -t reg.i.strikingly.com/falcon:v0.7.2 .
docker push reg.i.strikingly.com/falcon:v0.7.2
......@@ -15,7 +15,7 @@ async function main() {
if (shouldRun) {
task_trigger = "should_run_tasks";
await redis.del("falcon:should_run_tasks");
} else if (isMonday11AM()) {
} else if (isMonday11AMInBeijing()) {
const mondayKey = "falcon:monday_11am_executed";
const alreadyExecuted = await redis.get(mondayKey);
if (alreadyExecuted) {
......@@ -99,9 +99,23 @@ async function main() {
process.exit(0);
}
function isMonday11AM() {
function isMonday11AMInBeijing() {
const now = new Date();
return now.getDay() === 1 && now.getHours() === 11;
// 获取北京时间的各项
const formatter = new Intl.DateTimeFormat('zh-CN', {
timeZone: 'Asia/Shanghai',
hour12: false,
weekday: 'short',
hour: '2-digit'
});
const parts = formatter.formatToParts(now);
const weekday = parts.find(p => p.type === 'weekday')?.value;
const hour = Number(parts.find(p => p.type === 'hour')?.value);
console.log('[isMonday11AMInBeijing] weekday:', weekday, 'hour:', hour);
// 周一11点
return (weekday === '周一' || weekday === 'Mon') && hour === 11;
}
// 调用入口
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment