def get_first_perek(jd, israel):
    jyear = jd.year
    jmonth = jd.month
    jday = jd.day
    pes1 = JDate.create(jyear, 1, 15)
    # How many days after the first day of pesach was the first shabbos after pesach
    shb1 = (7 if israel else 8) + (6 - pes1.getdow())
    # What number shabbos after pesach is the current date
    cshb = (1 if (jmonth == 1 and jday == (shb1 + 15)) else int(
        (jd.ordinal - (pes1.ordinal + shb1)) / 7) + 1)
    prk = cshb % 6
    if prk == 0:
        prk = 6
    # If the second day of Shavuos was on Shabbos, we missed a week.
    # The second day of Pesach is always the same day as the first day of Shavuos.
    # So if Pesach was on Thursday, Shavuos will be on Friday and Shabbos in Chu"l.
    # Pesach can never come out on Friday, so in E. Yisroel Shavuos is never on Shabbos.
    if (not israel) and pes1.getdow() == 4 and (jmonth > 3 or
                                                (jmonth == 3 and jday > 6)):
        prk = 6 if prk == 1 else prk - 1
    # If Tisha B'Av was on Shabbos, we missed a week.
    # The first day of Pesach is always the same day of the week as Tisha b'av.
    if pes1.getdow() == 6 and (jmonth > 5 or (jmonth == 5 and jday > 9)):
        prk = 6 if prk == 1 else prk - 1
    return prk
def jdate_to_julian(jdate):
    year, month, day = jdate.year, jdate.month, jdate.day
    months = JDate.months_in_jyear(year)
    jd = EPOCH_JDATE + _jdate_delay_1(year) + _jdate_delay_2(year) + day + 1

    if month < 7:
        for mon in range(7, months + 1):
            jd += JDate.days_in_jmonth(year, mon)

        for mon in range(1, month):
            jd += JDate.days_in_jmonth(year, mon)
    else:
        for mon in range(7, month):
            jd += JDate.days_in_jmonth(year, mon)

    return int(jd) + 0.5
Exemple #3
0
def monthrange(year, mnth):
    """Return weekday (0-6 ~ Sun-Shabbos) and number of days (29-30) for
       year, mnth."""
    if not 1 <= mnth <= 13:
        raise IllegalMonthError(mnth)
    day1 = weekday(year, mnth, 1)
    ndays = JDate.days_in_jmonth(year, mnth)
    return day1, ndays
def main():
    parser = argparse.ArgumentParser(description='Outputs a formatted list of Zmanim for anywhere in the world '
                                                 'for any Jewish Date and for any number of days',
                                     epilog='''For example, to show all the Zmanim for all the days of Sukkos 5777
                                               for both Lakewood NJ and Brooklyn NY,
                                               use: luach.py "lakewood|brooklyn" -convertdate 15-7-5777 -d 9''')
    parser.add_argument('location',
                        help='''The city or location name. Doesn't need the full name,
                                the beginning of the name or a regular expression
                                search can be used. The search is not case sensitive.
                                For locations in Israel, the Hebrew name can be used as well as the English name.
                                If the supplied value matches more than one location,
                                the displayed Zmanim will be repeated for each match.
                                For example, if the supplied value is ".+wood", the
                                Zmanim of both Lakewood NJ and Hollywood California
                                will be displayed.''')
    parser.add_argument('-jd', '--jewishdate', default=JDate.today(), type=parse_jewish_date,
                        help='''The Jewish Date to display the Zmanim for.
                                If this argument is not supplied, the current system date is converted to a Jewish Date and used.
                                The Jewish Date should be formatted: DAY-MONTH-YEAR.
                                DAY is the day of the month.
                                MONTH is the Jewish month number, Nissan is month number 1 and Adar Sheini is 13.
                                YEAR is the full 4 digit Jewish year.
                                For example, "1-7-5778" will get the first day of Rosh Hashana 5778.
                                "13-4-5777" will get the 13th day of Tammuz 5777.
                                Alternatively, the date parts can be separated with a forward-slash (/), comma or period.''')
    parser.add_argument('-d', '--days', type=int, default=1,
                        help='''The number of days forward to display.
                                If this is not supplied, a single day will be displayed.''')
    parser.add_argument('-heb', '--hebrew', action="store_true", help='Display the Zmanim in Hebrew.')
    parser.add_argument('-a', '--army', action="store_true",
                        help='''Display the Zmanim time in army-time/24 hour format.
                                For example, for a Zman of 10:10 PM, 22:10 will be displayed.''')
    parser.add_argument('-l', '--locations', action="store_true",
                        help='''Instead of displaying the Zmanim, display the list of
                                locations returned from the "location" argument search.
                                Shows each locations name, latitude, longitude, elevation, utcoffset and hebrew name.
                                To show the ful list of all the locations, use: luach.py .+ -l''')
    args = parser.parse_args()

    if args.locations:
        locs = Location.get_location(args.location)
        if locs:
            locs.sort(key=lambda loc: loc.name)
            for i in locs:
                try:
                    print(i)
                except:
                    pass
        else:
            print('No locations were found that matched ', args.location)
    else:
        display_zmanim(location_search_pattern=args.location,
                       startjd=args.jewishdate,
                       number_of_days=args.days,
                       hebrew=args.hebrew,
                       army_time=args.army)
    def get_molad(month, year):
        month_adj = month - 7

        if month_adj < 0:
            month_adj += JDate.months_in_jyear(year)

        total_months = int(month_adj + 235 * int((year - 1) / 19) + 12 *
                           ((year - 1) % 19) +
                           ((((year - 1) % 19) * 7) + 1) / 19)
        parts_elapsed = 204 + (793 * (total_months % 1080))
        hours_elapsed = 5 + (12 * total_months) + 793 * int(
            total_months / 1080) + int(parts_elapsed / 1080) - 6
        parts = int((parts_elapsed % 1080) + 1080 * (hours_elapsed % 24))

        return dict(JDate=JDate.fromordinal((1 + (29 * int(total_months))) +
                                            int((hours_elapsed / 24))),
                    time=HourMinute(
                        int(hours_elapsed) % 24, int((parts % 1080) / 18)),
                    chalakim=parts % 18)
Exemple #6
0
 def itermonthdates(year, month):
     """
     Return an iterator for one month. The iterator will yield datetime.date
     values and will always iterate through complete weeks, so it will yield
     dates outside the specified month.
     """
     date = JDate(year, month, 1)
     # Go back to the beginning of the week
     days = date.getdow() % 7
     date -= days
     oneday = 1
     while True:
         yield date
         try:
             date += oneday
         except OverflowError:
             # Adding one day could fail after datetime.MAXYEAR
             break
         if date.month != month and date.getdow() == 0:
             break
def parse_jewish_date(string):
    match = re.match(pattern=r'^(?P<day>\d{1,2})[-\/,\.](?P<month>\d{1,2})[-\/,\.](?P<year>\d{4})$', string=string)
    if not match:
        raise argparse.ArgumentTypeError("%r is not a valid jewish date" % string)
    else:
        try:
            return JDate(year=int(match.group('year')),
                         month=int(match.group('month')),
                         day=int(match.group('day')))
        except ValueError as ve:
            msg = '"{}" is not a valid jewish date as {}'.format(string, ve)
            raise argparse.ArgumentTypeError(msg)
def greg_to_jdate(date_or_year, month=None, day=None):
    """
    date_or_year can be:
      - an instance of the built-in datetime.date/datetime.datetime class
      - a utils.GregorianDate namedtuple
      - an int representing the Gregorian year
    """

    if _is_legal_greg_date(date_or_year, month, day):
        if isinstance(date_or_year, datetime.date):
            return JDate.fromordinal(date_or_year.toordinal())

        if isinstance(date_or_year, int):
            y, m, d = date_or_year, month or 1, day or 1
        else:
            y, m, d = date_or_year  # unpack the utils.GregorianDate namedtuple

        if y > 0:
            return JDate.fromordinal(datetime.date(y, m, d).toordinal())
        else:
            return julian_to_jdate(greg_to_julian(d, m, y))
Exemple #9
0
 def yeardayscalendar(self, year, width=3):
     """
     Return the data for the specified year ready for formatting (similar to
     yeardatescalendar()). Entries in the week lists are day numbers.
     Day numbers outside this month are zero.
     """
     months = [
         self.monthdayscalendar(year, i)
         for i in range(7,
                        JDate.months_in_jyear(year) + 1)
     ]
     months += [self.monthdayscalendar(year, i) for i in range(1, 7)]
     return [months[i:i + width] for i in range(0, len(months), width)]
Exemple #10
0
 def yeardatescalendar(self, year, width=3):
     """
     Return the data for the specified year ready for formatting. The return
     value is a list of month rows. Each month row contains up to width months.
     Each month contains between 4 and 6 weeks and each week contains 1-7
     days. Days are JDate objects.
     """
     months = [
         self.monthdatescalendar(year, i)
         for i in range(7,
                        JDate.months_in_jyear(year) + 1)
     ]
     months += [self.monthdatescalendar(year, i) for i in range(1, 7)]
     return [months[i:i + width] for i in range(0, len(months), width)]
Exemple #11
0
def _fix_order(months, year):
    """
    Even though the month numbers for the Jewish year start from Nissan,
    the year starts from Tishrei.
    This function takes a list of month numbers used to display a yearly calendar,
    ordered as month 1 in year, 2 in year etc.
    and replaces the number with the correct real month number for that month.
    So for example, if the number is 1 , meaning the first month in the year,
    it is replaced with 7 which is the correct month number for Tishrei.
    """
    ly = JDate.months_in_jyear(year)
    # list of month numbers of this Jewish Year starting from Tishrei through Ellul.
    monthprog = [i for i in range(7, ly + 1)] + [i for i in range(1, 7)]
    return [monthprog[i - 1] for i in months]
def display_zmanim(location_search_pattern, startjd=JDate.today(), number_of_days=1, hebrew=False, army_time=False):
    if isinstance(location_search_pattern, Location):
        locations = (location_search_pattern,)
    else:
        locations = Location.get_location(location_search_pattern)
    if locations:
        for location in locations:
            if hebrew:
                print('זמני היום עבור {} {:*<45}\n'.format(location.hebrew.upper(), ''))
            else:
                print('\nZMANIM FOR {} {:*<45}'.format(location.name.upper(), ''))
            jd = startjd
            for i in range(number_of_days):
                gd = jd.todate()
                if isinstance(gd, datetime.date):
                    print('\n--{:-<50}'.format(jd.todate().strftime('%A, %B %d, %Y')))
                elif isinstance(gd, utils.GregorianDate):
                    if not hebrew:
                        print('\n--{}, {} {}, {}{:->40}'.format(utils.dow_eng[jd.getdow()],
                                                                utils.greg_months_eng[gd.month],
                                                                utils.to_suffixed(gd.day),
                                                                abs(gd.year),
                                                                ' BCE' if gd.year < 1 else ''))
                    else:
                        print('\n--{} {} {} {} {:-<28}'.format(utils.dow_heb[jd.getdow()],
                                                               gd.day,
                                                               'ל' + utils.greg_months_heb[gd.month],
                                                               abs(gd.year),
                                                               'לפה"ס' if gd.year < 1 else ''))

                # daily information is an OrderedDict of {title:value}
                for title, value in jcal.getdailyinfo(jd, location, hebrew).items():
                    display_info(title, value, hebrew, army_time)

                # daily zmanim is a list of namedtuple('OneZman', 'eng heb time')
                for one_zman in jcal.getdailyzmanim(jd, location):
                    display_zman(one_zman, hebrew, army_time)

                jd += 1
    else:
        print('No location found that matches with "%s"' % location_search_pattern)
Exemple #13
0
 def formatyear(self, theyear, width=3):
     """
     Return a formatted year as a table of tables.
     """
     v = []
     a = v.append
     width = max(width, 1)
     a('<table border="0" cellpadding="0" cellspacing="0" class="year">')
     a('\n')
     a('<tr><th colspan="%d" class="year">%s</th></tr>' % (width, theyear))
     for i in range(1, JDate.months_in_jyear(theyear) + 1, width):
         # months in this row
         months = range(i, min(i + width, 14))
         months = _fix_order(months, theyear)
         a('<tr>')
         for m in months:
             a('<td>')
             a(self.formatmonth(theyear, m, withyear=False))
             a('</td>')
         a('</tr>')
     a('</table>')
     return ''.join(v)
def julian_to_jdate(julian_date):
    julian_date = trunc(julian_date) + 0.5
    count = trunc(((julian_date - EPOCH_JDATE) * 98496.0) / 35975351.0)
    year = count - 1
    i = count
    while julian_date >= jdate_to_julian(JDate(i, 7, 1)):
        i += 1
        year += 1

    if julian_date < jdate_to_julian(JDate(year, 1, 1)):
        first = 7
    else:
        first = 1

    month = i = first
    while julian_date > jdate_to_julian(
            JDate(year, i, JDate.days_in_jmonth(year, i))):
        i += 1
        month += 1

    day = int(julian_date - jdate_to_julian(JDate(year, month, 1))) + 1
    return JDate(year, month, day)
Exemple #15
0
def weekday(year, mnth, day):
    """Return weekday (0-6 ~ Sun-Shabbos) for year (5776-...), month (1-12), day (1-30)."""
    return JDate(year, mnth, day).getdow()
Exemple #16
0
def isleap(year):
    """Return True for leap years, False for non-leap years."""
    return JDate.isleap_jyear(year)
Exemple #17
0
def main(args):
    import optparse
    parser = optparse.OptionParser(
        usage="usage: %prog [options] [year [month]]")
    parser.add_option("-w",
                      "--width",
                      dest="width",
                      type="int",
                      default=2,
                      help="width of date column (default 2, text only)")
    parser.add_option(
        "-l",
        "--lines",
        dest="lines",
        type="int",
        default=1,
        help="number of lines for each week (default 1, text only)")
    parser.add_option("-s",
                      "--spacing",
                      dest="spacing",
                      type="int",
                      default=6,
                      help="spacing between months (default 6, text only)")
    parser.add_option("-m",
                      "--months",
                      dest="months",
                      type="int",
                      default=3,
                      help="months per row (default 3, text only)")
    parser.add_option("-c",
                      "--css",
                      dest="css",
                      default="calendar.css",
                      help="CSS to use for page (html only)")
    parser.add_option("-e",
                      "--encoding",
                      dest="encoding",
                      default=None,
                      help="Encoding to use for output.")
    parser.add_option("-t",
                      "--type",
                      dest="type",
                      default="text",
                      choices=("text", "html"),
                      help="output type (text or html)")

    (options, args) = parser.parse_args(args)

    if options.type == "html":
        cal = HTMLCalendar()
        encoding = options.encoding
        if encoding is None:
            encoding = sys.getdefaultencoding()
        optdict = dict(encoding=encoding, css=options.css)
        write = sys.stdout.buffer.write
        if len(args) == 1:
            write(cal.formatyearpage(JDate.today().year, **optdict))
        elif len(args) == 2:
            write(cal.formatyearpage(int(args[1]), **optdict))
        else:
            parser.error("incorrect number of arguments")
            sys.exit(1)
    else:
        cal = TextCalendar()
        optdict = dict(w=options.width, l=options.lines)
        if len(args) != 3:
            optdict["cl"] = options.spacing
            optdict["m"] = options.months
        if len(args) == 1:
            result = cal.formatyear(JDate.today().year, **optdict)
        elif len(args) == 2:
            result = cal.formatyear(int(args[1]), **optdict)
        elif len(args) == 3:
            result = cal.formatmonth(int(args[1]), int(args[2]), **optdict)
        else:
            parser.error("incorrect number of arguments")
            sys.exit(1)
        write = sys.stdout.write
        if options.encoding:
            result = result.encode(options.encoding)
            write = sys.stdout.buffer.write
        write(result)
                    blatt += 24
                elif count == 38:
                    blatt += 33
                # Bailout
                j = 1 + dafcnt
            j += 1

        return cls._masechtaList[count], blatt

    # Returns the name of the Masechta and daf number in English, For example: Sukkah, Daf 3
    @classmethod
    def tostring(cls, jd):
        d = cls.getdaf(jd)
        if d:
            return d[0].eng + ", Daf " + str(d[1])

    # Returns the name of the Masechta and daf number in Hebrew. For example: 'סוכה דף כ.
    @classmethod
    def tostring_heb(cls, jd):
        d = cls.getdaf(jd)
        if d:
            return d[0].heb + " דף " + utils.to_jnum(d[1])


if __name__ == '__main__':
    jdat = JDate.today()
    dafEng = Dafyomi.tostring(jdat)
    dafHeb = Dafyomi.tostring_heb(jdat)
    print(dafEng)
    print(dafHeb)
            praklist = 4, 5, 6
    elif perek1 == 5:
        if cshb == 1:
            praklist = 5, 6
        elif cshb == 2:
            praklist = 1, 2
        elif cshb == 3:
            praklist = 3, 4
        elif cshb == 4:
            praklist = 5, 6
    elif perek1 == 6:
        if cshb == 1:
            praklist = 6,
        elif cshb == 2:
            praklist = 1, 2
        elif cshb == 3:
            praklist = 3, 4
        elif cshb == 4:
            praklist = 5, 6
    return praklist


if __name__ == '__main__':
    import jcal.utils as utils

    chukas5776 = JDate.create(5776, 4, 10)
    prakim = get_pirkeiavos(chukas5776, True)
    text = 'Pirkei Avos: ' + ' and '.join(
        [utils.to_suffixed(p) + ' Perek' for p in prakim])
    print(text)
Exemple #20
0
def proper_jmonth_name(jyear, jmonth, hebrew=False):
    from jcal.jdate import JDate
    if jmonth == 12 and JDate.isleap_jyear(jyear):
        return "Adar Rishon" if not hebrew else "אדר ראשון"
    else:
        return jmonths_eng[jmonth] if not hebrew else jmonths_heb[jmonth]
Exemple #21
0
    if month > 10 or month < 3:
        return False
    elif 3 < month < 10:
        return True
    # DST starts at 2 AM on the Friday before the last Sunday in March
    elif month == 3:  # March
        # Gets date of the Friday before the last Sunday
        last_friday = (31 - greg_dow(year, 3, 31)) - 2
        return day > last_friday or (day == last_friday and hour >= 2)
        # DST ends at 2 AM on the last Sunday in October
    else:  # dt.Month === 10 / October
        # Gets date of last Sunday in October
        last_sunday = 31 - greg_dow(year, 10, 31)
        return day < last_sunday or (day == last_sunday and hour < 2)


if __name__ == '__main__':
    from jcal.jdate import JDate

    # orig = GregorianDate(-2, 1, 1)
    # jd = JDate.fromdate(orig)
    # print('orig', orig)
    # print('orig - jdate', jd)
    # back = jd.todate()
    # print('back', back)
    td = JDate.today()
    from jcal.zmanim import Zmanim

    zm = Zmanim(dt=td)
    print(zm.get_sun_times())
