Created
August 21, 2018 21:28
-
-
Save ohadeytan/e981ea7810d6c5d199197b8c31466049 to your computer and use it in GitHub Desktop.
Python script for checking if today is Shabat or Chag (Jewish holiday)
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
from datetime import date | |
from datetime import datetime | |
from datetime import timedelta | |
import convertdate | |
def shabaton(t, eve=False): | |
if t.weekday() == 5 - 1 if eve else 0: | |
return True | |
if t == date(*convertdate.holidays.rosh_hashanah(t.year, eve)): | |
return True | |
if t == date(*convertdate.holidays.rosh_hashanah(t.year, eve)) + timedelta(days=1): | |
return True | |
if t == date(*convertdate.holidays.yom_kippur(t.year, eve)): | |
return True | |
if t == date(*convertdate.holidays.sukkot(t.year, eve)): | |
return True | |
if t == date(*convertdate.holidays.sukkot(t.year, eve)) + timedelta(days=7): | |
return True | |
if t == date(*convertdate.holidays.passover(t.year, eve)): | |
return True | |
if t == date(*convertdate.holidays.passover(t.year, eve)) + timedelta(days=6): | |
return True | |
if t == date(*convertdate.holidays.shavuot(t.year, eve)): | |
return True | |
return False | |
def main(): | |
t = date.today() | |
sh = shabaton(t, False) | |
esh = shabaton(t, True) | |
if sh: | |
print('Today is Shabat or Chag') | |
elif esh: | |
print('Today is Erev Shabat or Chag') | |
else: | |
print('Today is a regurlar day') | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment