exclude market closing day

This commit is contained in:
SeungJu Lim 2025-02-01 23:34:45 +09:00
parent 31f04afd8b
commit 03e12861df
1 changed files with 7 additions and 7 deletions

View File

@ -4,20 +4,20 @@ import { isDaylightSavingTime } from '../feature/utility.js';
export function initializeCronJobs(client) { export function initializeCronJobs(client) {
const channel = client.channels.cache.get(process.env.CH_FINANCE); const channel = client.channels.cache.get(process.env.CH_FINANCE);
// 미국 주식 시장 개장 시간 // 미국 주식 시장 개장 시간 (월~금)
const openTime = isDaylightSavingTime() ? '30 22 * * *' : '30 23 * * *'; const openTime = isDaylightSavingTime() ? '30 22 * * 1-5' : '30 23 * * 1-5';
const openJob = new CronJob(openTime, async () => { const openJob = new CronJob(openTime, async () => {
if (channel) { if (channel) {
const isDST = isDaylightSavingTime(); const isDST = isDaylightSavingTime();
const dstMessage = isDST const dstMessage = isDST
? '현재 서머타임이 적용 중입니다.' ? '(서머타임 적용됨)'
: '현재 서머타임이 적용되지 않았습니다.'; : '(서머타임 적용되지 않음)';
await channel.send(`미국 주식 시장이 열렸습니다.\n${dstMessage}`); await channel.send(`미국 주식 시장이 열렸습니다. ${dstMessage}`);
} }
}, null, true, 'Asia/Seoul'); }, null, true, 'Asia/Seoul');
// 미국 주식 시장 폐장 시간 // 미국 주식 시장 폐장 시간 (월~금)
const closeTime = isDaylightSavingTime() ? '0 5 * * *' : '0 6 * * *'; const closeTime = isDaylightSavingTime() ? '0 5 * * 1-5' : '0 6 * * 1-5';
const closeJob = new CronJob(closeTime, async () => { const closeJob = new CronJob(closeTime, async () => {
if (channel) { if (channel) {
await channel.send('미국 주식 시장이 닫혔습니다.'); await channel.send('미국 주식 시장이 닫혔습니다.');