def ellul(jd, israel):
    praklist = ()
    jyear = jd.year
    jday = jd.day
    # The first day of Ellul.
    # The year/month/day/ordinal constructor is used for efficiency.
    day1 = JDate(jyear, 6, 1, jd.ordinal - jd.day + 1)
    day1dow = day1.getdow()
    shabbos1day = 1 if day1dow == 6 else ((6 - (day1dow + 6) % 6) + 1)
    shabbos1date = JDate(jyear, 6, shabbos1day, day1.ordinal + shabbos1day - 1)
    # Which shabbos in Ellul are we working out now?
    cshb = 1 if jday == shabbos1day else int((jday - shabbos1day) / 7) + 1

    perek1 = get_first_perek(shabbos1date, israel)
    if perek1 == 1:
        if cshb == 1:
            praklist = 1,
        elif cshb == 2:
            praklist = 2,
        elif cshb == 3:
            praklist = 3, 4
        elif cshb == 4:
            praklist = 5, 6
    elif perek1 == 2:
        if cshb == 1:
            praklist = 2,
        elif cshb == 2:
            praklist = 3,
        elif cshb == 3:
            praklist = 4,
        elif cshb == 4:
            praklist = 5, 6
    elif perek1 == 3:
        if cshb == 1:
            praklist = 3,
        elif cshb == 2:
            praklist = 4,
        elif cshb == 3:
            praklist = 5,
        elif cshb == 4:
            praklist = 6,
    elif perek1 == 4:
        # This can only happen in Chutz La'aretz
        if cshb == 1:
            praklist = 4, 5
        elif cshb == 2:
            praklist = 6, 1
        elif cshb == 3:
            praklist = 2, 3
        elif cshb == 4:
            praklist = 4, 5, 6
    elif perek1 == 5:
        if cshb == 1:
            praklist = 5, 6
        elif cshb == 2:
            praklist = 1, 2
        elif cshb == 3:
            praklist = 3, 4
        elif cshb == 4:
            praklist = 5, 6
    elif perek1 == 6:
        if cshb == 1:
            praklist = 6,
        elif cshb == 2:
            praklist = 1, 2
        elif cshb == 3:
            praklist = 3, 4
        elif cshb == 4:
            praklist = 5, 6
    return praklist
    def get_sedra_order(cls, year, israel):
        # If the last call is within the same year as this one, we reuse the data.
        # If memory is an issue, remove these next few lines
        if cls._lastcalculatedyear is not None and cls._lastcalculatedyear['year'] == year and \
                        cls._lastcalculatedyear['israel'] == israel:
            return cls._lastcalculatedyear

        long_cheshvon = JDate.has_long_cheshvan(year)
        short_kislev = JDate.has_short_kislev(year)
        rosh_hashana = JDate.toordinal(year, 7, 1)
        rosh_hashana_dow = abs(rosh_hashana % 7)
        first_sat_in_year = cls.get_day_on_or_before(6, rosh_hashana + 6)
        year_type = 'regular'
        s_array = None

        if long_cheshvon and not short_kislev:
            year_type = 'complete'
        elif not long_cheshvon and short_kislev:
            year_type = 'incomplete'

        if not JDate.isleap_jyear(year):
            if rosh_hashana_dow == 6:
                if year_type == "incomplete":
                    s_array = cls._shabbos_short
                elif year_type == 'complete':
                    s_array = cls._shabbos_long
            elif rosh_hashana_dow == 1:
                if year_type == 'incomplete':
                    s_array = cls._mon_short
                elif year_type == 'complete':
                    s_array = cls._mon_short if israel else cls._mon_long
            elif rosh_hashana_dow == 2:
                if year_type == 'regular':
                    s_array = cls._mon_short if israel else cls._mon_long
            elif rosh_hashana_dow == 4:
                if year_type == 'regular':
                    s_array = cls._thu_normal_Israel if israel else cls._thu_normal
                elif year_type == 'complete':
                    s_array = cls._thu_long
            else:
                raise ValueError("improper sedra year type calculated.")
        # leap year
        else:
            if rosh_hashana_dow == 6:
                if year_type == 'incomplete':
                    s_array = cls._shabbos_short_leap
                elif year_type == 'complete':
                    s_array = cls._shabbos_short_leap if israel else cls._shabbos_long_leap
            elif rosh_hashana_dow == 1:
                if year_type == 'incomplete':
                    s_array = cls._mon_short_leap_Israel if israel else cls._mon_short_leap
                elif year_type == 'complete':
                    s_array = cls._mon_long_leap_Israel if israel else cls._mon_long_leap
            elif rosh_hashana_dow == 2:
                if year_type == 'regular':
                    s_array = cls._mon_long_leap_Israel if israel else cls._mon_long_leap
            elif rosh_hashana_dow == 4:
                if year_type == 'incomplete':
                    s_array = cls._thu_short_leap
                elif year_type == 'complete':
                    s_array = cls._thu_long_leap
            else:
                raise ValueError("improper sedra year type calculated.")

        retobj = dict(first_sat_in_year=first_sat_in_year, sedra_array=s_array, year=year, israel=israel)

        # Save the data in case the next call is for the same year
        cls._lastcalculatedyear = retobj

        return retobj
Exemple #24
0
def getdailyinfo(jd, location, hebrew):
    from jcal.jdate import JDate
    import jcal.utils
    from jcal.molad import Molad
    from jcal.hourminute import HourMinute
    from jcal.sedra import Sedra
    from jcal.dafyomi import Dafyomi
    from jcal.pirkeiavos import get_pirkeiavos

    infos = OrderedDict()
    sedras = Sedra.get_sedra(jd, location.israel)
    holidays = jd.get_holidays(location.israel)

    if hebrew:
        infos['תאריך'] = jd.tostring_heb()
        for h in holidays:
            htext = h.heb
            if 'מברכים' in htext:
                next_month = jd.add_days(12)
                htext += '- חודש ' + utils.proper_jmonth_name(next_month.year, next_month.month, hebrew=True)
                htext += '\nהמולד: ' + Molad.molad_string_heb(next_month.month, next_month.year)
                dim = JDate.days_in_jmonth(jd.year, jd.month)
                dow = dim - jd.day - (1 if dim == 30 else 0)
                htext += '\nראש חודש: ' + utils.dow_heb[dow]
                if dim == 30:
                    htext += ", " + utils.dow_heb[(dow + 1) % 7]
            infos[htext] = ''
        if jd.has_eiruv_tavshilin(location.israel):
            infos['עירוב תבשילין'] = ''
        if jd.has_candle_lighting():
            infos['הדלקת נרות'] = jd.get_candle_lighting(location)
        infos['פרשת השבוע'] = ' - '.join([s[1] for s in sedras])
        dy = Dafyomi.tostring_heb(jd)
        if dy:
            infos['דף יומי'] = Dafyomi.tostring_heb(jd)
        if jd.getdow() == 6:
            prakim = get_pirkeiavos(jd, location.israel)
            if prakim:
                infos['פרקי אבות'] = ' פרק' + ' ופרק '.join([utils.jsd[p - 1] for p in prakim])
    else:
        infos["Date"] = jd.tostring()
        infos['Parshas Hashavua'] = ' - '.join([s[0] for s in sedras])
        for h in holidays:
            htext = h.eng
            if 'Mevarchim' in htext:
                next_month = jd.add_days(12)
                htext += '- Chodesh ' + utils.proper_jmonth_name(next_month.year, next_month.month)
                htext += '\nThe Molad: ' + Molad.molad_string_heb(next_month.month, next_month.year)
                dim = JDate.days_in_jmonth(jd.year, jd.month)
                dow = dim - jd.getdow() - (1 if dim == 30 else 0)
                htext += '\nRosh Chodesh: ' + utils.dow_heb[dow]
                if dim == 30:
                    htext += ", " + utils.dow_eng[(dow + 1) % 7]
            infos[htext] = ''
        if jd.has_eiruv_tavshilin(location.israel):
            infos['Eruv Tavshilin'] = ''
        if jd.has_candle_lighting():
            infos['Candle Lighting'] = jd.get_candle_lighting(location)
        infos['Daf Yomi'] = Dafyomi.tostring(jd)
        if jd.getdow() == 6:
            prakim = get_pirkeiavos(jd, location.israel)
            if prakim:
                infos['Pirkei Avos'] = ' and '.join([utils.to_suffixed(p) + ' Perek' for p in prakim])
    return infos
                elif year_type == 'complete':
                    s_array = cls._shabbos_short_leap if israel else cls._shabbos_long_leap
            elif rosh_hashana_dow == 1:
                if year_type == 'incomplete':
                    s_array = cls._mon_short_leap_Israel if israel else cls._mon_short_leap
                elif year_type == 'complete':
                    s_array = cls._mon_long_leap_Israel if israel else cls._mon_long_leap
            elif rosh_hashana_dow == 2:
                if year_type == 'regular':
                    s_array = cls._mon_long_leap_Israel if israel else cls._mon_long_leap
            elif rosh_hashana_dow == 4:
                if year_type == 'incomplete':
                    s_array = cls._thu_short_leap
                elif year_type == 'complete':
                    s_array = cls._thu_long_leap
            else:
                raise ValueError("improper sedra year type calculated.")

        retobj = dict(first_sat_in_year=first_sat_in_year, sedra_array=s_array, year=year, israel=israel)

        # Save the data in case the next call is for the same year
        cls._lastcalculatedyear = retobj

        return retobj


if __name__ == '__main__':
    sedras = Sedra.get_sedra(JDate.today(), True)
    text = ' - '.join([s[0] for s in sedras])
    print(text)