Giter Club home page Giter Club logo

pyluach's Introduction

pyluach

Documentation Status https://github.com/simlist/pyluach/actions/workflows/testing-and-coverage.yml/badge.svg?branch=master https://coveralls.io/repos/github/simlist/pyluach/badge.svg?branch=master

Pyluach is a Python package for dealing with Hebrew (Jewish) calendar dates.

Features

  • Conversion between Hebrew and Gregorian dates
  • Finding the difference between two dates
  • Finding a date at a given duration from the given date
  • Rich comparisons between dates
  • Finding the weekday of a given date
  • Finding the weekly Parsha reading of a given date
  • Getting the holiday occuring on a given date
  • Generating html and text Hebrew calendars

Installation

Use pip install pyluach.

Documentation

Documentation for pyluach can be found at https://readthedocs.org/projects/pyluach/.

Examples

>>> from pyluach import dates, hebrewcal, parshios

>>> today = dates.HebrewDate.today()
>>> lastweek_gregorian = (today - 7).to_greg()
>>> lastweek_gregorian < today
    True
>>> today - lastweek_gregorian
7
>>> greg = dates.GregorianDate(1986, 3, 21)
>>> heb = dates.HebrewDate(5746, 13, 10)
>>> greg == heb
True

>>> purim = dates.HebrewDate(5781, 12, 14)
>>> purim.hebrew_day()
'י״ד'
>>> purim.hebrew_date_string()
'י״ד אדר תשפ״א'
>>> purim.hebrew_date_string(True)
'י״ד אדר ה׳תשפ״א'

>>> rosh_hashana = dates.HebrewDate(5782, 7, 1)
>>> rosh_hashana.holiday()
'Rosh Hashana'
>>> rosh_hashana.holiday(hebrew=True)
'ראש השנה'
>>> (rosh_hashana + 3).holiday()
None

>>> month = hebrewcal.Month(5781, 10)
>>> month.month_name()
'Teves'
>>> month.month_name(True)
'טבת'
>>> month + 3
Month(5781, 1)
>>> for month in hebrewcal.Year(5774).itermonths():
...     print(month.month_name())
Tishrei Cheshvan ...

>>> date = dates.GregorianDate(2010, 10, 6)
>>> parshios.getparsha(date)
[0]
>>> parshios.getparsha_string(date, israel=True)
'Beraishis'
>>> parshios.getparsha_string(date, hebrew=True)
'בראשית'
>>> new_date = dates.GregorianDate(2021, 3, 10)
>>> parshios.getparsha_string(new_date)
'Vayakhel, Pekudei'
>>> parshios.getparsha_string(new_date, hebrew=True)
'ויקהל, פקודי'

Contact

For questions and comments please raise an issue in github or contact me at [email protected].

License

Pyluach is licensed under the MIT license.

pyluach's People

Contributors

mhornbacher avatar simlist avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pyluach's Issues

Shavuos in Elul?

today

HebrewDate(5782, 5, 27)

(today+10)

HebrewDate(5782, 6, 7)

(today+10).month_name()

'Elul'

(today+10).holiday()

'Shavuos'

feature request: Getting specific day of holiday

Hi.
First, I'd like to say thanks for this great package.

It'd be nice to be able to get the specific day of the holiday. For example "ב סוכות" instead of "סוכות" for all Sukkot days.

parshios.getparsha_string(): Parsha variable is referenced before assignment.

Good morning,

I noticed an issue with the new update:

Steps to Reproduce:

  1. Install the latest version of the package.
  2. Load up a python console
    2.5. Import the library (from pyluach import dates, parshios, hebrewcal)
  3. Create a today variable (e.g. today = dates.HebrewDate.today() )
  4. Call the function e.g. parshios.getparsha_string(today)

Expected Behavior:

Returns a string of the parsha

Actual Behavior:

Throws the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/menachem/.local/lib/python3.5/site-packages/pyluach/parshios.py", line 137, in getparsha_string
    if parsha is None:
UnboundLocalError: local variable 'parsha' referenced before assignment

Proposed Solution:

Move line 139 above line 137 so that parsha is assigned before the check.

Notes

Already fixed in dev branch

Line location:

if parsha is None:

Official release?

Hello,

I was just wondering if there are any plans to publish an "official" (non-dev) release of this package? One of our dependencies started pulling in pyluach as a sub-dependency in a new release, and with our package management tool (pipenv) we either need to specify --pre to get it to work (which can then pull in other pre-release packages which we don't want, or pin our dependency to an older version.

Thanks!

Hebrew date start with Tishery as the first month

When requested (with a flag or by another class), we set the Hebrew date to set Tishrey as the 1st month, and Elul as the last one.
I'm willing to start working on this feature, but first I wanted to check if it's something that you also think is useful and worth working on. I also wanted to consult with you what you think is the best approach for this feature (flag or another class).
Let me know what you think ☺️

New API - `fast`

I want to automatically congrats on holiday, but the blessing is different between fast and actual holiday.

We can do it without inflecting the current holiday API that still will return fast alongside holiday.

Not having the year,

Thank you so much for such a wonderful package.

if I only have the month and day (Yahrzeit of Yusef Hasadik, which is today :) ), how would I calculate when it will be next year ?
I was thinking to

1: Assume it was this year,
Loop
2: if the date does not work try a year before
end of loop

so the birthdays will be correct, but yr is off.

Four Parshios in pyluach

It seems there is no support for Four Parshiot (Shekalim, Zachor, Para, Hodesh) in pyluach. Is that correct?

pip install pylauch broken

Following the instructions on https://pypi.org/project/pyluach/, but am unable to install the library using pip or pip3. Was it delisted from pypi?

pip3 install pylauch
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement pylauch (from versions: none)
ERROR: No matching distribution found for pylauch

pip install pylauch
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement pylauch (from versions: none)
ERROR: No matching distribution found for pylauch

pip --version
pip 23.2.1 from /usr/local/lib/python3.10/dist-packages/pip (python 3.10)

pip3 --version
pip 23.2.1 from /usr/local/lib/python3.10/dist-packages/pip (python 3.10)

holiday support

I would like to have holiday support in this project.
The basic support is that if holiday=True, getparash will return the closest parasha or holiday, plus to add the hol-hamo'ed parashos to all parashos.
I don't mind contribute it myself, but first I would like to discuss the design with you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.