Skip to content

Instantly share code, notes, and snippets.

@potato4d
Created November 2, 2021 03:55
Show Gist options
  • Save potato4d/d96905422a842dfc31678aa9f38a45a6 to your computer and use it in GitHub Desktop.
Save potato4d/d96905422a842dfc31678aa9f38a45a6 to your computer and use it in GitHub Desktop.
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