Last active
March 4, 2022 02:03
-
-
Save mitoma/4509618 to your computer and use it in GitHub Desktop.
shellでGoogleカレンダーから祝日を判定するにはこういう風に判定するといい。jenkinsなどで祝日稼働したくないジョブがあるときに便利だと思う。
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
#!/bin/sh | |
# 独自で休日を定義する場合は独自で作ったGoogleカレンダーのIDを指定する | |
# ここで指定しているカレンダーは公開カレンダー「日本の休日」 | |
CALENDAR_ID='ja.japanese%23holiday%40group.v.calendar.google.com' | |
# GoogleカレンダーのAPI KEYを設定する。 | |
API_KEY='API KEY' | |
DATE=`date +%Y-%m-%d` | |
MIN_TIME="${DATE}T00%3A00%3A00.000Z" | |
MAX_TIME="${DATE}T00%3A00%3A01.000Z" | |
URL="https://www.googleapis.com/calendar/v3/calendars/${CALENDAR_ID}/events?timeMax=${MAX_TIME}&timeMin=${MIN_TIME}&key=${API_KEY}" | |
# FIXME バグっとるらしい | |
IS_HOLIDAY=`curl -s "${URL}" | grep items | wc -l` | |
if [ ${IS_HOLIDAY} -gt 0 ] | |
then | |
echo "holiday" | |
else | |
echo "not holiday" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
スクリプトの中のMIN_TIMEとMAX_TIMEはどういう役割なのか教えていただけますか?