Skip to main content

typed-zmanim

Python Typed Zmanim library

This project is a port from Pinny Markowitz's python-zmanim port of Eliyahu Hershfeld's KosherJava project, with added typing.

The main difference between this project and python-zmanim is that instead of handling edge cases (literally, near the artic circle) by returning None, we raise an ArticCircleException. This prevents you from having to check every returned datetime for None.

Usage

Some common examples include...

Zmanim calculations

# Initialize a new ZmanimCalendar object, defaults to using today's date in GMT, located at Greenwich, England
from zmanim.zmanim_calendar import ZmanimCalendar
calendar = ZmanimCalendar()
calendar
#=> zmanim.zmanim_calendar.ZmanimCalendar(candle_lighting_offset=18, geo_location=zmanim.util.geo_location.GeoLocation(name='Greenwich, England', latitude=51.4772, longitude=0.0, time_zone=tzfile('/usr/share/zoneinfo/GMT'), elevation=0.0), date=datetime.datetime(2018, 8, 26, 11, 40, 29, 334774), calculator=<zmanim.util.noaa_calculator.NOAACalculator object at 0x10bbf7710>)

# Calculate the sunset for today at that location
calendar.sunset()
#=> datetime.datetime(2018, 8, 26, 18, 58, 40, 796469, tzinfo=tzfile('/usr/share/zoneinfo/GMT'))        

# Prepare a new location
from zmanim.util.geo_location import GeoLocation
location = GeoLocation('Lakewood, NJ', 40.0721087, -74.2400243, 'America/New_York', elevation=15)
location
#=> zmanim.util.geo_location.GeoLocation(name='Lakewood, NJ', latitude=40.0721087, longitude=-74.2400243, time_zone=tzfile('/usr/share/zoneinfo/America/New_York'), elevation=15.0) 

# Initialize a new ZmanimCalendar object, passing a specific location and date
from datetime import date
calendar = ZmanimCalendar(geo_location=location, date=date(2017, 12, 15))
calendar
#=> zmanim.zmanim_calendar.ZmanimCalendar(candle_lighting_offset=18, geo_location=zmanim.util.geo_location.GeoLocation(name='Lakewood, NJ', latitude=40.0721087, longitude=-74.2400243, time_zone=tzfile('/usr/share/zoneinfo/America/New_York'), elevation=15.0), date=datetime.date(2017, 12, 15), calculator=<zmanim.util.noaa_calculator.NOAACalculator object at 0x10bbf7828>)

# Calculate Sof Zman Krias Shma for that location/date per the opinion of GR"A
calendar.sof_zman_shma_gra()
#=> datetime.datetime(2017, 12, 15, 9, 32, 9, 383390, tzinfo=tzfile('/usr/share/zoneinfo/America/New_York'))

Date Calculations

# Initialize a new JewishDate object with today's date
from zmanim.hebrew_calendar.jewish_date import JewishDate 
date = JewishDate()
date
#=> <zmanim.hebrew_calendar.jewish_date.JewishDate gregorian_date=datetime.date(2018, 8, 26), jewish_date=(5778, 6, 15), day_of_week=1, molad_hours=0, molad_minutes=0, molad_chalakim=0>

# Calculate the JewishDate from 25 days ago
date - 25
#=> <zmanim.hebrew_calendar.jewish_date.JewishDate gregorian_date=datetime.date(2018, 8, 1), jewish_date=(5778, 5, 20), day_of_week=4, molad_hours=0, molad_minutes=0, molad_chalakim=0>

# Initialize a new JewishCalendar object for Pesach of this Jewish calendar year
from zmanim.hebrew_calendar.jewish_calendar import JewishCalendar
pesach = JewishCalendar(date.jewish_year, 1, 15)
pesach
#=> <zmanim.hebrew_calendar.jewish_calendar.JewishCalendar in_israel=False, gregorian_date=datetime.date(2018, 3, 31), jewish_date=(5778, 1, 15), day_of_week=7, molad_hours=0, molad_minutes=0, molad_chalakim=0>
pesach.significant_day()
#=> 'pesach'
pesach.is_yom_tov_assur_bemelacha()
#=> True

There is much more functionality included than demonstrated here. Feel free to experiment or read the source code to learn more!


Test

To run test

python -m unittest

To run type checking

mypy .

Contributing

Bug reports and pull requests are welcome on Github. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Release files for typed-zmanim 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for typed-zmanim 0.1.0
File Size Uploaded
typed_zmanim-0.1.0.tar.gz 34.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for typed-zmanim 0.1.0
File Interpreter ABI Platform
typed_zmanim-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 79.1 kB

Release files / typed_zmanim-0.1.0.tar.gz

Download URL typed_zmanim-0.1.0.tar.gz
Size 34.7 kB
Tags Source
SHA-256 checksum
How to use checksums
65dcf2cdf23f4708b38ba46dcc48f4e926ab3aea6152ad8c836a12835824092e
BLAKE2b-256 checksum
How to use checksums
e119a6d4dce639518919c48c20d28fdb2e9a02de3d247d9ee2aa1be0028b88e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.0 Linux/5.15.0-1041-azure

Release files / typed_zmanim-0.1.0-py3-none-any.whl

Download URL typed_zmanim-0.1.0-py3-none-any.whl
Size 44.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c183c6432999b7c067c748329e0603bc56ecc27103d368679b4b1e42e77ed2c5
BLAKE2b-256 checksum
How to use checksums
0e16003044727e6da7e204e29bd92a9bab11bc003d93bf5ef9cca6627ba20d12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.0 Linux/5.15.0-1041-azure

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page