Skip to content

Instantly share code, notes, and snippets.

@6mini
Created May 16, 2024 07:06
Show Gist options
  • Save 6mini/a348c74431babc69e9cef6115bfb7b00 to your computer and use it in GitHub Desktop.
Save 6mini/a348c74431babc69e9cef6115bfb7b00 to your computer and use it in GitHub Desktop.
이 스크립트는 현재 시각이 대한민국에서 영업일인지 여부를 확인한다. UTC 시간을 KST로 변환하고, 현재 요일이 평일인지와 공휴일 여부를 확인하여 프로그램 실행 여부를 결정한다. 이를 통해 프로그램이 한국의 영업일에만 동작하도록 한다.
from datetime import datetime, timedelta
from holidayskr import today_is_holiday
def check_if_business_day():
# 현재 UTC 시간
now_utc = datetime.utcnow()
# 한국 시간
kst_offset = timedelta(hours=9)
now_kst = now_utc + kst_offset
# 평일 확인 (월요일=0, 일요일=6)
is_weekday = now_kst.weekday() < 5
# 공휴일 확인
is_holiday = today_is_holiday()
return is_weekday and not is_holiday
def main_program_function():
# 여기에 프로그램의 주요 기능을 구현
print("프로그램을 실행합니다.")
if check_if_business_day():
main_program_function()
else:
print("오늘은 휴일이므로 프로그램이 실행되지 않습니다.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment