Created
November 2, 2021 03:55
-
-
Save potato4d/d96905422a842dfc31678aa9f38a45a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = require('axios') | |
const dayjs = require('dayjs') | |
const utc = require('dayjs/plugin/utc') | |
const timezone = require('dayjs/plugin/timezone') | |
const customHolidays = require('./custom_holidays') | |
dayjs.extend(utc) | |
dayjs.extend(timezone) | |
async function run() { | |
try { | |
const { data } = await axios.get('https://holidays-jp.github.io/api/v1/date.json') | |
const holidays = [ | |
...Object.keys(data), | |
customHolidays | |
] | |
if (holidays.includes(dayjs().tz('Asia/Tokyo').format('YYYY-MM-DD'))) { | |
console.log('Today is holiday.') | |
process.exit(1) | |
} else { | |
console.log('Today is not holiday.') | |
process.exit(0) | |
} | |
} catch(e) { | |
console.error(e) | |
process.exit(1) | |
} | |
} | |
run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment