Esempio n. 1
0
    def alternate_hebrew_date(self):
        """Get the day's Hebrew date if it's before the alternate_nighttime

        The default TimeInfo.hebrew_date bases its date on sunset. Use this
        attribute to base the Hebrew date on the alternate date

        Returns:
            tuple -- hebrew date formated as (year, month, day)
        """

        if self.is_night():
            if self.date_time < self.alternate_nighttime():
                date_time = self.date_time

                greg_year = int(date_time.strftime("%Y"))
                greg_month = int(date_time.strftime("%m"))
                greg_day = int(date_time.strftime("%d"))

                alternate_hebrew_date = hebrew.from_gregorian(
                    greg_year, greg_month, greg_day)
            else:
                alternate_hebrew_date = self.hebrew_date()
        else:
            alternate_hebrew_date = self.hebrew_date()

        return alternate_hebrew_date
Esempio n. 2
0
def get_dates(birthday):
    dates = []
    first_year, month, day = hebrew.from_gregorian(*birthday)
    for year in range(first_year, first_year + MAX_AGE):
        gregorian_date = hebrew.to_gregorian(year, month, day)
        dates.append(date(*gregorian_date))
    return dates
Esempio n. 3
0
def get_hebrew_date(dt_obj:datetime) -> tuple:
    """

    :param dt_obj : datetime object
    :return: en date and he date for Hebrew date
    """
    from convertdate import hebrew
    months = [
        ("Nisan", "ניסן"),
        ("Iyar", "אייר"),
        ("Sivan", "סיוון"),
        ("Tammuz", "תמוז"),
        ("Av", "אב"),
        ("Elul", "אלול"),
        ("Tishrei", "תשרי"),
        ("Cheshvan", "חשון"),
        ("Kislev", "כסלו"),
        ("Tevet", "טבת"),
        ("Shevat", "שבט"),
        ("Adar", "אדר"),
        ("Adar II", "אדר ב׳"),
    ]
    y, m, d = hebrew.from_gregorian(dt_obj.year, dt_obj.month, dt_obj.day)
    en = "{} {}, {}".format(months[m-1][0], d, y)
    he = "{} {}, {}".format(months[m-1][1], d, y)
    return en, he
Esempio n. 4
0
def getHebrewCalendarDateName( n ):
    if not isinstance( n, RPNDateTime ):
        raise ValueError( 'time type required for this operator' )

    date = hebrew.from_gregorian( n.year, n.month, n.day )

    return hebrewDays[ n.weekday( ) ] + ', ' + hebrewMonths[ date[ 1 ] - 1 ] + \
           ' ' + str( date[ 2 ] ) + ', ' + str( date[ 0 ] )
Esempio n. 5
0
 def test_returntype(self):
     self.assertSequenceType(coptic.from_gregorian(2020, 6, 4), int)
     self.assertSequenceType(hebrew.from_gregorian(2020, 6, 4), int)
     self.assertSequenceType(islamic.from_gregorian(2020, 6, 4), int)
     self.assertSequenceType(indian_civil.from_gregorian(2020, 6, 4), int)
     self.assertSequenceType(iso.from_gregorian(2020, 6, 4), int)
     self.assertSequenceType(julian.from_gregorian(2020, 6, 4), int)
     self.assertSequenceType(persian.from_gregorian(2020, 6, 4), int)
Esempio n. 6
0
    def hebrew_date(self):
        """Return the Hebrew date as a tuple

        Returns:
            tuple -- Hebrew date (year, month, day)
        """
        if self.is_night() and self.is_pm():
            date_time = self.date_time + timedelta(days=1)
        else:
            date_time = self.date_time
        greg_year = int(date_time.strftime("%Y"))
        greg_month = int(date_time.strftime("%m"))
        greg_day = int(date_time.strftime("%d"))

        return hebrew.from_gregorian(greg_year, greg_month, greg_day)
Esempio n. 7
0
def plus_thirteen(greg):
	greg2 = greg + timedelta(days=1)
	(hy,hm,hd)= hebrew.from_gregorian(greg2.year,greg2.month,greg2.day)
	if hebrew.year_months(hy+13) >= hm:
		if  hebrew.month_days(hy+13,hm) >= hd:
			#month and day fit
			hdate = (hy+13,hm,hd)
		elif hebrew.year_months(hy+13) >= hm + 1:
			#another month in year, not enough days in month
			if (hm+1 == 7):
				hdate = (hy + 14,hm+1,1)
			else:
				hdate = (hy + 13,hm+1,1)
		else:
			#not enough months in year, not enough days in month
			hdate = (hy + 13, 1,1)
	else:
		#not enough months in year
		hdate = (hy+13,1,1)
	return hdate
Esempio n. 8
0
def get_rh(loc, lang):
    tz = f.get_tz_by_location(loc)
    tz_time = pytz.timezone(tz)
    now = datetime.now(tz_time)
    hebrew_date = hebrew.from_gregorian(now.year, now.month, now.day)
    # проверка на рош ашану
    if hebrew_date[1] == 6:
        hebrew_date = (
            hebrew_date[0],
            hebrew_date[1] + 1,
            hebrew_date[2]
        )
    url = f'{URL}/getHolidayCalData.php?hebrewYear={hebrew_date[0]}'
    chodesh_dict = get_chodesh_dict(hebrew_date, url)
    length_of_rh = get_rh_lenght(hebrew_date)
    length_str = f'{length_of_rh}'

    if lang == 'Русский':
        rh = 'Месяц: {month}\n' \
             'Продолжительность Рош Ходеша: {length} {length_r}\n' \
             'Рош Ходеш: {rh}\n' \
             'Молад: {mol}'.format(
                month=data.jewish_months[get_month_name(chodesh_dict)],
                length=length_str,
                length_r=data.length_r[length_str],
                rh=get_rh_date_and_day(hebrew_date, length_of_rh, lang),
                mol=get_molad(chodesh_dict, lang)
             )
    elif lang == 'English':
        rh = 'Month: {month}\n' \
             'Rosh Chodesh duration: {length} {length_r}\n' \
             'Rosh Chodesh: {rh}\n' \
             'Molad: {mol}'.format(
                month=get_month_name(chodesh_dict),
                length=length_str,
                length_r=data.length_e[length_str],
                rh=get_rh_date_and_day(hebrew_date, length_of_rh, lang),
                mol=get_molad(chodesh_dict, lang)
             )
    return rh
Esempio n. 9
0
def getHebrewCalendarDateNameOperator( n ):
    date = hebrew.from_gregorian( n.year, n.month, n.day )

    return hebrewDays[ n.weekday( ) ] + ', ' + hebrewMonths[ date[ 1 ] - 1 ] + \
           ' ' + str( date[ 2 ] ) + ', ' + str( date[ 0 ] )
Esempio n. 10
0
def getHebrewCalendarDateOperator( n ):
    return list( hebrew.from_gregorian( n.year, n.month, n.day ) )
Esempio n. 11
0
def moonphase(year, month, day, do_print=False):
    h = year // 100             # integer division for the century
    yy = year % 100             # year within the century

    # The "golden number" for this year is the year modulo 19, but
    # adjusted to be centered around 0 -- i.e., -9 to 9 instead
    # of 0 to 19.  This improves the accuracy of the approximation
    # to within +/- 1 day.
    g = (yy + 9) % 19 - 9

    # There is an interesting 6 century near-repetition in the
    # century correction.  It would be interesting to find a
    # algorithm that handles the different corrections between
    # centuries 17|23|29, 20|26, 21|27, and 24|30.

    try:
        c = {17:7,
             18:1, 19:-4, 20:-8, 21:16, 22:11, 23:6,
             24:1, 25:-4, 26:-9, 27:15, 28:11, 29:6,
             30:0}[h]
    except KeyError:
        print("No century correction available for {}00-{}99".format(h,h))
        return

    # Golden number correction:  modulo 30, from -29 to 29.
    gc = g * 11
    while ( gc < -29 ): gc += 30;
    if (gc > 0): gc %= 30;

    # January/February correction:
    if month < 3:
       mc = 2
    else:
       mc = 0

    phase = (month + mc + day + gc + c + 30 ) % 30

    if (do_print):
        # It's nice to see what the Golden correction for the year
        # plus the century correction is.  This lets us quickly calculate the
        # correction for any other date in the same year.
        gcpc = (gc + c) % 30
        if gcpc <= 0:
            gcpc_alt = gcpc + 30
        else:
            gcpc_alt = gcpc - 30

        print("yy =", yy)
        print("g =", g)
        print("month + day + mc =", month + day + mc)
        print("gc =", gc)
        print("c =", c)
        print("Dates in the year", year,
              "have moon phase correction gc + c =",
              gcpc, "or", gcpc_alt)
        print(("\n\t{:04}/{:02}/{:02} has "
               "estimated moon phase = {}\n").format(year,
                                                   month,
                                                   day,
                                                   phase))
        if phase < 2:
            print("\tNew moon [or slightly after]")
        elif phase < 7:
            print("\tWaxing crescent")
        elif phase < 9:
            print("\tFirst quarter")
        elif phase < 14:
            print("\tWaxing gibbous")
        elif phase < 16:
            print("\tFull moon")
        elif phase < 22:
            print("\tWaning gibbous")
        elif phase < 24:
            print("\tLast quarter")
        elif phase < 29:
            print("\tWaning (de)crescent")
        elif phase < 31:
            print("\tNew moon [or slightly before]")

        try:
            # If you have the ephem package installed, you
            # can compare the estimate to the actual lunar phase
            import ephem
            thisdate = ephem.Date('{:04}/{:02}/{:02} 00:00:01'.format(year, month, day))
            prevmoon = ephem.previous_new_moon(thisdate)
            nextmoon = ephem.next_new_moon(thisdate)
            prevfull = ephem.previous_full_moon(thisdate)
            nextfull = ephem.next_full_moon(thisdate)
            prevymd = prevmoon.tuple()[:3]
            nextymd = nextmoon.tuple()[:3]
            pfymd = prevfull.tuple()[:3]
            nfymd = nextfull.tuple()[:3]
            print("\n\t{}".format(prevmoon), "UTC = Previous New Moon")
            print("\t{}".format(nextmoon), "UTC = Next New Moon")
            print("\t{}".format(prevfull), "UTC = Previous Full Moon")
            print("\t{}".format(nextfull), "UTC = Next Full Moon")
            try:
                from convertdate import julianday
                thisjdc = julianday.from_gregorian(year, month, day)
                prevjdc = julianday.from_gregorian(*prevymd)
                nextjdc = julianday.from_gregorian(*nextymd)
                pfjdc = julianday.from_gregorian(*pfymd)
                nfjdc = julianday.from_gregorian(*nfymd)
                print("\t{:2} days since prev new moon".format(int(thisjdc - prevjdc)))
                print("\t{:2} days until next new moon".format(int(nextjdc - thisjdc)))
                print("\t{:2} days since prev full moon".format(int(thisjdc - pfjdc)))
                print("\t{:2} days until next full moon".format(int(nfjdc - thisjdc)))
            except:
                print("julianday doesn't work")
                pass
        except:
            pass

        try:
            # If you have convertdate installed, you can compare the lunar
            # phase to the hebrew calendar date:
            from convertdate import hebrew
            hyear, hmonth, hday = hebrew.from_gregorian(year, month, day)
            print("\n\tHebrew date = {} {}, {}\n".format( hday,
                                                          hmonths[hmonth],
                                                          hyear ))
        except:
            pass
    return phase
Esempio n. 12
0
def moonphase(year, month, day, do_print=False):
    h = year // 100  # integer division for the century
    yy = year % 100  # year within the century

    # The "golden number" for this year is the year modulo 19, but
    # adjusted to be centered around 0 -- i.e., -9 to 9 instead
    # of 0 to 19.  This improves the accuracy of the approximation
    # to within +/- 1 day.
    g = (yy + 9) % 19 - 9

    # There is an interesting 6 century near-repetition in the
    # century correction.  It would be interesting to find a
    # algorithm that handles the different corrections between
    # centuries 17|23|29, 20|26, 21|27, and 24|30.

    try:
        c = {
            17: 7,
            18: 1,
            19: -4,
            20: -8,
            21: 16,
            22: 11,
            23: 6,
            24: 1,
            25: -4,
            26: -9,
            27: 15,
            28: 11,
            29: 6,
            30: 0
        }[h]
    except KeyError:
        print("No century correction available for {}00-{}99".format(h, h))
        return

    # Golden number correction:  modulo 30, from -29 to 29.
    gc = g * 11
    while (gc < -29):
        gc += 30
    if (gc > 0): gc %= 30

    # January/February correction:
    if month < 3:
        mc = 2
    else:
        mc = 0

    phase = (month + mc + day + gc + c + 30) % 30

    if (do_print):
        # It's nice to see what the Golden correction for the year
        # plus the century correction is.  This lets us quickly calculate the
        # correction for any other date in the same year.
        gcpc = (gc + c) % 30
        if gcpc <= 0:
            gcpc_alt = gcpc + 30
        else:
            gcpc_alt = gcpc - 30

        print("yy =", yy)
        print("g =", g)
        print("month + day + mc =", month + day + mc)
        print("gc =", gc)
        print("c =", c)
        print("Dates in the year", year, "have moon phase correction gc + c =",
              gcpc, "or", gcpc_alt)
        print(("\n\t{:04}/{:02}/{:02} has "
               "estimated moon phase = {}\n").format(year, month, day, phase))
        if phase < 2:
            print("\tNew moon [or slightly after]")
        elif phase < 7:
            print("\tWaxing crescent")
        elif phase < 9:
            print("\tFirst quarter")
        elif phase < 14:
            print("\tWaxing gibbous")
        elif phase < 16:
            print("\tFull moon")
        elif phase < 22:
            print("\tWaning gibbous")
        elif phase < 24:
            print("\tLast quarter")
        elif phase < 29:
            print("\tWaning (de)crescent")
        elif phase < 31:
            print("\tNew moon [or slightly before]")

        try:
            # If you have the ephem package installed, you
            # can compare the estimate to the actual lunar phase
            import ephem
            thisdate = ephem.Date('{:04}/{:02}/{:02} 00:00:01'.format(
                year, month, day))
            prevmoon = ephem.previous_new_moon(thisdate)
            nextmoon = ephem.next_new_moon(thisdate)
            prevfull = ephem.previous_full_moon(thisdate)
            nextfull = ephem.next_full_moon(thisdate)
            prevymd = prevmoon.tuple()[:3]
            nextymd = nextmoon.tuple()[:3]
            pfymd = prevfull.tuple()[:3]
            nfymd = nextfull.tuple()[:3]
            print("\n\t{}".format(prevmoon), "UTC = Previous New Moon")
            print("\t{}".format(nextmoon), "UTC = Next New Moon")
            print("\t{}".format(prevfull), "UTC = Previous Full Moon")
            print("\t{}".format(nextfull), "UTC = Next Full Moon")
            try:
                from convertdate import julianday
                thisjdc = julianday.from_gregorian(year, month, day)
                prevjdc = julianday.from_gregorian(*prevymd)
                nextjdc = julianday.from_gregorian(*nextymd)
                pfjdc = julianday.from_gregorian(*pfymd)
                nfjdc = julianday.from_gregorian(*nfymd)
                print("\t{:2} days since prev new moon".format(
                    int(thisjdc - prevjdc)))
                print("\t{:2} days until next new moon".format(
                    int(nextjdc - thisjdc)))
                print("\t{:2} days since prev full moon".format(
                    int(thisjdc - pfjdc)))
                print("\t{:2} days until next full moon".format(
                    int(nfjdc - thisjdc)))
            except:
                print("julianday doesn't work")
                pass
        except:
            pass

        try:
            # If you have convertdate installed, you can compare the lunar
            # phase to the hebrew calendar date:
            from convertdate import hebrew
            hyear, hmonth, hday = hebrew.from_gregorian(year, month, day)
            print("\n\tHebrew date = {} {}, {}\n".format(
                hday, hmonths[hmonth], hyear))
        except:
            pass
    return phase
Esempio n. 13
0
def do_the_things(lat, lon, chagdays=2, offset=0):
    tf = TimezoneFinder()
    tzname = tf.timezone_at(lng=lon, lat=lat)
    try:
        tz = pytz.timezone(tzname)
    except pytz.exceptions.UnknownTimeZoneError:
        tz = pytz.timezone('UTC')

    now = datetime.datetime.now(tz=tz)
    if offset is not None:
        now += datetime.timedelta(minutes=offset)
    noon = tz.localize(
        datetime.datetime(year=now.year,
                          month=now.month,
                          day=now.day,
                          hour=12,
                          minute=30))
    today = now.date()
    tomorrow = today + datetime.timedelta(days=1)

    # Get Hebrew calendar dates
    hebtoday = hebrew.from_gregorian(today.year, today.month, today.day)
    hebtomorrow = hebrew.from_gregorian(tomorrow.year, tomorrow.month,
                                        tomorrow.day)
    hebmonthtoday = hebrew_monthname(hebtoday)
    hebmonthtomorrow = hebrew_monthname(hebtomorrow)
    omertoday = omer_day(hebtoday)
    omertonight = omer_day(hebtomorrow)

    # Set up ephem info to determine sunset and nightfall
    herenow = ephem.Observer()
    herenow.lat, herenow.lon = lat * ephem.pi / 180, lon * ephem.pi / 180
    herenow.date = ephem.Date(now.astimezone(pytz.utc))
    herenoon = ephem.Observer()
    herenoon.lat, herenoon.lon = lat * ephem.pi / 180, lon * ephem.pi / 180
    herenoon.date = ephem.Date(noon.astimezone(pytz.utc))
    sun = ephem.Sun()

    # Determine "set" and "dark" for today (may be in the past)
    try:
        todayrise_eph = herenoon.previous_rising(sun)
        todayrise = pytz.utc.localize(todayrise_eph.datetime()).astimezone(tz)
        todayrise_txt = todayrise.isoformat(timespec='seconds')
        tonightset_eph = herenoon.next_setting(sun)
        tonightset = pytz.utc.localize(
            tonightset_eph.datetime()).astimezone(tz)
        tonightset_txt = tonightset.isoformat(timespec='seconds')
    except ephem.NeverUpError:
        todayrise_txt = 'downallday'
        tonightset_txt = 'downallday'
    except ephem.AlwaysUpError:
        todayrise_txt = 'upallday'
        tonightset_txt = 'upallday'
    oldhorizon = herenoon.horizon
    oldpressure = herenoon.pressure
    herenoon.pressure = 0
    # All horizon math is from top of sun disk
    # We need to take into account sun's radius, averaging .266 degrees
    herenoon.horizon = "-8.233"  # middle of sun 8.5 deg
    try:
        tonightdark_eph = herenoon.next_setting(sun)
        tonightdark = pytz.utc.localize(
            tonightdark_eph.datetime()).astimezone(tz)
        tonightdark_txt = tonightdark.isoformat(timespec='seconds')
    except ephem.NeverUpError:
        tonightdark_txt = 'alwaysdark'
    except ephem.AlwaysUpError:
        tonightdark_txt = 'none'
    herenoon.horizon = oldhorizon
    herenoon.pressure = oldpressure

    # Status of sun, handle no-rise/no-set cases first
    if todayrise_txt == "upallday":
        sunnow = "up"
    elif (todayrise_txt == 'downallday'
          and (tonightdark == 'alwaysdark' or tonightdark < now)):
        sunnow = "down"
    elif todayrise_txt == 'downallday':
        sunnow = "twilight"
    # normal cases
    elif todayrise > now:
        sunnow = "notyetup"
    elif tonightset > now:
        sunnow = "up"
    elif (tonightdark_txt == 'none' or tonightdark > now):
        sunnow = "twilight"
    else:
        sunnow = "down"

    # Is it Shabbat or a holiday?
    shabbat_or_holiday_today = (today.isoweekday() == 6)
    if (jewish_holiday(date=hebtoday, chagdays=chagdays)):
        shabbat_or_holiday_today = True
    shabbat_or_holiday_tonight = (today.isoweekday() == 5)
    if (jewish_holiday(date=hebtomorrow, chagdays=chagdays)):
        shabbat_or_holiday_tonight = True

    # Combine hebdate logic and shabbat/holiday logic with sun up/down logic
    if (sunnow == "notyetup" or sunnow == "up"):
        shabbat_or_holiday_now = shabbat_or_holiday_today
        hebrew_date_now = "{} {}, {}".format(hebtoday[2], hebmonthtoday,
                                             hebtoday[0])
        omernow = omertoday
    elif (sunnow == "down"):
        shabbat_or_holiday_now = shabbat_or_holiday_tonight
        hebrew_date_now = "{} {}, {}".format(hebtomorrow[2], hebmonthtomorrow,
                                             hebtomorrow[0])
        omernow = omertonight
    elif (sunnow == "twilight"):
        shabbat_or_holiday_now = (shabbat_or_holiday_today
                                  or shabbat_or_holiday_tonight)
        hebrew_date_now = "indeterminate"
        if omertoday > 0 and omertonight > 0:
            omernow = omertoday + 0.5
        else:
            omernow = 0
    else:
        raise ValueError("How is the sun not up or down or twilight?")

    # time for output
    to_return = {}
    to_return["results"] = {
        "now":
        now.astimezone(tz).isoformat(timespec='seconds'),
        "sunrise":
        todayrise_txt,
        "sunset":
        tonightset_txt,
        "jewish_twilight_end":
        tonightdark_txt,
        "sun_now":
        sunnow,
        "hebrew_date_today":
        "{} {}, {}".format(hebtoday[2], hebmonthtoday, hebtoday[0]),
        "hebrew_date_tonight":
        "{} {}, {}".format(hebtomorrow[2], hebmonthtomorrow, hebtomorrow[0]),
        "hebrew_date_now":
        hebrew_date_now,
        "shabbat_or_yom_tov_today":
        shabbat_or_holiday_today,
        "shabbat_or_yom_tov_tonight":
        shabbat_or_holiday_tonight,
        "shabbat_or_yom_tov_now":
        shabbat_or_holiday_now,
    }
    if omertoday > 0:
        to_return["results"]["omer_today"] = omertoday
    if omertonight > 0:
        to_return["results"]["omer_tonight"] = omertonight
    if omernow > 0:
        to_return["results"]["omer_now"] = omernow

    return json.dumps(to_return)
