Skip to content

Instantly share code, notes, and snippets.

@GuyKh
Last active December 20, 2021 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GuyKh/486890acf15826fdd62e1265bbf0fe5f to your computer and use it in GitHub Desktop.
Save GuyKh/486890acf15826fdd62e1265bbf0fe5f to your computer and use it in GitHub Desktop.
HebrewDate to GregorianDate
#!/usr/bin/env python3
import sys
from hebrew_numbers import gematria_to_int
from pyluach import dates
def main(args):
print (args)
if len(args) != 3:
print ("Wrong number of arguments")
return
day = int(args[0]) if args[0].isnumeric() else gematria_to_int(args[0])
year = int(args[2]) if args[2].isnumeric() else gematria_to_int(args[2])
month = getMonth(args[1])
hebDate = dates.HebrewDate(year, month, day)
gregDate = hebDate.to_greg()
print (str(gregDate.day) + "/" + str(gregDate.month) + "/" + str(gregDate.year))
def getMonth(month):
hebMonth = 0
if (month == "ניסן" or month == "Nissan"):
hebMonth = 1
elif (month == "אייר" or month == "Iyar"):
hebMonth = 2
elif (month == "סיון" or month == "סיון" or month == "Sivan"):
hebMonth = 3
elif (month == "תמוז" or month == "Tamuz" or month == "Tammuz"):
hebMonth = 4
elif (month == "אב" or month == "Av"):
hebMonth = 5
elif (month == "אלול" or month == "Elul"):
hebMonth = 6
elif (month == "תשרי" or month == "Tishrei"):
hebMonth = 7
elif (month == "חשוון" or month == "חשון" or month == "Heshvan" or month == "Cheshvan"):
hebMonth = 8
elif (month == "כסלו" or month == "Kislev"):
hebMonth = 9
elif (month == "טבת" or month == "Tevet"):
hebMonth = 10
elif (month == "שבט" or month == "Shvat"):
hebMonth = 11
elif (month == "אדר א'" or month == "Adar I" or month == "Adar"):
hebMonth = 12
elif (month == "אדר ב'" or month == "Adar II"):
hebMonth = 13
return hebMonth
if __name__ == "__main__":
main(sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment