Skip to main content

A library for calculating the days of Sefirat HaOmer.

Project description

sefirat-haomer

A library for calculating the days of Sefirat HaOmer.

Installation

You can install this package with pip or conda.

$ pip install sefirat-haomer
$ conda install -c abrahammurciano sefirat-haomer

Links

Documentation

Source Code - GitHub

PyPI - sefirat-haomer

Anaconda - sefirat-haomer

Usage

This library provides three main classes. OmerDay which represents a single day (1 to 49) of Sefirat HaOmer (not bound to any particular year), OmerDate which represents a day of Sefirat HaOmer in a particular year, and OmerCalendar which is a collection of OmerDate objects for a particular year.

For an actual example of how this library was used to generate Google Calendar events for the next 100 years, see this example. (Interestingly, this is why I wrote this library in the first place, and you can import the resulting calendar by clicking this link).

OmerDay

Here are some examples of how to use the OmerDay class.

>>> from sefirat_haomer import OmerDay
>>> day = OmerDay(33)

OmerDay objects have the following attributes:

>>> day.day
33
>>> day.weeks
4
>>> day.days
5

You can also get the day of the week for a given OmerDay by unpacking it:

>>> weeks, days = day
>>> weeks
4
>>> days
5

OmerDay objects can be converted to integers:

>>> int(day)
33

OmerDay objects can also be compared to other OmerDay objects:

>>> day == OmerDay(33)
True
>>> day != OmerDay(33)
False
>>> day < OmerDay(45)
True
>>> day > OmerDay(45)
False
>>> day <= OmerDay(20)
False
>>> day >= OmerDay(20)
True

OmerDate

Here are some examples of how to use the OmerDate class.

OmerDate objects can be created in any of the following ways. (All the following examples are equivalent.)

>>> from sefirat_haomer import OmerDate
>>> from pyluach.dates import HebrewDate
>>> from datetime import date
>>> 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))

OmerDate objects have the following attributes (in addition to those inherited from OmerDay):

>>> date.hebrew
HebrewDate(5783, 1, 23)
>>> date.gregorian
datetime.date(2023, 4, 14)

OmerDate objects can be compared to other OmerDate objects:

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

OmerCalendar

Here are some examples of how to use the OmerCalendar class.

OmerCalendar objects can be created in any of the following ways. (All the following examples are equivalent.)

>>> from sefirat_haomer import OmerCalendar
>>> calendar = OmerCalendar(hebrew_year=5783)
>>> calendar = OmerCalendar(gregorian_year=2023)

OmerCalendar objects have the following attributes:

>>> calendar.hebrew_year
5783
>>> calendar.gregorian_year
2023

OmerCalendar objects 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)]

OmerCalendar objects can be iterated over:

>>> for day in calendar:
...     print(day)

OmerCalendar objects can also tell you if a given OmerDate is in the calendar:

>>> OmerDate(1, hebrew_year=5783) in calendar
True
>>> OmerDate(1, hebrew_year=5784) in calendar
False

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sefirat_haomer-1.0.0.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

sefirat_haomer-1.0.0-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file sefirat_haomer-1.0.0.tar.gz.

File metadata

  • Download URL: sefirat_haomer-1.0.0.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.11 Linux/5.15.0-1035-azure

File hashes

Hashes for sefirat_haomer-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8cbced3afaed248f39c816a2da0d9f12ab7f39f2e9b94372768a3438bab06001
MD5 040e2aa418a04f5e289ca755562292ff
BLAKE2b-256 224960b7c1b3a8c9f63354f490ce6b79739b13051c757b4936ac582475802fbf

See more details on using hashes here.

File details

Details for the file sefirat_haomer-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: sefirat_haomer-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.11 Linux/5.15.0-1035-azure

File hashes

Hashes for sefirat_haomer-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 15a218caeb7e81fc1adcc64bdec30832a4ab7fef126d971621d2dec7f531d794
MD5 7967fcb06ad9c6ef39a6922eb52ff85e
BLAKE2b-256 81dcee88036291adcacfdec9a36bb3879c12aa16953766f0bc494169915135f4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page