Esempio n. 14
0
def to_heb_year_month_day(d):
    return hebrew.from_gregorian(d.year, d.month, d.day)
Esempio n. 15
0
import pandas as pd
from dateutil import rrule, parser
from convertdate import hebrew

date1 = '2001-01-01'
date2 = '2020-01-01'
datesx = list(
    rrule.rrule(rrule.DAILY,
                dtstart=parser.parse(date1),
                until=parser.parse(date2)))

hebrewCalendar = pd.DataFrame()
hebrewCalendar['date'] = datesx

hebrewCalendar['hebrewDate'] = hebrewCalendar['date'].apply(
    lambda x: hebrew.from_gregorian(x.year, x.month, x.day))

hebrewCalendar['hebrewMonth'] = hebrewCalendar['hebrewDate'].apply(
    lambda x: x[1])
hebrewCalendar['hebrewYear'] = hebrewCalendar['hebrewDate'].apply(
    lambda x: x[0])

Hebrew_months = {
    1: 'NISAN',
    2: 'IYYAR',
    3: 'SIVAN',
    4: 'TAMMUZ',
    5: 'AV',
    6: 'ELUL',
    7: 'TISHRI',
    8: 'HESHVAN',
Esempio n. 16
0
# !/usr/bin/env python
# -*- coding: utf-8 -*-

# Load all the settings from the json file
with open('settings.json') as s:
    obj = s.read()
    settings = json.loads(obj)
    SENDER_EMAIL = settings["SENDER_EMAIL"]
    SENDER_PASSWORD = settings["SENDER_PASSWORD"]
    TIME = settings["TIME"]

# Get today and convert it to Hebrew
today_gregorian_date = datetime.datetime.now()
today_hebrew_date = dates.HebrewDate.today()
year = hebrew.from_gregorian(today_gregorian_date.year,
                             today_gregorian_date.month,
                             today_gregorian_date.day)
year = year[0]  # This Hebrew Year
two_weeks_from_today = today_hebrew_date + 14

# Collect all the deceased info in separated arrays
deceased_month = []
deceased_day = []
deceased_donor = []
deceased_relation = []
deceased_name = []
deceased_SoD = []
deceased_email = []

# Array for ALL the email addresses
all_emails = []
Esempio n. 17
0
def getHebDate(date):
    """Returns the year, month, day of the Hebrew date for a DateTime object"""
    day = date.day
    month = date.month
    year = date.year
    return hebrew.from_gregorian(year, month, day)
Esempio n. 18
0
	blackouts.append(cycle_blackouts[cycle_blackout_index])
except:
	pass
try:
	blackouts.append(cycle_blackouts2[cycle_blackout_index2])
except:
	pass
blackout_inds = [dt_to_week(parse(d).date(),sat) for d in blackouts]


for person in people:
	# bnei_bday = parse(person['DOB']).date() + relativedelta(years=12 if person.get('Gender')=='f' else 13)
	dob = parse(person['dob']).date()
	if dob.year == 2018:
		dob = dob.replace(year=2008)
	hdob= hebrew.from_gregorian(*unpack(dob)) #year,month,day (hebrew)
	hbmbd = plus_thirteen(dob)
	gbmbd = hebrew.to_gregorian(*hbmbd)
	bmdate = next_sat(*gbmbd)
	hbmdate = hebrew.from_gregorian(*bmdate)
	weeks_til = dt_to_week(date(*bmdate),sat)
	earliest = max(0,weeks_til - early_threshold)
	latest = weeks_til + late_threshold
	days_before_sat = (date(year = bmdate[0],month=bmdate[1],day=bmdate[2]) - date(year = gbmbd[0], month = gbmbd[1],day= gbmbd[2])).days
	# print(f"bmdate is {date(year = bmdate[0],month=bmdate[1],day=bmdate[2]).strftime('%A, %B %d, %Y')}, gbmbd is {date(year = gbmbd[0], month = gbmbd[1],day= gbmbd[2]).strftime('%A, %B %d, %Y')}, and days_before_sat is {days_before_sat}\n")
	nondates = []
	notes = ''
	for key in nondatekeys:
		if (person[key] is not None) and (person[key] != ''):
			nd=parse(person[key]).date()
			if nd.year==21:
Esempio n. 19
0
def getHebrewCalendarDate( n ):
    if not isinstance( n, RPNDateTime ):
        raise ValueError( 'time type required for this operator' )

    return list( hebrew.from_gregorian( n.year, n.month, n.day ) )
Esempio n. 20
0
def plus_thirteen2(greg):
	greg2 = greg + timedelta(days=1)
	(hy,hm,hd)= hebrew.from_gregorian(greg2.year,greg2.month,greg2.day)
	h = hebrew.to_jd_gregorianyear(greg2.year+13,hm,hd)
	print(f"Converted gregorian {greg2} to hebrew {h}")
	return h