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 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)
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)
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())
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)
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)