Skip to content

Instantly share code, notes, and snippets.

@ohadeytan
Created August 21, 2018 21:28
Show Gist options
  • Save ohadeytan/e981ea7810d6c5d199197b8c31466049 to your computer and use it in GitHub Desktop.
Save ohadeytan/e981ea7810d6c5d199197b8c31466049 to your computer and use it in GitHub Desktop.

Revisions

  1. ohadeytan created this gist Aug 21, 2018.
    39 changes: 39 additions & 0 deletions shabaton.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    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()