Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Hebcal

A python package for working with Hebrew dates, times, and holidays

Note: This is still in development and not ready for production. There will still be lots of breaking changes.

There are several python packages that deal with Hebrew dates, Z'manim and Jewish holidays. However, since the Hebrew calendar considers nightfall the beginning of the new day, I've found it very inconvenient to work with other packages. Just converting a Gregorian date to a Hebrew date doesn't give you the proper conversion, as it could be past nightfall, which needs to manually accommodated.

The same goes for any Jewish holiday package. You first need to figure out what the real Hebrew date is before you can determine if it's currently a holiday.

I wanted something that I can just ask "is today a rest holiday?" and I should get a True or False.

I wrote Hebcal to solve these problems. It takes in a latitude and longitude to calculate the location. It can be installed through pip: pip install hebcal.

Here's a quick example:

import hebcal

time_info = hebcal.TimeInfo.now(latitude=40.089909, longitude=-74.216270)
print(time_info.today_sunrise().strftime('%-I:%M:%S %p'))
###6:48:58 AM
print(time_info.hebrew_date())
###(5779, 7, 19)

You can input a specific date and time with a string:

time_info = hebcal.TimeInfo('2018, 9, 27 10:07 pm', latitude=40.089909, longitude=-74.216270)
print(time_info.today_sunrise().strftime('%-I:%M:%S %p'))
###6:48:58 AM
print(time_info.hebrew_date())
###(5779, 7, 19)

The Hebrew date that is returned takes into account sunrise/sunset. If it's after sunset it will automatically return the correct Hebrew date.

You can also query directly if its night, or day

print(time_info.is_night())
###True
print(time_info.is_day())
###False
Note: Calculating the timezone from the lat/lon slows down the calculations. It is best to pass the timezone as an argument:
time_info = hebcal.TimeInfo.now(timezone='America/New_York', latitude=40.089909, longitude=-74.216270)

You can manually get the timezone using Hebcal:

from hebcal.util.location import get_location
timezone = get_location(latitude==40.089909, longitude=-74.216270)
print(timezone)
###America/New_York

Hebcal zmanim.Zmanim

note: All times are datetime.datetime objects. They can be formated using .strftime().

Here's an example of the hebcal.zmanim

time_info = hebcal.TimeInfo.now(latitude=40.089909, longitude=-74.216270)

# pass a hbcal.TimeInfo object into Zmanim
zmanim = hebcal.Zmanim(time_info)
print(zmanim.last_shema_ma)
###2018-09-27 09:12:12.895624-04:00
print(zmanim.last_shema_ma.strftime("%-I:%M:%S %p"))
###9:12:12 AM

Other than accessing individual zmanim, You can just print the Zmanim object, which returns formated times (i.e. 9:12:12 AM).

Another option is to get all the zmanim configures as json:

zmanim_json = hebcal.Zmanim.json(time_info)
print(zmanim_json['earliest mincha'])
###2018-09-27 13:17:19.756457-04:00

Add calandar README here.

Metadata

Release files for hebcal 0.0.1a0.dev4

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

Source distribution (sdist)

Source distribution for hebcal 0.0.1a0.dev4
File Size Uploaded Provenance Actions
hebcal-0.0.1a0.dev4.tar.gz 14.3 kB Without provenance Details for hebcal-0.0.1a0.dev4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hebcal 0.0.1a0.dev4
File Interpreter ABI Platform Actions
hebcal-0.0.1a0.dev4-py3-none-any.whl Python 3 none any Details for hebcal-0.0.1a0.dev4-py3-none-any.whl

Total release size: 35.1 kB

Release files / hebcal-0.0.1a0.dev4.tar.gz

Download URL hebcal-0.0.1a0.dev4.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
28755c3d38bb9d595ca6220b60afeedc2256b53c9d16a970afcc1d63b138b86f
BLAKE2b-256 checksum
How to use checksums
6c1788a77d5867cc6fdf14d6800d408a898c3e6573dba4cd6597d92da6c317e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.4

Release files / hebcal-0.0.1a0.dev4-py3-none-any.whl

Download URL hebcal-0.0.1a0.dev4-py3-none-any.whl
Size 20.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c5e74d5305428a607ef3844c0008dd6b0872deab7a87f736953e7de61cbc9ca
BLAKE2b-256 checksum
How to use checksums
361fb9d2946084c11ee85c79e1a138281470853fc52b6d935e4364ee91b2b0ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.4

Security for hebcal 0.0.1a0.dev4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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