Package: sefirat-haomer
sefirat-haomerA library for calculating the days of Sefirat HaOmer.InstallationYou can install this package with pip or conda.$pipinstallsefirat-haomer$condainstall-cabrahammurcianosefirat-haomerLinksUsageThis library provides three main classes.OmerDaywhich represents a single day (1 to 49) of Sefirat HaOmer (not bound to any particular year),OmerDatewhich represents a day of Sefirat HaOmer in a particular year, andOmerCalendarwhich is a collection ofOmerDateobjects for a particular year.For an actual example of how this library was used to generate Google Calendar events for the next 100 years, seethis example. (Interestingly, this is why I wrote this library in the first place, and you can import the resulting calendarby clicking this link).OmerDayHere are some examples of how to use theOmerDayclass.>>>fromsefirat_haomerimportOmerDay>>>day=OmerDay(33)OmerDayobjects have the following attributes:>>>day.day33>>>day.weeks4>>>day.days5You can also get the day of the week for a givenOmerDayby unpacking it:>>>weeks,days=day>>>weeks4>>>days5OmerDayobjects can be converted to integers:>>>int(day)33OmerDayobjects can also be compared to otherOmerDayobjects:>>>day==OmerDay(33)True>>>day!=OmerDay(33)False>>>day<OmerDay(45)True>>>day>OmerDay(45)False>>>day<=OmerDay(20)False>>>day>=OmerDay(20)TrueOmerDateHere are some examples of how to use theOmerDateclass.OmerDateobjects can be created in any of the following ways. (All the following examples are equivalent.)>>>fromsefirat_haomerimportOmerDate>>>frompyluach.datesimportHebrewDate>>>fromdatetimeimportdate>>>date=OmerDate(8,hebrew_year=5783)>>>date=OmerDate(8,gregorian_year=2023)>>>date=OmerDate.from_hebrew(HebrewDate(5783,1,23))>>>date=OmerDate.from_gregorian(date(2023,4,14))OmerDateobjects have the following attributes (in addition to those inherited fromOmerDay):>>>date.hebrewHebrewDate(5783,1,23)>>>date.gregoriandatetime.date(2023,4,14)OmerDateobjects can be compared to otherOmerDateobjects:>>>date==OmerDate(8,hebrew_year=5783)True>>>date!=OmerDate(8,hebrew_year=5784)True>>>date!=OmerDate(33,gregorian_year=5783)True>>>date<OmerDate(33,gregorian_year=5782)True>>>date>OmerDate(33,gregorian_year=5784)True>>>date<=OmerDate(33,gregorian_year=5782)False>>>date>=OmerDate(33,gregorian_year=5784)FalseOmerCalendarHere are some examples of how to use theOmerCalendarclass.OmerCalendarobjects can be created in any of the following ways. (All the following examples are equivalent.)>>>fromsefirat_haomerimportOmerCalendar>>>calendar=OmerCalendar(hebrew_year=5783)>>>calendar=OmerCalendar(gregorian_year=2023)OmerCalendarobjects have the following attributes:>>>calendar.hebrew_year5783>>>calendar.gregorian_year2023OmerCalendarobjects can be indexed just like a list:>>>calendar[0]OmerDate(1,hebrew_year=5783)>>>calendar[48]OmerDate(49,hebrew_year=5783)>>>calendar[-1]OmerDate(49,hebrew_year=5783)>>>calendar[:2][OmerDate(1,hebrew_year=5783),OmerDate(2,hebrew_year=5783)]>>>calendar[2:5][OmerDate(3,hebrew_year=5783),OmerDate(4,hebrew_year=5783),OmerDate(5,hebrew_year=5783)]>>>calendar[46:][OmerDate(47,hebrew_year=5783),OmerDate(48,hebrew_year=5783),OmerDate(49,hebrew_year=5783)]>>>calendar[5:10:2][OmerDate(6,hebrew_year=5783),OmerDate(8,hebrew_year=5783),OmerDate(10,hebrew_year=5783)]OmerCalendarobjects can be iterated over:>>>fordayincalendar:...print(day)OmerCalendarobjects can also tell you if a givenOmerDateis in the calendar:>>>OmerDate(1,hebrew_year=5783)incalendarTrue>>>OmerDate(1,hebrew_year=5784)incalendarFalse