├── test ├── __init__.py ├── test_engine │ ├── __init__.py │ ├── test_rosh_chodesh.py │ ├── test_holiday.py │ ├── test_fasts.py │ ├── test_shabbat.py │ └── test_yomtov.py ├── test_routers │ ├── __init__.py │ ├── test_errors.py │ └── test_main_router.py ├── pesach.http ├── test_main.py ├── consts.py ├── test_utils.py └── test_api_helpers.py ├── zmanim_api ├── __init__.py ├── engine │ ├── __init__.py │ ├── daf_yomi.py │ ├── rosh_chodesh.py │ ├── shabbat.py │ ├── zmanim_module.py │ └── holidays.py ├── routers │ ├── __init__.py │ ├── openapi_desctiptions.py │ └── main_router.py ├── settings.py ├── utils.py ├── main.py ├── api_helpers.py └── models.py ├── .codecov.yaml ├── Dockerfile ├── .github └── workflows │ ├── tests.yaml │ └── ci.yaml ├── pyproject.toml ├── uvicorn_logger.json ├── .gitignore ├── README.md ├── pdm.lock └── LICENSE /test/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /zmanim_api/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.codecov.yaml: -------------------------------------------------------------------------------- 1 | codecov: 2 | -------------------------------------------------------------------------------- /test/test_engine/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/test_routers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /zmanim_api/engine/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /zmanim_api/routers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/pesach.http: -------------------------------------------------------------------------------- 1 | GET http://localhost:8000/yom_tov? 2 | lat=32.08335 & 3 | lng=34.883325 & 4 | yomtov_name=pesach & 5 | cl=18 & 6 | havdala=tzeis_8_5_degrees 7 | 8 | ### 9 | -------------------------------------------------------------------------------- /test/test_main.py: -------------------------------------------------------------------------------- 1 | from fastapi.testclient import TestClient 2 | 3 | from zmanim_api.main import app 4 | 5 | client = TestClient(app) 6 | 7 | 8 | def test_swagger(): 9 | resp = client.get('/') 10 | assert resp.status_code == 200 11 | 12 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.11-slim 2 | 3 | RUN pip install pdm 4 | WORKDIR /home/app 5 | COPY . . 6 | WORKDIR /home/app/zmanim_api 7 | RUN pdm install 8 | ENV PYTHONPATH=/home/app 9 | ENV DOCKER_MODE=true 10 | EXPOSE 8000 11 | CMD ["pdm", "run", "python", "main.py"] 12 | -------------------------------------------------------------------------------- /zmanim_api/routers/openapi_desctiptions.py: -------------------------------------------------------------------------------- 1 | lang = 'Language. `en` and `ru` supported' 2 | lat = 'Latitude, like `32.09`' 3 | lng = 'Longitude, like `34.86`' 4 | date = 'Date in ISO format, like `2020-04-15`' 5 | dt = 'Date and time in ISO format, like `2020-04-15T13:55`' 6 | tz = 'Timezone, like `Europe/Moscow`' 7 | 8 | -------------------------------------------------------------------------------- /zmanim_api/settings.py: -------------------------------------------------------------------------------- 1 | from os import environ 2 | 3 | import sentry_sdk 4 | 5 | 6 | I18N_DOMAIN = 'zmanim_api' 7 | ROOT_PATH = environ.get('ROOT_PATH', '') 8 | SENTRY_PUBLIC_KEY = environ.get('SENTRY_PUBLIC_KEY') 9 | 10 | 11 | if SENTRY_PUBLIC_KEY: 12 | sentry_sdk.init( # pragma: no cover 13 | dsn=SENTRY_PUBLIC_KEY 14 | ) 15 | -------------------------------------------------------------------------------- /test/consts.py: -------------------------------------------------------------------------------- 1 | from datetime import date 2 | 3 | 4 | LAT = 32.09 5 | LNG = 34.86 6 | ZERO_ELEVATION = 0 7 | DATE = '2020-04-15' 8 | PY_DATE = date(2020, 4, 15) 9 | 10 | 11 | GEO_DATE_PARAMS = { 12 | 'date': DATE, 13 | 'elevation': ZERO_ELEVATION, 14 | 'lat': LAT, 15 | 'lng': LNG 16 | } 17 | 18 | CL_OFFSET = 18 19 | HAVDALA = 'tzeis_8_5_degrees' 20 | 21 | ASUR_BEMELACHA_PARAMS = { 22 | 'cl_offset': CL_OFFSET, 23 | 'havdala': HAVDALA 24 | } 25 | -------------------------------------------------------------------------------- /test/test_routers/test_errors.py: -------------------------------------------------------------------------------- 1 | from fastapi.testclient import TestClient 2 | 3 | from zmanim_api.main import app 4 | 5 | 6 | client = TestClient(app) 7 | 8 | 9 | def test_daf_yomi_endpoint(): 10 | params = {'date': 'broken_date'} 11 | expected = {'message': 'Invalid date provided! Invalid isoformat string: \'broken_date\''} 12 | 13 | actual = client.get('/daf_yomi', params=params) 14 | assert actual.status_code == 400 15 | assert actual.json() == expected 16 | -------------------------------------------------------------------------------- /zmanim_api/engine/daf_yomi.py: -------------------------------------------------------------------------------- 1 | from datetime import date 2 | 3 | from zmanim.limudim.calculators.daf_yomi_bavli import DafYomiBavli 4 | 5 | from ..models import DafYomi, SimpleSettings 6 | 7 | 8 | def get_daf_yomi(date_: date = None) -> DafYomi: 9 | daf_yomi = DafYomiBavli().limud(date_ or date.today()) 10 | daf_yomi_data = { 11 | 'masehet': daf_yomi.unit.components[0][0], 12 | 'daf': daf_yomi.unit.components[0][1] 13 | } 14 | settings = SimpleSettings(date=date_) 15 | return DafYomi(settings=settings, **daf_yomi_data) 16 | -------------------------------------------------------------------------------- /.github/workflows/tests.yaml: -------------------------------------------------------------------------------- 1 | name: Zmanim Api Tests 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | tests: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | - name: Set up Python 14 | uses: actions/setup-python@v2 15 | with: 16 | python-version: '3.11' 17 | - uses: pdm-project/setup-pdm@v3 18 | with: 19 | python-version: '3.11' 20 | - name: Install requirements 21 | run: pdm install -G :all 22 | 23 | - name: Run tests 24 | run: | 25 | pdm run tests 26 | pdm run xml 27 | - name: Codecov upload 28 | run: bash <(curl -s https://codecov.io/bash) 29 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | name: Zmanim Api CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | # pull_request: 8 | # branches: 9 | # - master 10 | 11 | jobs: 12 | ci: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v1 16 | - name: Docker login 17 | run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }} 18 | - name: Build 19 | run: docker build -t zmanim-api -f Dockerfile . 20 | - name: Tags 21 | run: | 22 | docker tag zmanim-api ${{ secrets.DOCKER_USER }}/zmanim-api:${{ github.sha }} 23 | docker tag zmanim-api ${{ secrets.DOCKER_USER }}/zmanim-api:latest 24 | - name: Push 25 | run: | 26 | docker push ${{ secrets.DOCKER_USER }}/zmanim-api:${{ github.sha }} 27 | docker push ${{ secrets.DOCKER_USER }}/zmanim-api:latest 28 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.pdm.build] 2 | includes = ["zmanim_api"] 3 | [project] 4 | name = "zmanim-api" 5 | version = "0.1.0" 6 | description = "" 7 | authors = [ 8 | {name = "Benyamin Ginzburg", email = "benyomin.94@gmail.com"}, 9 | ] 10 | dependencies = [ 11 | "fastapi==0.104.0", 12 | "pydantic==2.4.2", 13 | "uvicorn==0.23.2", 14 | "arrow==1.2.3", 15 | "timezonefinder==6.2.0", 16 | "zmanim==0.3.1", 17 | "betterlogging==0.2.1", 18 | "sentry-sdk==1.32.0", 19 | "tzdata" 20 | ] 21 | requires-python = ">=3.11,<3.12" 22 | readme = "README.md" 23 | license = {text = "GPL-3.0"} 24 | 25 | 26 | [tool.pdm.dev-dependencies] 27 | test = [ 28 | "pytest==7.4.2", 29 | "httpx==0.25.0", 30 | "coverage==7.2.3", 31 | ] 32 | 33 | [build-system] 34 | requires = ["pdm-backend"] 35 | build-backend = "pdm.backend" 36 | 37 | [tool.pdm.scripts] 38 | tests = "coverage run -m pytest -v test/" 39 | xml = "coverage xml" 40 | -------------------------------------------------------------------------------- /zmanim_api/utils.py: -------------------------------------------------------------------------------- 1 | import functools 2 | from datetime import date, timedelta 3 | 4 | from timezonefinder import TimezoneFinder 5 | 6 | 7 | @functools.cache 8 | def get_tz(lat: float, lng: float) -> str: 9 | """ Calculates timezone from coordinates """ 10 | tf = TimezoneFinder() 11 | tz = tf.timezone_at(lng=lng, lat=lat) 12 | 13 | if tz == 'Asia/Hebron': 14 | tz = 'Asia/Jerusalem' 15 | 16 | # dateutil still not supports new 'Europe/Kyiv' timezone, thus... 17 | if tz == 'Europe/Kyiv': 18 | tz = 'Europe/Kiev' 19 | 20 | return tz 21 | 22 | 23 | def is_diaspora(tz: str) -> bool: 24 | return False if tz in ['Asia/Tel_Aviv', 'Asia/Jerusalem', 'Asia/Hebron'] else True 25 | 26 | 27 | def get_next_weekday(d: date, weekday: int) -> date: 28 | current_day = d.weekday() 29 | res = weekday - current_day 30 | if res < 0: 31 | res = 7 + res 32 | return d + timedelta(days=res) 33 | 34 | 35 | -------------------------------------------------------------------------------- /uvicorn_logger.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "disable_existing_loggers": false, 4 | "formatters": { 5 | "default": { 6 | "()": "betterlogging.ColorizedFormatter" 7 | }, 8 | "access": { 9 | "()": "betterlogging.ColorizedFormatter", 10 | "fmt": "%(c_fg_green)s%(asctime)s %(c_color)s%(levelname)-8s%(c_reset)s %(c_fg_cyan)s[%(name)s] %(c_reset)s%(message)s" 11 | } 12 | }, 13 | "handlers": { 14 | "default": { 15 | "formatter": "default", 16 | "class": "logging.StreamHandler" 17 | }, 18 | "access": { 19 | "formatter": "access", 20 | "class": "logging.StreamHandler", 21 | "stream": "ext://sys.stdout" 22 | } 23 | }, 24 | "loggers": { 25 | "": { 26 | "handlers": [ 27 | "default" 28 | ], 29 | "level": "TRACE" 30 | }, 31 | "uvicorn.error": { 32 | "level": "INFO" 33 | }, 34 | "uvicorn.access": { 35 | "handlers": [ 36 | "access" 37 | ], 38 | "level": "INFO", 39 | "propagate": false 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /test/test_utils.py: -------------------------------------------------------------------------------- 1 | from datetime import date 2 | 3 | from zmanim_api.utils import get_next_weekday, get_tz 4 | 5 | 6 | def test_get_next_weekday(): 7 | weekday = 5 8 | d1 = date(2020, 9, 22) 9 | d2 = date(2020, 9, 25) 10 | d3 = date(2020, 9, 26) 11 | d4 = date(2020, 9, 27) 12 | 13 | expected_1 = date(2020, 9, 22) 14 | expected_2 = date(2020, 10, 3) 15 | 16 | assert get_next_weekday(d1, weekday), expected_1 17 | assert get_next_weekday(d2, weekday), expected_1 18 | assert get_next_weekday(d3, weekday), expected_2 19 | assert get_next_weekday(d4, weekday), expected_2 20 | 21 | 22 | def test_get_tz(): 23 | loc1 = 55.5, 37.7 24 | loc2 = 32.09, 34.87 25 | loc3 = 31.54, 35.25 26 | loc4 = 40.68, -73.96 27 | 28 | expected_1 = 'Europe/Moscow' 29 | expected_2 = 'Asia/Jerusalem' 30 | expected_3 = 'Asia/Jerusalem' 31 | expected_4 = 'America/New_York' 32 | 33 | assert get_tz(*loc1), expected_1 34 | assert get_tz(*loc2), expected_2 35 | assert get_tz(*loc3), expected_3 36 | assert get_tz(*loc4), expected_4 37 | -------------------------------------------------------------------------------- /test/test_api_helpers.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime as dt, date 2 | 3 | import pytest 4 | 5 | from test.consts import LAT, LNG 6 | from zmanim_api.api_helpers import ( 7 | validate_date_or_get_now, 8 | validate_datetime_or_get_now, 9 | DateException 10 | ) 11 | 12 | 13 | def test_validate_date_or_get_now_without_args(): 14 | resp = validate_date_or_get_now(None) 15 | assert isinstance(resp, date), True 16 | 17 | 18 | def test_validate_date_or_get_now_with_correct_arg(): 19 | expexted = date(2020, 4, 15) 20 | resp = validate_date_or_get_now('2020-04-15') 21 | assert resp == expexted 22 | 23 | 24 | def test_validate_date_or_get_now_with_incorrect_arg(): 25 | with pytest.raises(DateException): 26 | validate_date_or_get_now('15/04/2020') 27 | 28 | 29 | def test_validate_datetime_or_get_now_without_args(): 30 | resp = validate_datetime_or_get_now(None, LAT, LNG) 31 | assert isinstance(resp, dt), True 32 | 33 | 34 | def test_validate_datetime_or_get_now_with_correct_arg(): 35 | expexted = dt(2020, 4, 15, 16, 55) 36 | resp = validate_datetime_or_get_now('2020-04-15T16:55', LAT, LNG) 37 | assert resp == expexted 38 | 39 | 40 | def test_validate_datetime_or_get_now_with_incorrect_arg(): 41 | with pytest.raises(DateException): 42 | validate_datetime_or_get_now('15/04/2020 16:55', LAT, LNG) 43 | -------------------------------------------------------------------------------- /zmanim_api/engine/rosh_chodesh.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime as dt, date, timedelta 2 | from typing import Optional 3 | 4 | from zmanim.hebrew_calendar.jewish_calendar import JewishCalendar 5 | 6 | from ..models import RoshChodesh, SimpleSettings 7 | 8 | 9 | def get_next_rosh_chodesh(date_: date = None, original_date: Optional[date] = None) -> RoshChodesh: 10 | calendar = JewishCalendar(date_ or dt.now()) 11 | 12 | if calendar.is_rosh_chodesh(): 13 | return get_next_rosh_chodesh(date_ + timedelta(days=-1), original_date or date_) 14 | 15 | if calendar.jewish_month == 6: 16 | return get_next_rosh_chodesh(date_ + timedelta(days=calendar.days_in_jewish_month())) 17 | 18 | month_length = calendar.days_in_jewish_month() 19 | days_until_rh = 30 - calendar.jewish_day 20 | calendar.forward(days_until_rh) 21 | 22 | rh_dates = [calendar.gregorian_date.isoformat()] 23 | if month_length == 30: 24 | rh_dates.append(calendar.forward().gregorian_date.isoformat()) 25 | 26 | molad = calendar.molad() 27 | molad_iso = dt(molad.gregorian_year, molad.gregorian_month, molad.gregorian_day, 28 | molad.molad_hours, molad.molad_minutes) 29 | 30 | rh_data = { 31 | 'month_name': calendar.jewish_month_name(), 32 | 'days': rh_dates, 33 | 'duration': 1 if month_length == 29 else 2, 34 | 'molad': [molad_iso, molad.molad_chalakim] 35 | } 36 | settings = SimpleSettings(date=original_date or date_ or dt.now()) 37 | return RoshChodesh(settings=settings, **rh_data) 38 | -------------------------------------------------------------------------------- /test/test_engine/test_rosh_chodesh.py: -------------------------------------------------------------------------------- 1 | from datetime import date, datetime as dt 2 | 3 | from zmanim_api.engine.rosh_chodesh import get_next_rosh_chodesh 4 | from ..consts import PY_DATE 5 | 6 | 7 | def test_regular_rosh_chodesh(): 8 | expected = { 9 | 'settings': {'date': date.fromisoformat('2020-04-15')}, 10 | 'month_name': 'iyar', 11 | 'days': [date.fromisoformat('2020-04-24'), date.fromisoformat('2020-04-25')], 12 | 'duration': 2, 13 | 'molad': ('2020-04-22T22:58', 12) 14 | } 15 | 16 | actual = get_next_rosh_chodesh(PY_DATE) 17 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 18 | 19 | 20 | def test_rosh_chodesh_during_rosh_chodesh(): 21 | expected = { 22 | 'settings': {'date': date.fromisoformat('2020-04-25')}, 23 | 'month_name': 'iyar', 24 | 'days': [date.fromisoformat('2020-04-24'), date.fromisoformat('2020-04-25')], 25 | 'duration': 2, 26 | 'molad': ('2020-04-22T22:58', 12) 27 | } 28 | 29 | actual = get_next_rosh_chodesh(date(2020, 4, 25)) 30 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 31 | 32 | 33 | def test_rosh_chodesh_before_rosh_hashana(): 34 | expected = { 35 | 'settings': {'date': date.fromisoformat('2020-09-30')}, 36 | 'month_name': 'cheshvan', 37 | 'days': [date.fromisoformat('2020-10-18'), date.fromisoformat('2020-10-19')], 38 | 'duration': 2, 39 | 'molad': ('2020-10-17T03:23', 0) 40 | } 41 | 42 | actual = get_next_rosh_chodesh(date(2020, 9, 1)) 43 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 44 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | #*.mo 52 | #*.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | 106 | \.idea/ 107 | -------------------------------------------------------------------------------- /zmanim_api/main.py: -------------------------------------------------------------------------------- 1 | import logging 2 | from contextlib import asynccontextmanager 3 | from os import getenv 4 | 5 | import sentry_sdk 6 | import uvicorn 7 | from fastapi import FastAPI, Request 8 | from fastapi.responses import JSONResponse 9 | from betterlogging import get_colorized_logger, DEBUG 10 | 11 | from zmanim_api.api_helpers import DateException 12 | from zmanim_api.settings import ROOT_PATH, SENTRY_PUBLIC_KEY 13 | from zmanim_api.routers.main_router import main_router 14 | 15 | 16 | logger = get_colorized_logger() 17 | logger.setLevel(DEBUG) 18 | 19 | 20 | @asynccontextmanager 21 | async def lifespan(_: FastAPI): # pragma: no cover 22 | logger.info('STARTING ZMANIM API...') 23 | yield 24 | 25 | 26 | app = FastAPI( 27 | lifespan=lifespan, 28 | root_path=f'/{ROOT_PATH}', 29 | docs_url='/', 30 | title='Zmanim API', 31 | version='1.0.1' 32 | ) 33 | 34 | app.include_router(main_router, tags=['Main']) 35 | 36 | 37 | @app.middleware('http') # pragma: no cover 38 | async def set_sentry_context(request: Request, call_next): 39 | if SENTRY_PUBLIC_KEY: 40 | sentry_sdk.set_context('request', dict(request)) 41 | sentry_sdk.set_user({'ip_address': request.client.host}) 42 | return await call_next(request) 43 | 44 | 45 | @app.exception_handler(DateException) 46 | async def date_exception_handler(request: Request, exc: DateException): 47 | return JSONResponse( 48 | status_code=400, 49 | content={ 50 | 'message': f'Invalid date provided! {exc}' 51 | } 52 | ) 53 | 54 | 55 | @app.exception_handler(Exception) # pragma: no cover 56 | async def main_exception_handler(request: Request, e: Exception): 57 | sentry_sdk.capture_exception(e) 58 | 59 | return JSONResponse( 60 | status_code=500, 61 | content={'message': repr(e)} 62 | ) 63 | 64 | 65 | if __name__ == '__main__': # pragma: no cover 66 | uvicorn.run( 67 | app, 68 | host='0.0.0.0' if getenv('DOCKER_MODE') else '127.0.0.1', 69 | port=8000, 70 | use_colors=True, 71 | log_level=logging.DEBUG, 72 | log_config='../uvicorn_logger.json' 73 | ) 74 | 75 | # todo return zmanim calculation errors 76 | # todo translate: parshat hashavua names; daf yomi units; 77 | 78 | -------------------------------------------------------------------------------- /zmanim_api/api_helpers.py: -------------------------------------------------------------------------------- 1 | import zoneinfo 2 | from enum import Enum 3 | from typing import Optional 4 | from datetime import date, datetime 5 | 6 | from zmanim_api.utils import get_tz 7 | 8 | DATE_PATTERN = r'^\d{1,2}\/\d{1,2}\/\d{1,4}$' 9 | DATE_FORMAT = '%d/%m/%Y' 10 | 11 | 12 | class DateException(Exception): 13 | ... 14 | 15 | 16 | class LanguageChoices(Enum): 17 | en = 'en' 18 | ru = 'ru' 19 | 20 | 21 | class SimpleHolidayChoices(Enum): 22 | chanukah = 'chanukah' 23 | tu_bi_shvat = 'tu_bi_shvat' 24 | purim = 'purim' 25 | lag_baomer = 'lag_baomer' 26 | tu_be_av = 'tu_be_av' 27 | yom_hashoah = 'yom_hashoah' 28 | yom_hazikaron = 'yom_hazikaron' 29 | yom_haatzmaut = 'yom_haatzmaut' 30 | yom_yerushalaim = 'yom_yerushalaim' 31 | 32 | 33 | class YomTovChoices(Enum): 34 | rosh_hashana = 'rosh_hashana' 35 | yom_kippur = 'yom_kippur' 36 | succot = 'succot' 37 | shmini_atzeres = 'shmini_atzeres' 38 | pesach = 'pesach' 39 | shavuot = 'shavuot' 40 | 41 | 42 | class FastsChoices(str, Enum): 43 | fast_gedalia = 'fast_gedalia' 44 | fast_10_teves = 'fast_10_teves' 45 | fast_esther = 'fast_esther' 46 | fast_17_tammuz = 'fast_17_tammuz' 47 | fast_9_av = 'fast_9_av' 48 | 49 | 50 | class HavdalaChoices(str, Enum): 51 | tzeis_5_95_degrees = 'tzeis_5_95_degrees' 52 | tzeis_8_5_degrees = 'tzeis_8_5_degrees' 53 | tzeis_42_minutes = 'tzeis_42_minutes' 54 | tzeis_72_minutes = 'tzeis_72_minutes' 55 | 56 | 57 | HAVDALA_PARAMS = { 58 | 'tzeis_8_5_degrees': {'degrees': 8.5}, 59 | 'tzeis_72_minutes': {'offset': 72}, 60 | 'tzeis_42_minutes': {'offset': 42}, 61 | 'tzeis_5_95_degrees': {'degrees': 5.95}, 62 | } 63 | 64 | 65 | def validate_date_or_get_now(date_: Optional[str], lat: float = 32.09, lng: float = 34.86) -> date: 66 | if date_: 67 | try: 68 | response = date.fromisoformat(date_) 69 | except ValueError as e: 70 | raise DateException(e) 71 | 72 | else: 73 | tz_name = get_tz(lat, lng) 74 | tz = zoneinfo.ZoneInfo(tz_name) 75 | 76 | response = datetime.now().astimezone(tz).date() 77 | return response 78 | 79 | 80 | def validate_datetime_or_get_now(dt: Optional[str], lat: float, lng: float) -> datetime: 81 | if dt: 82 | try: 83 | response = datetime.fromisoformat(dt) 84 | except ValueError as e: 85 | raise DateException(e) 86 | else: 87 | tz_name = get_tz(lat, lng) 88 | tz = zoneinfo.ZoneInfo(tz_name) 89 | response = datetime.now().astimezone(tz) 90 | return response 91 | -------------------------------------------------------------------------------- /zmanim_api/engine/shabbat.py: -------------------------------------------------------------------------------- 1 | from datetime import timedelta, date 2 | 3 | from zmanim.util.geo_location import GeoLocation 4 | from zmanim.zmanim_calendar import ZmanimCalendar 5 | from zmanim.hebrew_calendar.jewish_calendar import JewishCalendar 6 | from zmanim.limudim.calculators.parsha import Parsha 7 | 8 | from ..models import Shabbat, Settings 9 | from ..api_helpers import HavdalaChoices, HAVDALA_PARAMS 10 | from ..utils import get_next_weekday, get_tz, is_diaspora 11 | 12 | 13 | def get_shabbat( 14 | # lang: str, 15 | lat: float, 16 | lng: float, 17 | elevation: float, 18 | cl_offset: int, 19 | havdala: HavdalaChoices, 20 | date_: date 21 | ) -> Shabbat: 22 | # 1. get friday nearest to the date 23 | friday = get_next_weekday(date_, 4) 24 | saturday = friday + timedelta(days=1) 25 | 26 | tz = get_tz(lat, lng) 27 | location = GeoLocation('', lat, lng, tz, elevation) 28 | 29 | friday_calendar = ZmanimCalendar(candle_lighting_offset=cl_offset, geo_location=location, date=friday) 30 | saturday_calendar = ZmanimCalendar(candle_lighting_offset=cl_offset, geo_location=location, date=saturday) 31 | 32 | cl_time = friday_calendar.candle_lighting() 33 | havdala_params = HAVDALA_PARAMS[havdala.name] 34 | tzais = saturday_calendar.tzais(havdala_params) 35 | 36 | if tzais: 37 | havdala_time = tzais 38 | elif saturday_calendar.chatzos(): # summer nights on north 39 | havdala_time = saturday_calendar.chatzos() + timedelta(hours=12) 40 | else: # polar night 41 | havdala_time = None 42 | 43 | late_cl_warning = False if friday_calendar.alos() else True 44 | 45 | jewish_calendar = JewishCalendar(saturday, in_israel=not is_diaspora(tz)) 46 | if jewish_calendar.is_yom_tov_assur_bemelacha() or jewish_calendar.is_chol_hamoed(): 47 | torah_part = jewish_calendar.significant_day() 48 | else: 49 | torah_part = Parsha(in_israel=not is_diaspora(tz)).limud(saturday).description() 50 | 51 | data = { 52 | 'torah_part': torah_part, 53 | 'candle_lighting': cl_time and cl_time.isoformat(timespec='minutes'), 54 | 'cl_offset': cl_offset, 55 | 'havdala': havdala_time and havdala_time.isoformat(timespec='minutes'), 56 | 'havdala_opinion': havdala.value, 57 | 'late_cl_warning': late_cl_warning 58 | } 59 | settings = Settings( 60 | cl_offset=cl_offset, 61 | havdala_opinion=havdala, 62 | coordinates=(lat, lng), 63 | elevation=elevation, 64 | date=date_ 65 | ) 66 | 67 | return Shabbat(settings=settings, **data) 68 | -------------------------------------------------------------------------------- /zmanim_api/models.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import json 4 | from datetime import datetime, time, date as Date 5 | from pydantic import BaseModel, field_serializer 6 | 7 | 8 | class SimpleSettings(BaseModel): 9 | date: Date | None = None 10 | jewish_date: str | None = None 11 | holiday_name: str | None = None 12 | 13 | 14 | class Settings(SimpleSettings): 15 | cl_offset: int | None = None 16 | havdala_opinion: str | None = None 17 | coordinates: tuple[float, float] | None = None 18 | elevation: int | None = None 19 | fast_name: str | None = None 20 | yomtov_name: str | None = None 21 | 22 | 23 | class ZmanimRequest(BaseModel): 24 | sunrise: bool = True 25 | alos: bool = True 26 | sof_zman_tefila_gra: bool = True 27 | sof_zman_tefila_ma: bool = True 28 | misheyakir_10_2: bool = True 29 | sof_zman_shema_gra: bool = True 30 | sof_zman_shema_ma: bool = True 31 | chatzos: bool = True 32 | mincha_ketana: bool = True 33 | mincha_gedola: bool = True 34 | plag_mincha: bool = True 35 | sunset: bool = True 36 | tzeis_8_5_degrees: bool = True 37 | tzeis_72_minutes: bool = True 38 | tzeis_42_minutes: bool = True 39 | tzeis_5_95_degrees: bool = True 40 | chatzot_laila: bool = True 41 | astronomical_hour_ma: bool = True 42 | astronomical_hour_gra: bool = True 43 | 44 | 45 | class ZmanimResponse(BaseModel): 46 | settings: Settings 47 | alos: datetime | None = None 48 | sunrise: datetime | None = None 49 | misheyakir_10_2: datetime | None = None 50 | sof_zman_shema_ma: datetime | None = None 51 | sof_zman_shema_gra: datetime | None = None 52 | sof_zman_tefila_ma: datetime | None = None 53 | sof_zman_tefila_gra: datetime | None = None 54 | chatzos: datetime | None = None 55 | mincha_gedola: datetime | None = None 56 | mincha_ketana: datetime | None = None 57 | plag_mincha: datetime | None = None 58 | sunset: datetime | None = None 59 | tzeis_5_95_degrees: datetime | None = None 60 | tzeis_8_5_degrees: datetime | None = None 61 | tzeis_42_minutes: datetime | None = None 62 | tzeis_72_minutes: datetime | None = None 63 | chatzot_laila: datetime | None = None 64 | astronomical_hour_ma: time | None = None 65 | astronomical_hour_gra: time | None = None 66 | 67 | 68 | class AsurBeMelachaDay(BaseModel): 69 | date: Date | None = None 70 | candle_lighting: datetime | None = None 71 | havdala: datetime | None = None 72 | 73 | 74 | class Shabbat(AsurBeMelachaDay): 75 | settings: Settings 76 | torah_part: str = None 77 | late_cl_warning: bool = False 78 | 79 | 80 | class RoshChodesh(BaseModel): 81 | settings: SimpleSettings 82 | month_name: str 83 | days: list[Date] 84 | duration: int 85 | molad: tuple[datetime, int] 86 | 87 | @field_serializer('molad') 88 | def serialize_molad(self, molad: tuple[datetime, int], _info) -> tuple[str, int]: 89 | return molad[0].isoformat(timespec='minutes'), molad[1] 90 | 91 | # model_config = ConfigDict( 92 | # json_encoders={ 93 | # datetime: lambda d: d.isoformat(timespec='minutes') 94 | # } 95 | # ) 96 | 97 | 98 | class DafYomi(BaseModel): 99 | settings: SimpleSettings 100 | masehet: str 101 | daf: int 102 | 103 | 104 | class Holiday(BaseModel): 105 | settings: SimpleSettings 106 | date: Date 107 | 108 | 109 | class YomTov(BaseModel): 110 | settings: Settings 111 | pre_shabbat: AsurBeMelachaDay | None = None 112 | 113 | pesach_eating_chanetz_till: datetime | None = None 114 | pesach_burning_chanetz_till: datetime | None = None 115 | 116 | day_1: AsurBeMelachaDay 117 | day_2: AsurBeMelachaDay | None = None 118 | post_shabbat: AsurBeMelachaDay | None = None 119 | hoshana_rabba: Date | None = None 120 | 121 | pesach_part_2_day_1: AsurBeMelachaDay | None = None 122 | pesach_part_2_day_2: AsurBeMelachaDay | None = None 123 | pesach_part_2_post_shabat: AsurBeMelachaDay | None = None 124 | 125 | 126 | class Fast(BaseModel): 127 | settings: Settings 128 | moved_fast: bool | None = False 129 | fast_start: datetime | None = None 130 | chatzot: datetime | None = None 131 | havdala_5_95_dgr: datetime | None = None 132 | havdala_8_5_dgr: datetime | None = None 133 | havdala_42_min: datetime | None = None 134 | 135 | 136 | class BooleanResp(BaseModel): 137 | result: bool 138 | -------------------------------------------------------------------------------- /zmanim_api/engine/zmanim_module.py: -------------------------------------------------------------------------------- 1 | import zoneinfo 2 | from typing import Optional 3 | from datetime import date, datetime as dt, time, timedelta, datetime 4 | 5 | import arrow 6 | from zmanim.util.geo_location import GeoLocation 7 | from zmanim.zmanim_calendar import ZmanimCalendar 8 | from zmanim.hebrew_calendar.jewish_date import JewishDate 9 | 10 | from zmanim_api.utils import get_tz, is_diaspora 11 | from zmanim_api.models import ZmanimRequest, ZmanimResponse, Settings, BooleanResp 12 | 13 | 14 | GEOMETRIC_ZENITH = 90 15 | 16 | 17 | class ZmanimCalculator: 18 | zc: ZmanimCalendar 19 | jewish_date: str 20 | 21 | def __init__(self, lat: float, lng: float, date_: date, elevation: float): 22 | tz = get_tz(lat, lng) 23 | 24 | jewish_date = JewishDate(date_).jewish_date 25 | self.jewish_date = f'{jewish_date[0]}-{jewish_date[1]}-{jewish_date[2]}' 26 | 27 | location = GeoLocation('', lat, lng, tz, elevation) 28 | self.zc = ZmanimCalendar(geo_location=location, date=date_) 29 | 30 | @property 31 | def sunrise(self) -> Optional[datetime]: 32 | return self.zc.sunrise() 33 | 34 | @property 35 | def alos(self) -> Optional[datetime]: 36 | return self.zc.alos() 37 | 38 | @property 39 | def sof_zman_tefila_gra(self) -> datetime: 40 | return self.zc.sof_zman_tfila_gra() 41 | 42 | @property 43 | def sof_zman_tefila_ma(self) -> Optional[datetime]: 44 | return self.zc.sof_zman_tfila_mga() 45 | 46 | @property 47 | def misheyakir_10_2(self) -> Optional[datetime]: 48 | return self.zc.sunrise_offset_by_degrees(GEOMETRIC_ZENITH + 10.2) 49 | 50 | @property 51 | def sof_zman_shema_gra(self) -> datetime: 52 | return self.zc.sof_zman_shma_gra() 53 | 54 | @property 55 | def sof_zman_shema_ma(self) -> datetime: 56 | return self.zc.sof_zman_shma_mga() 57 | 58 | @property 59 | def chatzos(self) -> Optional[datetime]: 60 | return self.zc.chatzos() 61 | 62 | @property 63 | def mincha_ketana(self) -> Optional[datetime]: 64 | return self.zc.mincha_ketana() 65 | 66 | @property 67 | def mincha_gedola(self) -> Optional[datetime]: 68 | return self.zc.mincha_gedola() 69 | 70 | @property 71 | def plag_mincha(self) -> Optional[datetime]: 72 | return self.zc.plag_hamincha() 73 | 74 | @property 75 | def sunset(self) -> Optional[datetime]: 76 | return self.zc.sunset() 77 | 78 | @property 79 | def tzeis_8_5_degrees(self) -> Optional[datetime]: 80 | return self.zc.tzais() 81 | 82 | @property 83 | def tzeis_72_minutes(self) -> Optional[datetime]: 84 | return self.zc.tzais({'offset': 72}) 85 | 86 | @property 87 | def tzeis_42_minutes(self) -> Optional[datetime]: 88 | return self.zc.tzais({'offset': 42}) 89 | 90 | @property 91 | def tzeis_5_95_degrees(self) -> Optional[datetime]: 92 | return self.zc.tzais({'degrees': 5.95}) 93 | 94 | @property 95 | def astronomical_hour_ma(self) -> time: 96 | return arrow.get(int(self.zc.shaah_zmanis_mga() / 1000)).time() 97 | 98 | @property 99 | def astronomical_hour_gra(self) -> time: 100 | return arrow.get(int(self.zc.shaah_zmanis_gra() / 1000)).time() 101 | 102 | @property 103 | def chatzot_laila(self) -> Optional[datetime]: 104 | chatzos = self.zc.chatzos() 105 | return chatzos and chatzos + timedelta(hours=12) 106 | 107 | 108 | def get_zmanim( 109 | date_: date, 110 | lat: float, 111 | lng: float, 112 | elevation: float, 113 | settings: ZmanimRequest 114 | ) -> ZmanimResponse: 115 | zmanim_calc = ZmanimCalculator(lat, lng, date_, elevation) 116 | 117 | zmanim = {} 118 | for zman_name, is_active in settings.model_dump().items(): 119 | if not is_active: 120 | continue 121 | 122 | zmanim[zman_name] = getattr(zmanim_calc, zman_name) 123 | 124 | settings = Settings(date=date_, coordinates=(lat, lng), elevation=elevation, jewish_date=zmanim_calc.jewish_date) 125 | return ZmanimResponse(settings=settings, **zmanim) 126 | 127 | 128 | def is_asur_bemelaha( 129 | dt_: dt, 130 | lat: float, 131 | lng: float, 132 | elevation: float 133 | ) -> BooleanResp: 134 | # todo add tzeis option 135 | tz = get_tz(lat, lng) 136 | is_israel = not is_diaspora(tz) 137 | 138 | location = GeoLocation('', lat, lng, tz, elevation) 139 | calendar = ZmanimCalendar(geo_location=location, date=dt_.date()) 140 | 141 | dt_ = dt_.astimezone(zoneinfo.ZoneInfo(tz)) 142 | resp = calendar.is_assur_bemelacha(current_time=dt_, in_israel=is_israel) 143 | return BooleanResp(result=resp) 144 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 9 | [![Python][python-shield]][python-url] 10 | [![Coverage][coverage-shield]][coverage-url] 11 | [![Contributors][contributors-shield]][contributors-url] 12 | [![Forks][forks-shield]][forks-url] 13 | [![Stargazers][stars-shield]][stars-url] 14 | [![Issues][issues-shield]][issues-url] 15 | [![MIT License][license-shield]][license-url] 16 | [![LinkedIn][linkedin-shield]][linkedin-url] 17 | 18 | 19 | 20 | 21 | ## Table of Contents 22 | 23 | * [About the Project](#about-the-project) 24 | * [Built With](#built-with) 25 | * [Getting Started](#getting-started) 26 | * [Installation](#installation) 27 | * [Tests](#tests) 28 | * [Usage](#usage) 29 | * [Contributing](#contributing) 30 | * [Contact](#contact) 31 | 32 | 33 | ## About The Project 34 | 35 | Simple high-level api for all features of hebrew calendar. 36 | [**Explore the swagger »**](https://api.ginzburg.io/zmanim) 37 | 38 | 39 | ### Built With 40 | 41 | * [Python 3.11](https://www.python.org/downloads/release/python-311/) 42 | * [FastAPI](https://github.com/tiangolo/fastapi) 43 | * [KosherJava's](https://github.com/KosherJava/zmanim) [python port](https://github.com/pinnymz/python-zmanim) 44 | 45 | 46 | 47 | 48 | ## Getting Started 49 | 50 | To get a local copy up and running follow these simple steps. 51 | 52 | ### Installation 53 | #### Docker 54 | 1. Run `docker run -p 8000:8000 benyomin/zmanim-api:latest` 55 | 2. Open http://localhost:8000 in your browser to explore the swagger. 56 | 57 | #### Python 58 | 1) Clone/fork the repo 59 | 2) Use PDM for build environment and install dependencies: `pdm install` 60 | 3) Go to project folder: `cd %repo_location%/zmanim_api` 61 | 4) Run `python main.py` 62 | 5) Open http://localhost:8000 in your browser to explore the swagger 63 | 64 | ### Tests 65 | Run tests: `pytest test/` 66 | Run with coverage: `coverage run -m pytest -v test/` or `coverage xml` 67 | 68 | 69 | 70 | 71 | ## Usage 72 | 73 | Request: 74 | **`GET`** `http://localhost:8000/shabbat?cl_offset=18&lat=32.09&lng=34.86` 75 | Response: 76 | ```json 77 | { 78 | "candle_lighting": "2020-10-09T17:56:00+03:00", 79 | "havdala": "2020-10-10T18:50:00+03:00", 80 | "settings": { 81 | "date": "2020-10-05", 82 | "cl_offset": 18, 83 | "havdala_opinion": "tzeis_8_5_degrees", 84 | "coordinates": [32.09, 34.86], 85 | "elevation": 0 86 | }, 87 | "torah_part": "shemini_atzeres", 88 | "late_cl_warning": false 89 | } 90 | ``` 91 | 92 | _For more examples, please refer to the [Swagger docs](https://api.ginzburg.io/zmanim)_ 93 | 94 | 95 | 96 | 97 | ## Contributing 98 | 99 | Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**. 100 | 101 | 1. Fork the Project 102 | 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) 103 | 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) 104 | 4. Push to the Branch (`git push origin feature/AmazingFeature`) 105 | 5. Open a Pull Request 106 | 107 | 108 | 109 | 110 | ## Contact 111 | 112 | * Telegram - [@benyomin](https://t.me/benyomin) 113 | * [Email](mailto:benyomin.94@gmail.com) 114 | 115 | Project Link: [https://github.com/benyaming/zmanim_api](https://github.com/benyaming/zmanim_api) 116 | 117 | 118 | 119 | 120 | 121 | [python-shield]: https://img.shields.io/github/pipenv/locked/python-version/benyaming/zmanim_api?style=flat-square 122 | [python-url]: https://img.shields.io/github/pipenv/locked/python-version/benyaming/zmanim_api?style=flat-square 123 | [coverage-shield]: https://img.shields.io/codecov/c/github/benyaming/zmanim_api/master?style=flat-square 124 | [coverage-url]: https://img.shields.io/codecov/c/github/benyaming/zmanim_api/master?style=flat-square 125 | [contributors-shield]: https://img.shields.io/github/contributors/benyaming/zmanim_api.svg?style=flat-square 126 | [contributors-url]: https://github.com/benyaming/zmanim_api/graphs/contributors 127 | [forks-shield]: https://img.shields.io/github/forks/benyaming/zmanim_api.svg?style=flat-square 128 | [forks-url]: https://github.com/benyaming/zmanim_api/network/members 129 | [stars-shield]: https://img.shields.io/github/stars/benyaming/zmanim_api.svg?style=flat-square 130 | [stars-url]: https://github.com/benyaming/zmanim_api/stargazers 131 | [issues-shield]: https://img.shields.io/github/issues/benyaming/zmanim_api.svg?style=flat-square 132 | [issues-url]: https://github.com/benyaming/repo/zmanim_api 133 | [license-shield]: https://img.shields.io/github/license/benyaming/zmanim_api.svg?style=flat-square 134 | [license-url]: https://github.com/benyaming/zmanim_api/blob/master/LICENSE.txt 135 | [linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=flat-square&logo=linkedin&colorB=555 136 | [linkedin-url]: https://linkedin.com/in/benyaming 137 | 138 | 139 | -------------------------------------------------------------------------------- /zmanim_api/routers/main_router.py: -------------------------------------------------------------------------------- 1 | from typing import Optional 2 | 3 | from fastapi import Query, APIRouter 4 | 5 | from ..api_helpers import ( 6 | LanguageChoices, 7 | SimpleHolidayChoices, 8 | YomTovChoices, 9 | FastsChoices, 10 | HavdalaChoices, 11 | validate_date_or_get_now, 12 | validate_datetime_or_get_now 13 | ) 14 | from ..models import ( 15 | ZmanimRequest, 16 | ZmanimResponse, 17 | Shabbat, 18 | RoshChodesh, 19 | DafYomi, 20 | Holiday, 21 | YomTov, 22 | Fast, 23 | BooleanResp 24 | ) 25 | from ..engine.daf_yomi import get_daf_yomi 26 | from ..engine.zmanim_module import get_zmanim, is_asur_bemelaha 27 | from ..engine.shabbat import get_shabbat 28 | from ..engine.rosh_chodesh import get_next_rosh_chodesh 29 | from ..engine import holidays as hd 30 | from . import openapi_desctiptions as ds 31 | 32 | lang_param = Query(LanguageChoices.en, description=ds.lang) 33 | cl_param = Query(18, description='qwerrt', ge=0, lt=100) 34 | date_param = Query(None, description=ds.date) 35 | dt_param = Query(None, description=ds.dt) 36 | lat_param = Query(32.09, description=ds.lat, ge=-90, le=90) 37 | lng_param = Query(34.86, description=ds.lng, ge=-180, le=180) 38 | elevation_param = Query(0, description='') 39 | havdala_param = Query(HavdalaChoices.tzeis_8_5_degrees, description='tzeit') 40 | 41 | 42 | main_router = APIRouter() 43 | 44 | 45 | @main_router.post('/zmanim', response_model=ZmanimResponse, response_model_exclude_none=True) 46 | async def zmanim( 47 | settings: ZmanimRequest, 48 | date: Optional[str] = date_param, 49 | elevation: float = elevation_param, 50 | lat: float = lat_param, 51 | lng: float = lng_param, 52 | ) -> ZmanimResponse: 53 | parsed_date = validate_date_or_get_now(date, lat, lng) 54 | data = get_zmanim( 55 | date_=parsed_date, 56 | lat=lat, 57 | lng=lng, 58 | elevation=elevation, 59 | settings=settings) 60 | return data 61 | 62 | 63 | @main_router.get('/shabbat', response_model=Shabbat, response_model_exclude_none=True) 64 | async def shabbat( 65 | cl_offset: int = cl_param, 66 | lat: float = lat_param, 67 | lng: float = lng_param, 68 | elevation: float = elevation_param, 69 | havdala: HavdalaChoices = havdala_param, 70 | date: Optional[str] = date_param 71 | ) -> Shabbat: 72 | parsed_date = validate_date_or_get_now(date, lat, lng) 73 | data = get_shabbat(lat, lng, elevation, cl_offset, havdala, parsed_date) 74 | return data 75 | 76 | 77 | @main_router.get('/rosh_chodesh', response_model=RoshChodesh, response_model_exclude_none=True) 78 | async def rosh_chodesh(date: Optional[str] = date_param) -> RoshChodesh: 79 | parsed_date = validate_date_or_get_now(date) 80 | data = get_next_rosh_chodesh(parsed_date) 81 | return data 82 | 83 | 84 | @main_router.get('/daf_yomi', response_model=DafYomi, response_model_exclude_none=True) 85 | async def daf_yomi(date: Optional[str] = date_param) -> DafYomi: 86 | parsed_date = validate_date_or_get_now(date) 87 | data = get_daf_yomi(parsed_date) 88 | return data 89 | 90 | 91 | @main_router.get('/holiday', response_model=Holiday, response_model_exclude_none=True) 92 | async def holiday( 93 | holiday_name: SimpleHolidayChoices = Query(..., description='select holiday name'), # todo descr 94 | date: Optional[str] = date_param 95 | ): 96 | parsed_date = validate_date_or_get_now(date) 97 | resp = hd.get_simple_holiday(name=holiday_name.name, date_=parsed_date) 98 | return resp 99 | 100 | 101 | @main_router.get('/yom_tov', response_model=YomTov, response_model_exclude_none=True) 102 | async def yom_tov( 103 | yomtov_name: YomTovChoices = Query(..., description='select yomtov name'), # todo descr 104 | lat: float = lat_param, 105 | lng: float = lng_param, 106 | elevation: int = elevation_param, 107 | cl: int = cl_param, 108 | havdala: HavdalaChoices = havdala_param, 109 | date: Optional[str] = date_param 110 | ): 111 | parsed_date = validate_date_or_get_now(date, lat, lng) 112 | resp = hd.get_yom_tov( 113 | name=yomtov_name.name, 114 | date_=parsed_date, 115 | lat=lat, 116 | lng=lng, 117 | elevation=elevation, 118 | cl=cl, 119 | havdala_opinion=havdala 120 | ) 121 | return resp 122 | 123 | 124 | @main_router.get('/fast', response_model=Fast, response_model_exclude_none=True) 125 | async def fast( 126 | fast_name: FastsChoices = Query(..., description='Select fast name'), 127 | lat: float = lat_param, 128 | lng: float = lng_param, 129 | elevation: int = elevation_param, 130 | date: Optional[str] = date_param 131 | ) -> Fast: 132 | parsed_date = validate_date_or_get_now(date, lat, lng) 133 | data = hd.fast( 134 | name=fast_name.name, 135 | date_=parsed_date, 136 | lat=lat, 137 | lng=lng, 138 | elevation=elevation 139 | ) 140 | return data 141 | 142 | 143 | @main_router.get('/is_asur_bemelacha', response_model=BooleanResp) 144 | async def is_asur_bemelacha( 145 | lat: float = lat_param, 146 | lng: float = lng_param, 147 | elevation: int = elevation_param, 148 | dt: Optional[str] = dt_param 149 | ) -> BooleanResp: 150 | parsed_dt = validate_datetime_or_get_now(dt, lat, lng) 151 | resp = is_asur_bemelaha(parsed_dt, lat, lng, elevation) 152 | return resp 153 | -------------------------------------------------------------------------------- /test/test_engine/test_holiday.py: -------------------------------------------------------------------------------- 1 | from datetime import date 2 | 3 | from zmanim_api.engine.holidays import get_simple_holiday 4 | from zmanim_api.api_helpers import SimpleHolidayChoices 5 | from ..consts import PY_DATE 6 | 7 | 8 | def test_regular_holiday(): 9 | expected = { 10 | 'settings': { 11 | 'date': date.fromisoformat('2020-04-15'), 12 | 'holiday_name': 'tu_bi_shvat' 13 | }, 14 | 'date': date.fromisoformat('2021-01-28') 15 | } 16 | 17 | actual = get_simple_holiday(SimpleHolidayChoices.tu_bi_shvat.value, PY_DATE) 18 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 19 | 20 | 21 | def test_yom_hashoah(): 22 | expected = { 23 | 'settings': { 24 | 'date': date.fromisoformat('2020-04-15'), 25 | 'holiday_name': 'yom_hashoah' 26 | }, 27 | 'date': date.fromisoformat('2020-04-21') 28 | } 29 | 30 | actual = get_simple_holiday(SimpleHolidayChoices.yom_hashoah.value, PY_DATE) 31 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 32 | 33 | 34 | def test_yom_hashoah_on_friday(): 35 | expected = { 36 | 'settings': { 37 | 'date': date.fromisoformat('2021-04-01'), 38 | 'holiday_name': 'yom_hashoah' 39 | }, 40 | 'date': date.fromisoformat('2021-04-08') 41 | } 42 | 43 | actual = get_simple_holiday(SimpleHolidayChoices.yom_hashoah.value, date(2021, 4, 1)) 44 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 45 | 46 | 47 | def test_yom_hashoah_on_sunday(): 48 | expected = { 49 | 'settings': { 50 | 'date': date.fromisoformat('2024-04-01'), 51 | 'holiday_name': 'yom_hashoah' 52 | }, 53 | 'date': date.fromisoformat('2024-05-06') 54 | } 55 | 56 | actual = get_simple_holiday(SimpleHolidayChoices.yom_hashoah.value, date(2024, 4, 1)) 57 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 58 | 59 | 60 | def test_yom_hazikaron(): 61 | expected = { 62 | 'settings': { 63 | 'date': date.fromisoformat('2020-04-15'), 64 | 'holiday_name': 'yom_hazikaron' 65 | }, 66 | 'date': date.fromisoformat('2020-04-28') 67 | } 68 | 69 | actual = get_simple_holiday(SimpleHolidayChoices.yom_hazikaron.value, PY_DATE) 70 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 71 | 72 | 73 | def test_yom_hazikaron_friday_yom_haatzmaut_shabbat(): 74 | expected_1 = { 75 | 'settings': { 76 | 'date': date.fromisoformat('2021-04-01'), 77 | 'holiday_name': 'yom_hazikaron' 78 | }, 79 | 'date': date.fromisoformat('2021-04-14') 80 | } 81 | expected_2 = { 82 | 'settings': { 83 | 'date': date.fromisoformat('2021-04-01'), 84 | 'holiday_name': 'yom_haatzmaut' 85 | }, 86 | 'date': date.fromisoformat('2021-04-15') 87 | } 88 | 89 | actual_1 = get_simple_holiday(SimpleHolidayChoices.yom_hazikaron.value, date(2021, 4, 1)) 90 | actual_2 = get_simple_holiday(SimpleHolidayChoices.yom_haatzmaut.value, date(2021, 4, 1)) 91 | assert actual_1.model_dump(exclude_none=True, by_alias=True) == expected_1 92 | assert actual_2.model_dump(exclude_none=True, by_alias=True) == expected_2 93 | 94 | 95 | def test_yom_hazikaron_shabbat_yom_haatzmaut_sunday(): 96 | expected_1 = { 97 | 'settings': { 98 | 'date': date.fromisoformat('2024-04-01'), 99 | 'holiday_name': 'yom_hazikaron' 100 | }, 101 | 'date': date.fromisoformat('2024-05-13') 102 | } 103 | expected_2 = { 104 | 'settings': { 105 | 'date': date.fromisoformat('2024-04-01'), 106 | 'holiday_name': 'yom_haatzmaut' 107 | }, 108 | 'date': date.fromisoformat('2024-05-14') 109 | } 110 | 111 | actual_1 = get_simple_holiday(SimpleHolidayChoices.yom_hazikaron.value, date(2024, 4, 1)) 112 | actual_2 = get_simple_holiday(SimpleHolidayChoices.yom_haatzmaut.value, date(2024, 4, 1)) 113 | assert actual_1.model_dump(exclude_none=True, by_alias=True) == expected_1 114 | assert actual_2.model_dump(exclude_none=True, by_alias=True) == expected_2 115 | 116 | 117 | def test_yom_hazikaron_wednesdey_yom_haatzmaut_thursday(): 118 | expected_1 = { 119 | 'settings': { 120 | 'date': date.fromisoformat('2022-04-01'), 121 | 'holiday_name': 'yom_hazikaron' 122 | }, 123 | 'date': date.fromisoformat('2022-05-04') 124 | } 125 | expected_2 = { 126 | 'settings': { 127 | 'date': date.fromisoformat('2022-04-01'), 128 | 'holiday_name': 'yom_haatzmaut' 129 | }, 130 | 'date': date.fromisoformat('2022-05-05') 131 | } 132 | 133 | actual_1 = get_simple_holiday(SimpleHolidayChoices.yom_hazikaron.value, date(2022, 4, 1)) 134 | actual_2 = get_simple_holiday(SimpleHolidayChoices.yom_haatzmaut.value, date(2022, 4, 1)) 135 | assert actual_1.model_dump(exclude_none=True, by_alias=True) == expected_1 136 | assert actual_2.model_dump(exclude_none=True, by_alias=True) == expected_2 137 | 138 | 139 | def test_holiday_ducing_holiday(): 140 | expected = { 141 | 'settings': { 142 | 'date': date.fromisoformat('2021-12-01'), 143 | 'holiday_name': 'chanukah' 144 | }, 145 | 'date': date.fromisoformat('2021-11-29') 146 | } 147 | 148 | actual = get_simple_holiday(SimpleHolidayChoices.chanukah.value, date(2021, 12, 1)).model_dump(exclude_none=True, by_alias=True) 149 | assert actual == expected 150 | 151 | 152 | def test_purim_on_first_adar(): 153 | expected = { 154 | 'settings': { 155 | 'date': date.fromisoformat('2022-03-02'), 156 | 'holiday_name': 'purim' 157 | }, 158 | 'date': date.fromisoformat('2022-03-17') 159 | } 160 | actual = get_simple_holiday(SimpleHolidayChoices.purim.value, date(2022, 3, 2)).model_dump(exclude_none=True, by_alias=True) 161 | assert actual == expected 162 | -------------------------------------------------------------------------------- /test/test_engine/test_fasts.py: -------------------------------------------------------------------------------- 1 | from datetime import date, datetime as dt 2 | 3 | from zmanim_api.engine.holidays import fast 4 | from zmanim_api.api_helpers import FastsChoices 5 | from ..consts import LAT, LNG, ZERO_ELEVATION, PY_DATE 6 | 7 | 8 | def test_regular_fast(): 9 | expected = { 10 | 'settings': { 11 | 'date': date.fromisoformat('2020-04-15'), 12 | 'coordinates': (32.09, 34.86), 13 | 'elevation': 0, 14 | 'fast_name': 'fast_9_av' 15 | }, 16 | 'moved_fast': False, 17 | 'fast_start': dt.fromisoformat('2020-07-29T19:39:46.806374+03:00'), 18 | 'chatzot': dt.fromisoformat('2020-07-30T12:46:47.783707+03:00'), 19 | 'havdala_42_min': dt.fromisoformat('2020-07-30T20:21:01.912951+03:00'), 20 | 'havdala_5_95_dgr': dt.fromisoformat('2020-07-30T20:05:29.105997+03:00'), 21 | 'havdala_8_5_dgr': dt.fromisoformat('2020-07-30T20:18:58.749568+03:00') 22 | } 23 | 24 | actual = fast( 25 | FastsChoices.fast_9_av.value, 26 | PY_DATE, 27 | LAT, 28 | LNG, 29 | ZERO_ELEVATION 30 | ) 31 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 32 | 33 | 34 | def test_moved_fast_esther(): 35 | expected = { 36 | 'settings': { 37 | 'date': date.fromisoformat('2024-01-15'), 38 | 'coordinates': (32.09, 34.86), 39 | 'elevation': 0, 40 | 'fast_name': 'fast_esther' 41 | }, 42 | 'moved_fast': True, 43 | 'fast_start': dt.fromisoformat('2024-03-21T04:30:13.115829+02:00'), 44 | 'havdala_42_min': dt.fromisoformat('2024-03-21T18:34:57.556976+02:00'), 45 | 'havdala_5_95_dgr': dt.fromisoformat('2024-03-21T18:17:09.706478+02:00'), 46 | 'havdala_8_5_dgr': dt.fromisoformat('2024-03-21T18:29:15.548910+02:00') 47 | } 48 | 49 | actual = fast( 50 | FastsChoices.fast_esther.value, 51 | date(2024, 1, 15), 52 | LAT, 53 | LNG, 54 | ZERO_ELEVATION 55 | ) 56 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 57 | 58 | 59 | def test_moved_fast_tammuz_and_av(): 60 | expected_1 = { 61 | 'settings': { 62 | 'date': date.fromisoformat('2019-01-15'), 63 | 'coordinates': (32.09, 34.86), 64 | 'elevation': 0, 65 | 'fast_name': 'fast_17_tammuz' 66 | }, 67 | 'moved_fast': True, 68 | 'fast_start': dt.fromisoformat('2019-07-21T04:23:50.558258+03:00'), 69 | 'havdala_42_min': dt.fromisoformat('2019-07-21T20:27:20.849848+03:00'), 70 | 'havdala_5_95_dgr': dt.fromisoformat('2019-07-21T20:12:23.808687+03:00'), 71 | 'havdala_8_5_dgr': dt.fromisoformat('2019-07-21T20:26:14.766497+03:00') 72 | } 73 | expected_2 = { 74 | 'settings': { 75 | 'date': date.fromisoformat('2019-01-15'), 76 | 'coordinates': (32.09, 34.86), 77 | 'elevation': 0, 78 | 'fast_name': 'fast_9_av' 79 | }, 80 | 'moved_fast': True, 81 | 'fast_start': dt.fromisoformat('2019-08-10T19:30:10.266510+03:00'), 82 | 'chatzot': dt.fromisoformat('2019-08-11T12:45:36.210526+03:00'), 83 | 'havdala_42_min': dt.fromisoformat('2019-08-11T20:11:11.913263+03:00'), 84 | 'havdala_5_95_dgr': dt.fromisoformat('2019-08-11T19:54:56.938923+03:00'), 85 | 'havdala_8_5_dgr': dt.fromisoformat('2019-08-11T20:08:01.465638+03:00') 86 | } 87 | 88 | actual_1 = fast( 89 | FastsChoices.fast_17_tammuz.value, 90 | date(2019, 1, 15), 91 | LAT, 92 | LNG, 93 | ZERO_ELEVATION 94 | ) 95 | actual_2 = fast( 96 | FastsChoices.fast_9_av.value, 97 | date(2019, 1, 15), 98 | LAT, 99 | LNG, 100 | ZERO_ELEVATION, 101 | ) 102 | 103 | assert actual_1.model_dump(exclude_none=True, by_alias=True) == expected_1 104 | assert actual_2.model_dump(exclude_none=True, by_alias=True) == expected_2 105 | 106 | 107 | def test_day_after_moved_fast_tammuz_and_av(): 108 | expected_1 = { 109 | 'settings': { 110 | 'date': date.fromisoformat('2022-07-17'), 111 | 'coordinates': (32.09, 34.86), 112 | 'elevation': 0, 113 | 'fast_name': 'fast_17_tammuz' 114 | }, 115 | 'moved_fast': True, 116 | 'fast_start': dt.fromisoformat('2022-07-17T04:20:45.436601+03:00'), 117 | 'havdala_42_min': dt.fromisoformat('2022-07-17T20:29:10.152776+03:00'), 118 | 'havdala_5_95_dgr': dt.fromisoformat('2022-07-17T20:14:25.670857+03:00'), 119 | 'havdala_8_5_dgr': dt.fromisoformat('2022-07-17T20:28:24.129112+03:00') 120 | } 121 | expected_2 = { 122 | 'settings': { 123 | 'date': date.fromisoformat('2022-08-07'), 124 | 'coordinates': (32.09, 34.86), 125 | 'elevation': 0, 126 | 'fast_name': 'fast_9_av' 127 | }, 128 | 'moved_fast': True, 129 | 'fast_start': dt.fromisoformat('2022-08-06T19:33:38.618130+03:00'), 130 | 'chatzot': dt.fromisoformat('2022-08-07T12:46:08.569260+03:00'), 131 | 'havdala_42_min': dt.fromisoformat('2022-08-07T20:14:44.393678+03:00'), 132 | 'havdala_5_95_dgr': dt.fromisoformat('2022-08-07T19:58:43.183910+03:00'), 133 | 'havdala_8_5_dgr': dt.fromisoformat('2022-08-07T20:11:55.916590+03:00') 134 | } 135 | actual_1 = fast( 136 | FastsChoices.fast_17_tammuz.value, 137 | date(2022, 7, 17), 138 | LAT, 139 | LNG, 140 | ZERO_ELEVATION 141 | ) 142 | actual_2 = fast( 143 | FastsChoices.fast_9_av.value, 144 | date(2022, 8, 7), 145 | LAT, 146 | LNG, 147 | ZERO_ELEVATION, 148 | ) 149 | 150 | assert actual_1.model_dump(exclude_none=True, by_alias=True) == expected_1 151 | assert actual_2.model_dump(exclude_none=True, by_alias=True) == expected_2 152 | 153 | 154 | def test_9_of_av_in_north(): 155 | expected = { 156 | 'settings': { 157 | 'date': date.fromisoformat('2021-07-24'), 158 | 'coordinates': (63.44563381372263, 13.49966869597185), 159 | 'elevation': 0, 160 | 'fast_name': 'fast_17_tammuz' 161 | }, 162 | 'moved_fast': True, 163 | 'fast_start': dt.fromisoformat('2022-07-17T01:11:01.899904+02:00'), 164 | 'havdala_42_min': dt.fromisoformat('2022-07-17T23:29:10.694261+02:00') 165 | } 166 | 167 | actual = fast( 168 | FastsChoices.fast_17_tammuz.value, 169 | date(2021, 7, 24), 170 | 63.44563381372263, 171 | 13.49966869597185, 172 | ZERO_ELEVATION, 173 | ).model_dump(exclude_none=True, by_alias=True) 174 | assert actual == expected 175 | -------------------------------------------------------------------------------- /test/test_engine/test_shabbat.py: -------------------------------------------------------------------------------- 1 | from datetime import date, datetime as dt 2 | 3 | from zmanim_api.engine.shabbat import get_shabbat 4 | from zmanim_api.api_helpers import HavdalaChoices 5 | from ..consts import LAT, LNG, ZERO_ELEVATION, CL_OFFSET, PY_DATE 6 | 7 | 8 | def test_regular_shabbat(): 9 | expected = { 10 | 'candle_lighting': dt.fromisoformat('2020-04-17T18:53:00+03:00'), 11 | 'havdala': dt.fromisoformat('2020-04-18T19:49:00+03:00'), 12 | 'settings': { 13 | 'date': date.fromisoformat('2020-04-15'), 14 | 'cl_offset': 18, 15 | 'havdala_opinion': 'tzeis_8_5_degrees', 16 | 'coordinates': (32.09, 34.86), 17 | 'elevation': 0 18 | }, 19 | 'torah_part': 'shemini', 20 | 'late_cl_warning': False 21 | } 22 | 23 | resp = get_shabbat(LAT, LNG, ZERO_ELEVATION, CL_OFFSET, HavdalaChoices.tzeis_8_5_degrees, PY_DATE) 24 | assert resp.model_dump(exclude_none=True, by_alias=True) == expected 25 | 26 | 27 | def test_shabbat_with_late_cl_warning(): 28 | expected = { 29 | 'candle_lighting': dt.fromisoformat('2020-06-19T20:57:00+03:00'), 30 | 'havdala': dt.fromisoformat('2020-06-20T22:55:00+03:00'), 31 | 'settings': { 32 | 'date': date.fromisoformat('2020-06-15'), 33 | 'cl_offset': 18, 34 | 'havdala_opinion': 'tzeis_8_5_degrees', 35 | 'coordinates': (55.5, 37.7), 36 | 'elevation': 0 37 | }, 38 | 'torah_part': 'shelach', 39 | 'late_cl_warning': True 40 | } 41 | 42 | resp = get_shabbat(55.5, 37.7, ZERO_ELEVATION, CL_OFFSET, HavdalaChoices.tzeis_8_5_degrees, 43 | date(2020, 6, 15)) 44 | assert resp.model_dump(exclude_none=True, by_alias=True) == expected 45 | 46 | 47 | def test_shabbat_with_tzeit_by_chatzot_layla(): 48 | expected = { 49 | 'candle_lighting': dt.fromisoformat('2021-07-30T22:49:00+02:00'), 50 | 'havdala': dt.fromisoformat('2021-08-01T00:22:00+02:00'), 51 | 'settings': { 52 | 'date': date.fromisoformat('2021-07-24'), 53 | 'cl_offset': 18, 54 | 'havdala_opinion': 'tzeis_8_5_degrees', 55 | 'coordinates': (69.77, 25.01), 56 | 'elevation': 0 57 | }, 58 | 'torah_part': 'eikev', 59 | 'late_cl_warning': True 60 | } 61 | 62 | resp = get_shabbat(69.77, 25.01, ZERO_ELEVATION, CL_OFFSET, HavdalaChoices.tzeis_8_5_degrees, 63 | date(2021, 7, 24)) 64 | assert resp.model_dump(exclude_none=True, by_alias=True) == expected 65 | 66 | 67 | def test_shabbat_with_polar_daynight(): 68 | expected = { 69 | 'settings': { 70 | 'date': date.fromisoformat('2021-07-25'), 71 | 'cl_offset': 18, 72 | 'havdala_opinion': 'tzeis_8_5_degrees', 73 | 'coordinates': (76.60, 103.45), 74 | 'elevation': 0 75 | }, 76 | 'torah_part': 'eikev', 77 | 'late_cl_warning': True 78 | } 79 | 80 | resp = get_shabbat(76.60, 103.45, ZERO_ELEVATION, CL_OFFSET, HavdalaChoices.tzeis_8_5_degrees, 81 | date(2021, 7, 25)) 82 | assert resp.model_dump(exclude_none=True, by_alias=True) == expected 83 | 84 | 85 | def test_shabbat_with_different_parsha(): 86 | expected_1 = { 87 | 'candle_lighting': dt.fromisoformat('2020-06-05T19:26:00+03:00'), 88 | 'havdala': dt.fromisoformat('2020-06-06T20:26:00+03:00'), 89 | 'settings': { 90 | 'date': date.fromisoformat('2020-05-30'), 91 | 'cl_offset': 18, 92 | 'havdala_opinion': 'tzeis_8_5_degrees', 93 | 'coordinates': (32.09, 34.86), 94 | 'elevation': 0 95 | }, 96 | 'torah_part': 'behaalosecha', 97 | 'late_cl_warning': False 98 | } 99 | expected_2 = { 100 | 'candle_lighting': dt.fromisoformat('2020-06-05T19:41:00+03:00'), 101 | 'havdala': dt.fromisoformat('2020-06-06T20:46:00+03:00'), 102 | 'settings': { 103 | 'date': date.fromisoformat('2020-05-30'), 104 | 'cl_offset': 18, 105 | 'havdala_opinion': 'tzeis_8_5_degrees', 106 | 'coordinates': (37.7, 34.86), 107 | 'elevation': 0 108 | }, 109 | 'torah_part': 'naso', 110 | 'late_cl_warning': False 111 | } 112 | 113 | resp_1 = get_shabbat(LAT, LNG, ZERO_ELEVATION, CL_OFFSET, HavdalaChoices.tzeis_8_5_degrees, date.fromisoformat('2020-05-30')) 114 | resp_2 = get_shabbat(37.7, LNG, ZERO_ELEVATION, CL_OFFSET, HavdalaChoices.tzeis_8_5_degrees, date.fromisoformat('2020-05-30')) 115 | 116 | assert resp_1.model_dump(exclude_none=True, by_alias=True) == expected_1 117 | assert resp_2.model_dump(exclude_none=True, by_alias=True) == expected_2 118 | 119 | 120 | def test_shabbat_with_yomtov(): 121 | expected_1 = { 122 | 'candle_lighting': dt.fromisoformat('2020-05-29T19:22:00+03:00'), 123 | 'havdala': dt.fromisoformat('2020-05-30T20:22:00+03:00'), 124 | 'settings': { 125 | 'date': date.fromisoformat('2020-05-29'), 126 | 'cl_offset': 18, 127 | 'havdala_opinion': 'tzeis_8_5_degrees', 128 | 'coordinates': (32.09, 34.86), 129 | 'elevation': 0 130 | }, 131 | 'torah_part': 'naso', 132 | 'late_cl_warning': False 133 | } 134 | expected_2 = { 135 | 'candle_lighting': dt.fromisoformat('2020-05-29T19:36:00+03:00'), 136 | 'havdala': dt.fromisoformat('2020-05-30T20:41:00+03:00'), 137 | 'settings': { 138 | 'date': date.fromisoformat('2020-05-29'), 139 | 'cl_offset': 18, 140 | 'havdala_opinion': 'tzeis_8_5_degrees', 141 | 'coordinates': (37.7, 34.86), 142 | 'elevation': 0 143 | }, 144 | 'torah_part': 'shavuos', 145 | 'late_cl_warning': False 146 | } 147 | expected_3 = { 148 | 'candle_lighting': dt.fromisoformat('2020-04-10T18:53:00+03:00'), 149 | 'havdala': dt.fromisoformat('2020-04-11T19:52:00+03:00'), 150 | 'settings': { 151 | 'date': date.fromisoformat('2020-04-10'), 152 | 'cl_offset': 18, 153 | 'havdala_opinion': 'tzeis_8_5_degrees', 154 | 'coordinates': (37.7, 34.86), 155 | 'elevation': 0 156 | }, 157 | 'torah_part': 'chol_hamoed_pesach', 158 | 'late_cl_warning': False 159 | } 160 | 161 | resp_1 = get_shabbat(LAT, LNG, ZERO_ELEVATION, CL_OFFSET, HavdalaChoices.tzeis_8_5_degrees, date.fromisoformat('2020-05-29')) 162 | resp_2 = get_shabbat(37.7, LNG, ZERO_ELEVATION, CL_OFFSET, HavdalaChoices.tzeis_8_5_degrees, date.fromisoformat('2020-05-29')) 163 | resp_3 = get_shabbat(37.7, LNG, ZERO_ELEVATION, CL_OFFSET, HavdalaChoices.tzeis_8_5_degrees, date.fromisoformat('2020-04-10')) 164 | 165 | assert resp_1.model_dump(exclude_none=True, by_alias=True) == expected_1 166 | assert resp_2.model_dump(exclude_none=True, by_alias=True) == expected_2 167 | assert resp_3.model_dump(exclude_none=True, by_alias=True) == expected_3 168 | -------------------------------------------------------------------------------- /test/test_routers/test_main_router.py: -------------------------------------------------------------------------------- 1 | from fastapi.testclient import TestClient 2 | 3 | from zmanim_api.main import app 4 | from ..consts import GEO_DATE_PARAMS, ASUR_BEMELACHA_PARAMS, DATE, HAVDALA 5 | 6 | 7 | client = TestClient(app) 8 | 9 | 10 | def test_zmanim_endpoint(): 11 | params = GEO_DATE_PARAMS 12 | json = { 13 | 'sunrise': True, 14 | 'alos': True, 15 | 'sof_zman_tefila_gra': True, 16 | 'sof_zman_tefila_ma': True, 17 | 'misheyakir_10_2': True, 18 | 'sof_zman_shema_gra': True, 19 | 'sof_zman_shema_ma': True, 20 | 'chatzos': True, 21 | 'mincha_ketana': True, 22 | 'mincha_gedola': True, 23 | 'plag_mincha': True, 24 | 'sunset': True, 25 | 'tzeis_8_5_degrees': True, 26 | 'tzeis_72_minutes': True, 27 | 'tzeis_42_minutes': True, 28 | 'tzeis_5_95_degrees': True, 29 | 'chatzot_laila': True, 30 | 'astronomical_hour_ma': True, 31 | 'astronomical_hour_gra': True 32 | } 33 | json_for_empty_result = {k: False for k, _ in json.items()} 34 | 35 | expected = { 36 | 'settings': { 37 | 'date': '2020-04-15', 38 | 'jewish_date': '5780-1-21', 39 | 'coordinates': [ 40 | 32.09, 41 | 34.86 42 | ], 43 | 'elevation': 0 44 | }, 45 | 'sunrise': '2020-04-15T06:11:24.317714+03:00', 46 | 'alos': '2020-04-15T04:55:46.643596+03:00', 47 | 'sof_zman_tefila_gra': '2020-04-15T10:30:58.115338+03:00', 48 | 'sof_zman_tefila_ma': '2020-04-15T10:06:58.115338+03:00', 49 | 'misheyakir_10_2': '2020-04-15T05:25:33.360431+03:00', 50 | 'sof_zman_shema_gra': '2020-04-15T09:26:04.665932+03:00', 51 | 'mincha_ketana': '2020-04-15T16:27:52.087071+03:00', 52 | 'sof_zman_shema_ma': '2020-04-15T08:50:04.665932+03:00', 53 | 'chatzos': '2020-04-15T12:40:45.014150+03:00', 54 | 'mincha_gedola': '2020-04-15T13:13:11.738853+03:00', 55 | 'plag_mincha': '2020-04-15T17:48:58.898828+03:00', 56 | 'sunset': '2020-04-15T19:10:05.710586+03:00', 57 | 'tzeis_8_5_degrees': '2020-04-15T19:47:36.366258+03:00', 58 | 'tzeis_72_minutes': '2020-04-15T20:22:05.710586+03:00', 59 | 'tzeis_42_minutes': '2020-04-15T19:52:05.710586+03:00', 60 | 'tzeis_5_95_degrees': '2020-04-15T19:35:01.557256+03:00', 61 | 'astronomical_hour_ma': '01:16:53', 62 | 'astronomical_hour_gra': '01:04:53', 63 | 'chatzot_laila': '2020-04-16T00:40:45.014150+03:00' 64 | } 65 | expected_empty = {'settings': expected['settings']} 66 | 67 | resp = client.post('/zmanim', params=params, json=json) 68 | empty_resp = client.post('/zmanim', params=params, json=json_for_empty_result) 69 | 70 | assert resp.status_code == 200 71 | assert resp.json() == expected 72 | assert empty_resp.json() == expected_empty 73 | 74 | 75 | def test_shabbat_endpoint(): 76 | params = {**GEO_DATE_PARAMS, **ASUR_BEMELACHA_PARAMS} 77 | expected = { 78 | 'candle_lighting': '2020-04-17T18:53:00+03:00', 79 | 'havdala': '2020-04-18T19:49:00+03:00', 80 | 'settings': { 81 | 'date': '2020-04-15', 82 | 'cl_offset': 18, 83 | 'havdala_opinion': 'tzeis_8_5_degrees', 84 | 'coordinates': [ 85 | 32.09, 86 | 34.86 87 | ], 88 | 'elevation': 0 89 | }, 90 | 'torah_part': 'shemini', 91 | 'late_cl_warning': False 92 | } 93 | 94 | resp = client.get('/shabbat', params=params) 95 | assert resp.json() == expected 96 | 97 | 98 | def test_rosh_chodesh_endpoint(): 99 | params = {'date': DATE} 100 | expected = { 101 | 'settings': {'date': '2020-04-15'}, 102 | 'month_name': 'iyar', 103 | 'days': [ 104 | '2020-04-24', 105 | '2020-04-25' 106 | ], 107 | 'duration': 2, 108 | 'molad': ['2020-04-22T22:58', 12] 109 | } 110 | 111 | resp = client.get('/rosh_chodesh', params=params) 112 | assert resp.json() == expected 113 | 114 | 115 | def test_daf_yomi_endpoint(): 116 | params = {'date': GEO_DATE_PARAMS['date']} 117 | expected = { 118 | 'settings': { 119 | 'date': '2020-04-15' 120 | }, 121 | 'masehet': "shabbos", 122 | 'daf': 40 123 | } 124 | 125 | resp = client.get('/daf_yomi', params=params) 126 | assert resp.json() == expected 127 | 128 | 129 | def test_holiday_endpoint(): 130 | params = { 131 | 'holiday_name': 'purim', 132 | 'date': DATE 133 | } 134 | expected = { 135 | "settings": { 136 | "date": "2020-04-15", 137 | "holiday_name": "purim" 138 | }, 139 | "date": "2021-02-26" 140 | } 141 | 142 | resp = client.get('/holiday', params=params) 143 | assert resp.json() == expected 144 | 145 | 146 | def test_yomtov_endpoint(): 147 | params = { 148 | **GEO_DATE_PARAMS, 149 | **ASUR_BEMELACHA_PARAMS, 150 | 'yomtov_name': 'rosh_hashana' 151 | } 152 | expected = { 153 | 'settings': { 154 | 'date': '2020-04-15', 155 | 'cl_offset': 18, 156 | 'havdala_opinion': 'tzeis_8_5_degrees', 157 | 'coordinates': [ 158 | 32.09, 159 | 34.86 160 | ], 161 | 'elevation': 0, 162 | 'yomtov_name': 'rosh_hashana' 163 | }, 164 | 'day_1': { 165 | 'date': '2020-09-19', 166 | 'candle_lighting': '2020-09-18T18:24:14.730847+03:00' 167 | }, 168 | 'day_2': { 169 | 'date': '2020-09-20', 170 | 'candle_lighting': '2020-09-19T19:17:11.477017+03:00', 171 | 'havdala': '2020-09-20T19:15:50.475811+03:00' 172 | } 173 | } 174 | 175 | resp = client.get('/yom_tov', params=params) 176 | assert resp.json() == expected 177 | 178 | 179 | def test_fast_endpoint(): 180 | params = { 181 | **GEO_DATE_PARAMS, 182 | 'fast_name': 'fast_gedalia' 183 | } 184 | expected = { 185 | 'settings': { 186 | 'date': '2020-04-15', 187 | 'coordinates': [ 188 | 32.09, 189 | 34.86 190 | ], 191 | 'elevation': 0, 192 | 'fast_name': 'fast_gedalia' 193 | }, 194 | 'moved_fast': False, 195 | 'fast_start': '2020-09-21T05:15:41.082623+03:00', 196 | 'havdala_42_min': '2020-09-21T19:20:15.474227+03:00', 197 | 'havdala_5_95_dgr': '2020-09-21T19:02:25.211412+03:00', 198 | 'havdala_8_5_dgr': '2020-09-21T19:14:29.657488+03:00' 199 | } 200 | 201 | resp = client.get('/fast', params=params) 202 | assert resp.json() == expected 203 | 204 | 205 | def test_asur_bemelacha_endpoint(): 206 | params_1 = { 207 | 'lat': GEO_DATE_PARAMS['lat'], 208 | 'lng': GEO_DATE_PARAMS['lng'], 209 | 'elevation': GEO_DATE_PARAMS['elevation'], 210 | 'dt': '2020-09-27T12:00' 211 | } 212 | params_2 = { 213 | 'lat': GEO_DATE_PARAMS['lat'], 214 | 'lng': GEO_DATE_PARAMS['lng'], 215 | 'elevation': GEO_DATE_PARAMS['elevation'], 216 | 'dt': '2020-09-26T12:00' 217 | } 218 | expected_1 = {'result': False} 219 | expected_2 = {'result': True} 220 | 221 | actual_1 = client.get('/is_asur_bemelacha', params=params_1) 222 | actual_2 = client.get('/is_asur_bemelacha', params=params_2) 223 | assert actual_1.json() == expected_1 224 | assert actual_2.json() == expected_2 225 | -------------------------------------------------------------------------------- /zmanim_api/engine/holidays.py: -------------------------------------------------------------------------------- 1 | from datetime import date, timedelta 2 | 3 | from zmanim.util.geo_location import GeoLocation 4 | from zmanim.zmanim_calendar import ZmanimCalendar 5 | from zmanim.hebrew_calendar.jewish_calendar import JewishCalendar 6 | 7 | from ..utils import get_tz, is_diaspora 8 | from ..api_helpers import HAVDALA_PARAMS, HavdalaChoices 9 | from ..models import Holiday, YomTov, Fast, SimpleSettings, Settings 10 | 11 | 12 | HOLYDAYS_AND_FASTS_DATES = { 13 | 'rosh_hashana': (1, 7), 14 | 'yom_kippur': (10, 7), 15 | 'succot': (15, 7), 16 | 'shmini_atzeres': (22, 7), 17 | 'chanukah': (25, 9), 18 | 'tu_bi_shvat': (15, 11), 19 | 'purim': (14, 12), 20 | 'pesach': (15, 1), 21 | 'pesach_2': (21, 1), 22 | 'yom_hashoah': (27, 1), 23 | 'yom_hazikaron': (4, 2), 24 | 'yom_haatzmaut': (5, 2), 25 | 'lag_baomer': (18, 2), 26 | 'yom_yerushalaim': (28, 2), 27 | 'shavuot': (6, 3), 28 | 'tu_be_av': (15, 5), 29 | 'fast_gedalia': (3, 7), 30 | 'fast_10_teves': (10, 10), 31 | 'fast_esther': (13, 12), 32 | 'fast_17_tammuz': (17, 4), 33 | 'fast_9_av': (9, 5) 34 | } 35 | 36 | NON_YOM_TOV_HOLYDAYS = ( 37 | 'chanukah', 38 | 'tu_bi_shvat', 39 | 'purim', 40 | 'lag_baomer', 41 | 'tu_be_av', 42 | 'yom_hashoah', 43 | 'yom_hazikaron', 44 | 'yom_haatzmaut', 45 | 'yom_yerushalaim' 46 | ) 47 | 48 | LONG_HOLYDAYS = { 49 | # {name: (length in diaspora, length in israel)} 50 | 'rosh_hashana': (2, 2), 51 | 'succot': (7, 6), 52 | 'shmini_atzeres': (2, 1), 53 | 'chanukah': (8, 8), 54 | 'pesach': (8, 7), 55 | # 'pesach_2': (2, 1), 56 | 'shavuot': (2, 1) 57 | } 58 | 59 | MOOVABLE_DAYS = { 60 | 'fast_17_tammuz', 61 | 'fast_9_av', 62 | 'fast_gedalia' 63 | } 64 | 65 | 66 | def _get_first_day_date(name: str, date_: date, diaspora: bool = True) -> JewishCalendar: 67 | day, month = HOLYDAYS_AND_FASTS_DATES[name] 68 | 69 | now = JewishCalendar(date_) 70 | 71 | if now.is_jewish_leap_year() and month == 12: 72 | month = 13 73 | 74 | first_day_date = JewishCalendar.from_jewish_date(now.jewish_year, month, day) 75 | 76 | if first_day_date < now: 77 | # in case of long holyday to protect from return next year holiday during current one 78 | # mooving backward to length of the holiday 79 | if name in LONG_HOLYDAYS: 80 | duration = LONG_HOLYDAYS[name][0] if diaspora else LONG_HOLYDAYS[name][1] 81 | if now.back(duration) < first_day_date: 82 | return _get_first_day_date(name, date_ - timedelta(days=duration), diaspora) 83 | 84 | first_day_date = JewishCalendar.from_jewish_date(first_day_date.jewish_year + 1, month, day) 85 | 86 | if month == 12 and first_day_date.is_jewish_leap_year(): 87 | first_day_date.forward(30) 88 | 89 | # if yom hashoa felt on Friday, moove it to Thursday 90 | if name == 'yom_hashoah' and first_day_date.day_of_week == 6: 91 | first_day_date.forward(-1) 92 | 93 | # if yom hashoa felt on Sunday, moove it to Monday 94 | if name == 'yom_hashoah' and first_day_date.day_of_week == 1: 95 | first_day_date.forward(1) 96 | 97 | # if yom hazikarom felt on thursday and yom haatzmaut on friday, 98 | # moove them one day to past 99 | if (name == 'yom_hazikaron' and first_day_date.day_of_week == 5) or \ 100 | (name == 'yom_haatzmaut' and first_day_date.day_of_week == 6): 101 | first_day_date.forward(-1) 102 | 103 | # if yom hazikarom felt on friday and yom haatzmaut on shabbat, 104 | # moove them two days to past 105 | if (name == 'yom_hazikaron' and first_day_date.day_of_week == 6) or \ 106 | (name == 'yom_haatzmaut' and first_day_date.day_of_week == 7): 107 | first_day_date.forward(-2) 108 | 109 | # if yom hazikarom felt on sunday and yom haatzmaut on monday, 110 | # moove them one day to future 111 | if (name == 'yom_hazikaron' and first_day_date.day_of_week == 1) or \ 112 | (name == 'yom_haatzmaut' and first_day_date.day_of_week == 2): 113 | first_day_date.forward(1) 114 | 115 | return first_day_date 116 | 117 | 118 | def fast( 119 | name: str, 120 | date_: date, 121 | lat: float | None, 122 | lng: float | None, 123 | elevation: int, 124 | ) -> Fast: 125 | tz = get_tz(lat, lng) 126 | diaspora = is_diaspora(tz) 127 | is_9_av = True if name == 'fast_9_av' else None 128 | 129 | data = {'moved_fast': False} 130 | 131 | fast_date = _get_first_day_date(name, date_, diaspora) 132 | if name in MOOVABLE_DAYS: 133 | if fast_date.gregorian_date.weekday() == 5: 134 | # Deferred fast in the future 135 | fast_date.forward(1) 136 | data['moved_fast'] = True 137 | elif date_.year != fast_date.gregorian_year: 138 | # Probably today is deferred fast 139 | previous_day = _get_first_day_date(name, date_ - timedelta(days=1), diaspora) 140 | if date_.year == previous_day.gregorian_year and previous_day.gregorian_date.weekday() == 5: 141 | fast_date = previous_day 142 | 143 | # Deferred fasts 144 | if name in ('fast_gedalia', 'fast_17_tammuz', 'fast_9_av') and fast_date.day_of_week == 7: 145 | fast_date.forward(1) 146 | data['moved_fast'] = True 147 | if name == 'fast_esther' and fast_date.day_of_week == 7: 148 | fast_date.forward(-2) 149 | data['moved_fast'] = True 150 | 151 | location = GeoLocation('', lat, lng, tz, elevation) 152 | fast_calc = ZmanimCalendar(geo_location=location, date=fast_date.gregorian_date) 153 | if is_9_av: 154 | eve_calc = ZmanimCalendar(geo_location=location, date=(fast_date - 1).gregorian_date) 155 | data['fast_start'] = eve_calc.shkia() 156 | data['chatzot'] = fast_calc.chatzos() 157 | else: 158 | if fast_calc.alos(): 159 | data['fast_start'] = fast_calc.alos() 160 | else: 161 | eve_calc = ZmanimCalendar(geo_location=location, date=(fast_date - 1).gregorian_date) 162 | data['fast_start'] = eve_calc.chatzos() + timedelta(hours=12) 163 | 164 | # calculate additional fast ending times: 165 | # sunset = fast_calc.shkia() 166 | # sba_time = (sunset + timedelta(minutes=31)) 167 | # nvr_time = (sunset + timedelta(minutes=28)) 168 | # ssk_time = (sunset + timedelta(minutes=25)) 169 | 170 | data['havdala_8_5_dgr'] = fast_calc.tzais({'degrees': 8.5}) 171 | data['havdala_5_95_dgr'] = fast_calc.tzais({'degrees': 5.95}) 172 | data['havdala_42_min'] = fast_calc.sunset() + timedelta(minutes=42) 173 | 174 | settings = Settings( 175 | coordinates=(lat, lng), 176 | elevation=elevation, 177 | date=date_, 178 | fast_name=name 179 | ) 180 | 181 | return Fast(settings=settings, **data) 182 | 183 | 184 | def get_simple_holiday(name: str, date_: date) -> Holiday: 185 | holiday_date = _get_first_day_date(name, date_).gregorian_date 186 | data = {'holiday': name, 'date': holiday_date} 187 | 188 | settings = SimpleSettings(date=date_, holiday_name=name) 189 | return Holiday(settings=settings, **data) 190 | 191 | 192 | def get_yom_tov( 193 | name: str, 194 | date_: date, 195 | lat: float, 196 | lng: float, 197 | elevation: int, 198 | cl: int, 199 | havdala_opinion: HavdalaChoices 200 | ) -> YomTov: 201 | """ 202 | There are different holiday dates sets: 203 | [Y] - one yom tov — Generic yom tov in Israel 204 | [Y Y] - two yom tovs — Generic yom tov in diaspora 205 | [Y S] - one yom tov and shabbat 206 | [S Y Y] 207 | [Y S] 208 | [Y Y S] 209 | """ 210 | tz = get_tz(lat, lng) 211 | diaspora = is_diaspora(tz) 212 | day_1_date = _get_first_day_date(name, date_, diaspora) 213 | 214 | shabbat_date = None 215 | day_2_date = None 216 | 217 | eve_date = day_1_date - 1 # Y 218 | 219 | if (diaspora and not name == 'yom_kippur') or name == 'rosh_hashana': # Y Y 220 | day_2_date = day_1_date + 1 221 | 222 | last_yt_date = day_2_date or day_1_date 223 | 224 | if day_1_date.day_of_week == 1: # S Y Y 225 | shabbat_date = day_1_date - 1 226 | elif last_yt_date.day_of_week == 6: # Y S / Y Y S 227 | shabbat_date = last_yt_date + 1 228 | 229 | # checks 230 | assert eve_date.has_candle_lighting() 231 | assert day_1_date.is_assur_bemelacha() 232 | if day_2_date: 233 | assert day_2_date.is_yom_tov_sheni() 234 | assert day_2_date.is_assur_bemelacha() 235 | 236 | data = {} 237 | shabbat_term = None 238 | 239 | if shabbat_date and shabbat_date < day_1_date: 240 | shabbat_term = 'pre_shabbat' 241 | data[shabbat_term] = {'date': shabbat_date.gregorian_date} 242 | 243 | data['day_1'] = {'date': day_1_date.gregorian_date} 244 | 245 | if day_2_date: 246 | data['day_2'] = {'date': day_2_date.gregorian_date} 247 | 248 | if shabbat_date and shabbat_date > last_yt_date: 249 | shabbat_term = 'post_shabbat' 250 | data[shabbat_term] = {'date': shabbat_date.gregorian_date} 251 | 252 | if name == 'succot': 253 | date_hoshana_rabba = day_1_date + 6 254 | data['hoshana_rabba'] = date_hoshana_rabba.gregorian_date 255 | 256 | # zmanim calculation 257 | havdala_params = HAVDALA_PARAMS[havdala_opinion.name] 258 | 259 | location = GeoLocation('', lat, lng, tz, elevation) 260 | 261 | eve_zmanim_calc = ZmanimCalendar(cl, geo_location=location, date=eve_date.gregorian_date) 262 | first_day_calc = ZmanimCalendar(cl, geo_location=location, date=day_1_date.gregorian_date) 263 | 264 | if shabbat_date: 265 | shabbat_eve_date = shabbat_date - 1 266 | eve_shabbat_calc = ZmanimCalendar(cl, geo_location=location, date=shabbat_eve_date.gregorian_date) 267 | shabbat_calc = ZmanimCalendar(cl, geo_location=location, date=shabbat_date.gregorian_date) 268 | data[shabbat_term]['candle_lighting'] = eve_shabbat_calc.candle_lighting() 269 | 270 | if shabbat_date > day_1_date: 271 | data[shabbat_term]['havdala'] = shabbat_calc.tzais(havdala_params) 272 | 273 | if shabbat_term == 'pre_shabbat': 274 | data['day_1']['candle_lighting'] = eve_zmanim_calc.tzais(havdala_params) 275 | else: 276 | data['day_1']['candle_lighting'] = eve_zmanim_calc.candle_lighting() 277 | 278 | if not day_2_date: 279 | if not shabbat_term or shabbat_term == 'pre_shabbat': 280 | data['day_1']['havdala'] = first_day_calc.tzais(havdala_params) 281 | 282 | else: 283 | second_day_calc = ZmanimCalendar(cl, geo_location=location, date=day_2_date.gregorian_date) 284 | if day_1_date.gregorian_date.weekday() == 4: 285 | data['day_2']['candle_lighting'] = first_day_calc.candle_lighting() 286 | else: 287 | data['day_2']['candle_lighting'] = first_day_calc.tzais(havdala_params) 288 | # data['day_2']['candle_lighting'] = smart_candle_lighting(day_2_date, second_day_calc) 289 | if not shabbat_date or shabbat_date < day_2_date: 290 | data['day_2']['havdala'] = second_day_calc.tzais(havdala_params) 291 | 292 | part_2_data = {} 293 | if name == 'pesach': 294 | part_2 = get_yom_tov('pesach_2', date_, lat, lng, elevation, cl, havdala_opinion) 295 | part_2_data = { 296 | 'pesach_part_2_day_1': part_2.day_1, 297 | 'pesach_part_2_day_2': part_2.day_2, 298 | 'pesach_part_2_post_shabat': part_2.pesach_part_2_post_shabat 299 | } 300 | 301 | data['pesach_eating_chanetz_till'] = eve_zmanim_calc._shaos_into_day( 302 | eve_zmanim_calc.elevation_adjusted_sunrise(), 303 | eve_zmanim_calc.elevation_adjusted_sunset(), 304 | 4 305 | ) 306 | data['pesach_burning_chanetz_till'] = eve_zmanim_calc._shaos_into_day( 307 | eve_zmanim_calc.elevation_adjusted_sunrise(), 308 | eve_zmanim_calc.elevation_adjusted_sunset(), 309 | 5 310 | ) 311 | 312 | if name == 'pesach_2' and shabbat_term in data: 313 | data['pesach_part_2_post_shabat'] = data.pop(shabbat_term) 314 | 315 | settings = Settings( 316 | cl_offset=cl, 317 | havdala_opinion=havdala_opinion, 318 | coordinates=(lat, lng), 319 | elevation=elevation, 320 | date=date_, 321 | yomtov_name=name 322 | ) 323 | return YomTov(settings=settings, **data, **part_2_data) 324 | -------------------------------------------------------------------------------- /test/test_engine/test_yomtov.py: -------------------------------------------------------------------------------- 1 | from datetime import date, datetime as dt 2 | 3 | from zmanim_api.engine.holidays import get_yom_tov 4 | from zmanim_api.api_helpers import YomTovChoices, HavdalaChoices 5 | from ..consts import LAT, LNG, ZERO_ELEVATION 6 | 7 | 8 | def test_regular_yomtov_in_istael(): 9 | expected = { 10 | 'settings': { 11 | 'date': date.fromisoformat('2021-04-15'), 12 | 'cl_offset': 18, 13 | 'havdala_opinion': 'tzeis_8_5_degrees', 14 | 'coordinates': (32.09, 34.86), 15 | 'elevation': 0, 16 | 'yomtov_name': 'shavuot' 17 | }, 18 | 'day_1': { 19 | 'date': date.fromisoformat('2021-05-17'), 20 | 'candle_lighting': dt.fromisoformat('2021-05-16T19:13:51.154895+03:00'), 21 | 'havdala': dt.fromisoformat('2021-05-17T20:13:02.790384+03:00') 22 | } 23 | } 24 | 25 | actual = get_yom_tov( 26 | YomTovChoices.shavuot.value, 27 | date(2021, 4, 15), 28 | LAT, 29 | LNG, 30 | ZERO_ELEVATION, 31 | 18, 32 | HavdalaChoices.tzeis_8_5_degrees 33 | ) 34 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 35 | 36 | 37 | def test_regular_yomtov_in_diaspora(): 38 | expected = { 39 | 'settings': { 40 | 'date': date.fromisoformat('2021-04-15'), 41 | 'cl_offset': 18, 42 | 'havdala_opinion': 'tzeis_8_5_degrees', 43 | 'coordinates': (55.5, 37.7), 44 | 'elevation': 0, 45 | 'yomtov_name': 'shavuot' 46 | }, 47 | 'day_1': { 48 | 'date': date.fromisoformat('2021-05-17'), 49 | 'candle_lighting': dt.fromisoformat('2021-05-16T20:17:11.838274+03:00') 50 | }, 51 | 'day_2': { 52 | 'date': date.fromisoformat('2021-05-18'), 53 | 'candle_lighting': dt.fromisoformat('2021-05-17T21:55:12.282469+03:00'), 54 | 'havdala': dt.fromisoformat('2021-05-18T21:57:45.263860+03:00') 55 | } 56 | } 57 | 58 | actual = get_yom_tov( 59 | YomTovChoices.shavuot.value, 60 | date(2021, 4, 15), 61 | 55.5, 62 | 37.7, 63 | ZERO_ELEVATION, 64 | 18, 65 | HavdalaChoices.tzeis_8_5_degrees 66 | ) 67 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 68 | 69 | 70 | def test_past_yomtov(): 71 | expected = { 72 | 'settings': { 73 | 'date': date.fromisoformat('2019-04-01'), 74 | 'cl_offset': 18, 75 | 'havdala_opinion': 'tzeis_8_5_degrees', 76 | 'coordinates': (32.09, 34.86), 77 | 'elevation': 0, 78 | 'yomtov_name': 'succot' 79 | }, 80 | 'day_1': { 81 | 'date': date.fromisoformat('2019-10-14'), 82 | 'candle_lighting': dt.fromisoformat('2019-10-13T17:53:03.590573+03:00'), 83 | 'havdala': dt.fromisoformat('2019-10-14T18:46:18.069214+03:00') 84 | }, 85 | 'hoshana_rabba': date.fromisoformat('2019-10-20') 86 | } 87 | 88 | actual = get_yom_tov( 89 | YomTovChoices.succot.value, 90 | date(2019, 4, 1), 91 | LAT, 92 | LNG, 93 | ZERO_ELEVATION, 94 | 18, 95 | HavdalaChoices.tzeis_8_5_degrees 96 | ) 97 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 98 | 99 | 100 | def test_rosh_hashana_in_diaspora(): 101 | expected = { 102 | 'settings': { 103 | 'date': date.fromisoformat('2021-04-15'), 104 | 'cl_offset': 18, 105 | 'havdala_opinion': 'tzeis_8_5_degrees', 106 | 'coordinates': (55.5, 37.7), 107 | 'elevation': 0, 108 | 'yomtov_name': 'rosh_hashana' 109 | }, 110 | 'day_1': { 111 | 'date': date.fromisoformat('2021-09-07'), 112 | 'candle_lighting': dt.fromisoformat('2021-09-06T18:51:44.012224+03:00') 113 | }, 114 | 'day_2': { 115 | 'date': date.fromisoformat('2021-09-08'), 116 | 'candle_lighting': dt.fromisoformat('2021-09-07T20:03:54.173229+03:00'), 117 | 'havdala': dt.fromisoformat('2021-09-08T20:01:06.268724+03:00') 118 | } 119 | } 120 | 121 | actual = get_yom_tov( 122 | YomTovChoices.rosh_hashana.value, 123 | date(2021, 4, 15), 124 | 55.5, 125 | 37.7, 126 | ZERO_ELEVATION, 127 | 18, 128 | HavdalaChoices.tzeis_8_5_degrees 129 | ) 130 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 131 | 132 | 133 | def test_pre_shabbat_in_israel(): 134 | expected = { 135 | 'settings': { 136 | 'date': date.fromisoformat('2022-04-01'), 137 | 'cl_offset': 18, 138 | 'havdala_opinion': 'tzeis_8_5_degrees', 139 | 'coordinates': (32.09, 34.86), 140 | 'elevation': 0, 141 | 'yomtov_name': 'shavuot' 142 | }, 143 | 'pre_shabbat': { 144 | 'date': date.fromisoformat('2022-06-04'), 145 | 'candle_lighting': dt.fromisoformat('2022-06-03T19:25:00.047838+03:00') 146 | }, 147 | 'day_1': { 148 | 'date': date.fromisoformat('2022-06-05'), 149 | 'candle_lighting': dt.fromisoformat('2022-06-04T20:25:30.621846+03:00'), 150 | 'havdala': dt.fromisoformat('2022-06-05T20:26:05.207323+03:00') 151 | } 152 | } 153 | 154 | actual = get_yom_tov( 155 | YomTovChoices.shavuot.value, 156 | date(2022, 4, 1), 157 | LAT, 158 | LNG, 159 | ZERO_ELEVATION, 160 | 18, 161 | HavdalaChoices.tzeis_8_5_degrees 162 | ) 163 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 164 | 165 | 166 | def test_pre_shabbat_in_diaspora(): 167 | expected = { 168 | 'settings': { 169 | 'date': date.fromisoformat('2022-04-01'), 170 | 'cl_offset': 18, 171 | 'havdala_opinion': 'tzeis_8_5_degrees', 172 | 'coordinates': (55.5, 37.7), 173 | 'elevation': 0, 174 | 'yomtov_name': 'shavuot' 175 | }, 176 | 'pre_shabbat': { 177 | 'date': date.fromisoformat('2022-06-04'), 178 | 'candle_lighting': dt.fromisoformat('2022-06-03T20:44:39.375578+03:00') 179 | }, 180 | 'day_1': { 181 | 'date': date.fromisoformat('2022-06-05'), 182 | 'candle_lighting': dt.fromisoformat('2022-06-04T22:36:39.212694+03:00'), 183 | }, 184 | 'day_2': { 185 | 'date': date.fromisoformat('2022-06-06'), 186 | 'candle_lighting': dt.fromisoformat('2022-06-05T22:38:33.390085+03:00'), 187 | 'havdala': dt.fromisoformat('2022-06-06T22:40:23.180390+03:00') 188 | } 189 | } 190 | 191 | actual = get_yom_tov( 192 | YomTovChoices.shavuot.value, 193 | date(2022, 4, 1), 194 | 55.5, 195 | 37.7, 196 | ZERO_ELEVATION, 197 | 18, 198 | HavdalaChoices.tzeis_8_5_degrees 199 | ) 200 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 201 | 202 | 203 | def test_post_shabbat_in_israel(): 204 | expected = { 205 | 'settings': { 206 | 'date': date.fromisoformat('2020-04-15'), 207 | 'cl_offset': 18, 208 | 'havdala_opinion': 'tzeis_8_5_degrees', 209 | 'coordinates': (32.09, 34.86), 210 | 'elevation': 0, 211 | 'yomtov_name': 'shavuot' 212 | }, 213 | 'day_1': { 214 | 'date': date.fromisoformat('2020-05-29'), 215 | 'candle_lighting': dt.fromisoformat('2020-05-28T19:21:50.464019+03:00') 216 | }, 217 | 'post_shabbat': { 218 | 'date': date.fromisoformat('2020-05-30'), 219 | 'candle_lighting': dt.fromisoformat('2020-05-29T19:22:26.312364+03:00'), 220 | 'havdala': dt.fromisoformat('2020-05-30T20:22:41.756404+03:00') 221 | } 222 | } 223 | 224 | actual = get_yom_tov( 225 | YomTovChoices.shavuot.value, 226 | date(2020, 4, 15), 227 | LAT, 228 | LNG, 229 | ZERO_ELEVATION, 230 | 18, 231 | HavdalaChoices.tzeis_8_5_degrees 232 | ) 233 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 234 | 235 | 236 | def test_post_shabbat_in_diaspora(): 237 | expected = { 238 | 'settings': { 239 | 'date': date.fromisoformat('2020-04-01'), 240 | 'cl_offset': 18, 241 | 'havdala_opinion': 'tzeis_8_5_degrees', 242 | 'coordinates': (55.5, 37.7), 243 | 'elevation': 0, 244 | 'yomtov_name': 'pesach' 245 | }, 246 | 'pesach_burning_chanetz_till': dt.fromisoformat('2020-04-08T11:23:16:659939+03:00'), 247 | 'pesach_eating_chanetz_till': dt.fromisoformat('2020-04-08T10:14:58:519048+03:00'), 248 | 'day_1': { 249 | 'date': date.fromisoformat('2020-04-09'), 250 | 'candle_lighting': dt.fromisoformat('2020-04-08T19:03:23.646179+03:00') 251 | }, 252 | 'day_2': { 253 | 'date': date.fromisoformat('2020-04-10'), 254 | 'candle_lighting': dt.fromisoformat('2020-04-09T20:21:45.269644+03:00') 255 | }, 256 | 'post_shabbat': { 257 | 'date': date.fromisoformat('2020-04-11'), 258 | 'candle_lighting': dt.fromisoformat('2020-04-10T19:07:23.016963+03:00'), 259 | 'havdala': dt.fromisoformat('2020-04-11T20:26:20.026278+03:00') 260 | }, 261 | 'pesach_part_2_day_1': { 262 | 'date': date.fromisoformat('2020-04-15'), 263 | 'candle_lighting': dt.fromisoformat('2020-04-14T19:15:22.104678+03:00') 264 | }, 265 | 'pesach_part_2_day_2': { 266 | 'date': date.fromisoformat('2020-04-16'), 267 | 'candle_lighting': dt.fromisoformat('2020-04-15T20:35:38.135050+03:00'), 268 | 'havdala': dt.fromisoformat('2020-04-16T20:37:59.486154+03:00') 269 | } 270 | } 271 | 272 | actual = get_yom_tov( 273 | YomTovChoices.pesach.value, 274 | date(2020, 4, 1), 275 | 55.5, 276 | 37.7, 277 | ZERO_ELEVATION, 278 | 18, 279 | HavdalaChoices.tzeis_8_5_degrees 280 | ) 281 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 282 | 283 | 284 | def test_second_yt_is_shabbat(): 285 | expected = { 286 | 'settings': { 287 | 'date': date.fromisoformat('2021-07-24'), 288 | 'cl_offset': 18, 289 | 'havdala_opinion': 'tzeis_8_5_degrees', 290 | 'coordinates': (55.63097, 37.628591), 291 | 'elevation': 0, 292 | 'yomtov_name': 'pesach' 293 | }, 294 | 'pesach_burning_chanetz_till': dt.fromisoformat('2022-04-15T11:19:24:184815+03:00'), 295 | 'pesach_eating_chanetz_till': dt.fromisoformat('2022-04-15T10:08:36:127354+03:00'), 296 | 'day_1': { 297 | 'date': date.fromisoformat('2022-04-16'), 298 | 'candle_lighting': dt.fromisoformat('2022-04-15T19:17:00.587041+03:00') 299 | }, 300 | 'day_2': { 301 | 'date': date.fromisoformat('2022-04-17'), 302 | 'candle_lighting': dt.fromisoformat('2022-04-16T20:37:44.000668+03:00'), 303 | 'havdala': dt.fromisoformat('2022-04-17T20:40:06.767369+03:00') 304 | }, 305 | 'pesach_part_2_day_1': { 306 | 'date': date.fromisoformat('2022-04-22'), 307 | 'candle_lighting': dt.fromisoformat('2022-04-21T19:29:03.967858+03:00') 308 | }, 309 | 'pesach_part_2_day_2': { 310 | 'date': date.fromisoformat('2022-04-23'), 311 | 'candle_lighting': dt.fromisoformat('2022-04-22T19:31:04.444159+03:00'), 312 | 'havdala': dt.fromisoformat('2022-04-23T20:54:39.137197+03:00') 313 | } 314 | } 315 | 316 | actual = get_yom_tov( 317 | YomTovChoices.pesach.value, 318 | date(2021, 7, 24), 319 | 55.63097, 320 | 37.628591, 321 | ZERO_ELEVATION, 322 | 18, 323 | HavdalaChoices.tzeis_8_5_degrees 324 | ) 325 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 326 | 327 | 328 | def test_peesach_part_2_post_shabbat_in_istael(): 329 | expected = { 330 | 'settings': { 331 | 'date': date.fromisoformat('2022-04-12'), 332 | 'cl_offset': 18, 333 | 'havdala_opinion': 'tzeis_8_5_degrees', 334 | 'coordinates': (32.08335, 34.883325), 335 | 'elevation': 0, 336 | "yomtov_name": "pesach" 337 | }, 338 | 'pesach_burning_chanetz_till': dt.fromisoformat('2022-04-15T11:35:57:473214+03:00'), 339 | 'pesach_eating_chanetz_till': dt.fromisoformat('2022-04-15T10:31:08:593221+03:00'), 340 | 'day_1': { 341 | "date": date.fromisoformat('2022-04-16'), 342 | "candle_lighting": dt.fromisoformat('2022-04-15T18:51:39.633162+03:00'), 343 | "havdala": dt.fromisoformat('2022-04-16T19:47:54.176159+03:00') 344 | }, 345 | 'pesach_part_2_day_1': { 346 | "date": date.fromisoformat('2022-04-22'), 347 | "candle_lighting": dt.fromisoformat('2022-04-21T18:55:51.226349+03:00') 348 | }, 349 | 'pesach_part_2_post_shabat': { 350 | 'date': date.fromisoformat('2022-04-23'), 351 | 'candle_lighting': dt.fromisoformat('2022-04-22T18:56:33.479101+03:00'), 352 | 'havdala': dt.fromisoformat('2022-04-23T19:53:23.397083+03:00') 353 | } 354 | } 355 | 356 | actual = get_yom_tov( 357 | YomTovChoices.pesach.value, 358 | date(2022, 4, 12), 359 | 32.08335, 360 | 34.883325, 361 | ZERO_ELEVATION, 362 | 18, 363 | HavdalaChoices.tzeis_8_5_degrees 364 | ) 365 | assert actual.model_dump(exclude_none=True, by_alias=True) == expected 366 | -------------------------------------------------------------------------------- /pdm.lock: -------------------------------------------------------------------------------- 1 | # This file is @generated by PDM. 2 | # It is not intended for manual editing. 3 | 4 | [metadata] 5 | groups = ["default", "test"] 6 | cross_platform = true 7 | static_urls = false 8 | lock_version = "4.3" 9 | content_hash = "sha256:9038636a85335305a8c61bdbab116799071b9a0c3f652c8ef060ac33f5bc3753" 10 | 11 | [[package]] 12 | name = "annotated-types" 13 | version = "0.6.0" 14 | requires_python = ">=3.8" 15 | summary = "Reusable constraint types to use with typing.Annotated" 16 | files = [ 17 | {file = "annotated_types-0.6.0-py3-none-any.whl", hash = "sha256:0641064de18ba7a25dee8f96403ebc39113d0cb953a01429249d5c7564666a43"}, 18 | {file = "annotated_types-0.6.0.tar.gz", hash = "sha256:563339e807e53ffd9c267e99fc6d9ea23eb8443c08f112651963e24e22f84a5d"}, 19 | ] 20 | 21 | [[package]] 22 | name = "anyio" 23 | version = "3.7.1" 24 | requires_python = ">=3.7" 25 | summary = "High level compatibility layer for multiple asynchronous event loop implementations" 26 | dependencies = [ 27 | "idna>=2.8", 28 | "sniffio>=1.1", 29 | ] 30 | files = [ 31 | {file = "anyio-3.7.1-py3-none-any.whl", hash = "sha256:91dee416e570e92c64041bd18b900d1d6fa78dff7048769ce5ac5ddad004fbb5"}, 32 | {file = "anyio-3.7.1.tar.gz", hash = "sha256:44a3c9aba0f5defa43261a8b3efb97891f2bd7d804e0e1f56419befa1adfc780"}, 33 | ] 34 | 35 | [[package]] 36 | name = "arrow" 37 | version = "1.2.3" 38 | requires_python = ">=3.6" 39 | summary = "Better dates & times for Python" 40 | dependencies = [ 41 | "python-dateutil>=2.7.0", 42 | ] 43 | files = [ 44 | {file = "arrow-1.2.3-py3-none-any.whl", hash = "sha256:5a49ab92e3b7b71d96cd6bfcc4df14efefc9dfa96ea19045815914a6ab6b1fe2"}, 45 | {file = "arrow-1.2.3.tar.gz", hash = "sha256:3934b30ca1b9f292376d9db15b19446088d12ec58629bc3f0da28fd55fb633a1"}, 46 | ] 47 | 48 | [[package]] 49 | name = "betterlogging" 50 | version = "0.2.1" 51 | summary = "My logging improvement" 52 | files = [ 53 | {file = "betterlogging-0.2.1-py3-none-any.whl", hash = "sha256:fc289ac94bf13b44286438d73edd0563f2259b681364f34eeeaff970fada46dd"}, 54 | {file = "betterlogging-0.2.1.tar.gz", hash = "sha256:e2bc423ba0e06c94dc90f5db06d2d8b656807e33fecd02c43af7175236849d34"}, 55 | ] 56 | 57 | [[package]] 58 | name = "certifi" 59 | version = "2023.7.22" 60 | requires_python = ">=3.6" 61 | summary = "Python package for providing Mozilla's CA Bundle." 62 | files = [ 63 | {file = "certifi-2023.7.22-py3-none-any.whl", hash = "sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9"}, 64 | {file = "certifi-2023.7.22.tar.gz", hash = "sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082"}, 65 | ] 66 | 67 | [[package]] 68 | name = "cffi" 69 | version = "1.16.0" 70 | requires_python = ">=3.8" 71 | summary = "Foreign Function Interface for Python calling C code." 72 | dependencies = [ 73 | "pycparser", 74 | ] 75 | files = [ 76 | {file = "cffi-1.16.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b84834d0cf97e7d27dd5b7f3aca7b6e9263c56308ab9dc8aae9784abb774d404"}, 77 | {file = "cffi-1.16.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1b8ebc27c014c59692bb2664c7d13ce7a6e9a629be20e54e7271fa696ff2b417"}, 78 | {file = "cffi-1.16.0-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ee07e47c12890ef248766a6e55bd38ebfb2bb8edd4142d56db91b21ea68b7627"}, 79 | {file = "cffi-1.16.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d8a9d3ebe49f084ad71f9269834ceccbf398253c9fac910c4fd7053ff1386936"}, 80 | {file = "cffi-1.16.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e70f54f1796669ef691ca07d046cd81a29cb4deb1e5f942003f401c0c4a2695d"}, 81 | {file = "cffi-1.16.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5bf44d66cdf9e893637896c7faa22298baebcd18d1ddb6d2626a6e39793a1d56"}, 82 | {file = "cffi-1.16.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7b78010e7b97fef4bee1e896df8a4bbb6712b7f05b7ef630f9d1da00f6444d2e"}, 83 | {file = "cffi-1.16.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:c6a164aa47843fb1b01e941d385aab7215563bb8816d80ff3a363a9f8448a8dc"}, 84 | {file = "cffi-1.16.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e09f3ff613345df5e8c3667da1d918f9149bd623cd9070c983c013792a9a62eb"}, 85 | {file = "cffi-1.16.0-cp311-cp311-win32.whl", hash = "sha256:2c56b361916f390cd758a57f2e16233eb4f64bcbeee88a4881ea90fca14dc6ab"}, 86 | {file = "cffi-1.16.0-cp311-cp311-win_amd64.whl", hash = "sha256:db8e577c19c0fda0beb7e0d4e09e0ba74b1e4c092e0e40bfa12fe05b6f6d75ba"}, 87 | {file = "cffi-1.16.0.tar.gz", hash = "sha256:bcb3ef43e58665bbda2fb198698fcae6776483e0c4a631aa5647806c25e02cc0"}, 88 | ] 89 | 90 | [[package]] 91 | name = "click" 92 | version = "8.1.7" 93 | requires_python = ">=3.7" 94 | summary = "Composable command line interface toolkit" 95 | dependencies = [ 96 | "colorama; platform_system == \"Windows\"", 97 | ] 98 | files = [ 99 | {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, 100 | {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, 101 | ] 102 | 103 | [[package]] 104 | name = "colorama" 105 | version = "0.4.6" 106 | requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" 107 | summary = "Cross-platform colored terminal text." 108 | files = [ 109 | {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, 110 | {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, 111 | ] 112 | 113 | [[package]] 114 | name = "coverage" 115 | version = "7.2.3" 116 | requires_python = ">=3.7" 117 | summary = "Code coverage measurement for Python" 118 | files = [ 119 | {file = "coverage-7.2.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:dfd393094cd82ceb9b40df4c77976015a314b267d498268a076e940fe7be6b79"}, 120 | {file = "coverage-7.2.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:182eb9ac3f2b4874a1f41b78b87db20b66da6b9cdc32737fbbf4fea0c35b23fc"}, 121 | {file = "coverage-7.2.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1bb1e77a9a311346294621be905ea8a2c30d3ad371fc15bb72e98bfcfae532df"}, 122 | {file = "coverage-7.2.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ca0f34363e2634deffd390a0fef1aa99168ae9ed2af01af4a1f5865e362f8623"}, 123 | {file = "coverage-7.2.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:55416d7385774285b6e2a5feca0af9652f7f444a4fa3d29d8ab052fafef9d00d"}, 124 | {file = "coverage-7.2.3-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:06ddd9c0249a0546997fdda5a30fbcb40f23926df0a874a60a8a185bc3a87d93"}, 125 | {file = "coverage-7.2.3-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:fff5aaa6becf2c6a1699ae6a39e2e6fb0672c2d42eca8eb0cafa91cf2e9bd312"}, 126 | {file = "coverage-7.2.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:ea53151d87c52e98133eb8ac78f1206498c015849662ca8dc246255265d9c3c4"}, 127 | {file = "coverage-7.2.3-cp311-cp311-win32.whl", hash = "sha256:8f6c930fd70d91ddee53194e93029e3ef2aabe26725aa3c2753df057e296b925"}, 128 | {file = "coverage-7.2.3-cp311-cp311-win_amd64.whl", hash = "sha256:fa546d66639d69aa967bf08156eb8c9d0cd6f6de84be9e8c9819f52ad499c910"}, 129 | {file = "coverage-7.2.3-pp37.pp38.pp39-none-any.whl", hash = "sha256:965ee3e782c7892befc25575fa171b521d33798132692df428a09efacaffe8d0"}, 130 | {file = "coverage-7.2.3.tar.gz", hash = "sha256:d298c2815fa4891edd9abe5ad6e6cb4207104c7dd9fd13aea3fdebf6f9b91259"}, 131 | ] 132 | 133 | [[package]] 134 | name = "fastapi" 135 | version = "0.104.0" 136 | requires_python = ">=3.8" 137 | summary = "FastAPI framework, high performance, easy to learn, fast to code, ready for production" 138 | dependencies = [ 139 | "anyio<4.0.0,>=3.7.1", 140 | "pydantic!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,!=2.1.0,<3.0.0,>=1.7.4", 141 | "starlette<0.28.0,>=0.27.0", 142 | "typing-extensions>=4.8.0", 143 | ] 144 | files = [ 145 | {file = "fastapi-0.104.0-py3-none-any.whl", hash = "sha256:456482c1178fb7beb2814b88e1885bc49f9a81f079665016feffe3e1c6a7663e"}, 146 | {file = "fastapi-0.104.0.tar.gz", hash = "sha256:9c44de45693ae037b0c6914727a29c49a40668432b67c859a87851fc6a7b74c6"}, 147 | ] 148 | 149 | [[package]] 150 | name = "h11" 151 | version = "0.14.0" 152 | requires_python = ">=3.7" 153 | summary = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1" 154 | files = [ 155 | {file = "h11-0.14.0-py3-none-any.whl", hash = "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761"}, 156 | {file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, 157 | ] 158 | 159 | [[package]] 160 | name = "h3" 161 | version = "3.7.6" 162 | summary = "Hierarchical hexagonal geospatial indexing system" 163 | files = [ 164 | {file = "h3-3.7.6-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:991ee991f2ae41f629feb1cd32fa677b8512c72696eb0ad94fcf359d61184b2e"}, 165 | {file = "h3-3.7.6-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:fcbfff87d223279f8e38bbee3ebf52b1b96ae280e9e7de24674d3c284373d946"}, 166 | {file = "h3-3.7.6-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:eddf10d1d2139b3ea3ad1618c2074e1c47d3d36bddb5359e4955f5fd0b089d93"}, 167 | {file = "h3-3.7.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:76abc02f14a8df42fb5d80e6045023fb756c49d3cb08d69a8ceb9362b95d4bec"}, 168 | {file = "h3-3.7.6-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:fc8030968586a7810aa192397ad9a4f7d7a963f57c9b3e210fc38de0aa5c2533"}, 169 | {file = "h3-3.7.6-cp311-cp311-win_amd64.whl", hash = "sha256:1bdc790d91138e781973dcaade5231db7fe8a876330939e0903f602acc4fb64c"}, 170 | {file = "h3-3.7.6.tar.gz", hash = "sha256:9bbd3dbac99532fa521d7d2e288ff55877bea3223b070f659ed7b5f8f1f213eb"}, 171 | ] 172 | 173 | [[package]] 174 | name = "httpcore" 175 | version = "0.18.0" 176 | requires_python = ">=3.8" 177 | summary = "A minimal low-level HTTP client." 178 | dependencies = [ 179 | "anyio<5.0,>=3.0", 180 | "certifi", 181 | "h11<0.15,>=0.13", 182 | "sniffio==1.*", 183 | ] 184 | files = [ 185 | {file = "httpcore-0.18.0-py3-none-any.whl", hash = "sha256:adc5398ee0a476567bf87467063ee63584a8bce86078bf748e48754f60202ced"}, 186 | {file = "httpcore-0.18.0.tar.gz", hash = "sha256:13b5e5cd1dca1a6636a6aaea212b19f4f85cd88c366a2b82304181b769aab3c9"}, 187 | ] 188 | 189 | [[package]] 190 | name = "httpx" 191 | version = "0.25.0" 192 | requires_python = ">=3.8" 193 | summary = "The next generation HTTP client." 194 | dependencies = [ 195 | "certifi", 196 | "httpcore<0.19.0,>=0.18.0", 197 | "idna", 198 | "sniffio", 199 | ] 200 | files = [ 201 | {file = "httpx-0.25.0-py3-none-any.whl", hash = "sha256:181ea7f8ba3a82578be86ef4171554dd45fec26a02556a744db029a0a27b7100"}, 202 | {file = "httpx-0.25.0.tar.gz", hash = "sha256:47ecda285389cb32bb2691cc6e069e3ab0205956f681c5b2ad2325719751d875"}, 203 | ] 204 | 205 | [[package]] 206 | name = "idna" 207 | version = "3.4" 208 | requires_python = ">=3.5" 209 | summary = "Internationalized Domain Names in Applications (IDNA)" 210 | files = [ 211 | {file = "idna-3.4-py3-none-any.whl", hash = "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"}, 212 | {file = "idna-3.4.tar.gz", hash = "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"}, 213 | ] 214 | 215 | [[package]] 216 | name = "iniconfig" 217 | version = "2.0.0" 218 | requires_python = ">=3.7" 219 | summary = "brain-dead simple config-ini parsing" 220 | files = [ 221 | {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, 222 | {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, 223 | ] 224 | 225 | [[package]] 226 | name = "julian" 227 | version = "0.14" 228 | summary = "Simple library for converting between Julian calendar dates and datetime objects" 229 | files = [ 230 | {file = "julian-0.14.zip", hash = "sha256:deee4090faad584c1875d97e72808198f802a9d2dc38a70fe2a8f790ea5dbd0a"}, 231 | ] 232 | 233 | [[package]] 234 | name = "memoization" 235 | version = "0.4.0" 236 | requires_python = ">=3, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4" 237 | summary = "A powerful caching library for Python, with TTL support and multiple algorithm options. (https://github.com/lonelyenvoy/python-memoization)" 238 | files = [ 239 | {file = "memoization-0.4.0.tar.gz", hash = "sha256:fde5e7cd060ef45b135e0310cfec17b2029dc472ccb5bbbbb42a503d4538a135"}, 240 | ] 241 | 242 | [[package]] 243 | name = "numpy" 244 | version = "1.26.1" 245 | requires_python = "<3.13,>=3.9" 246 | summary = "Fundamental package for array computing in Python" 247 | files = [ 248 | {file = "numpy-1.26.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cd7837b2b734ca72959a1caf3309457a318c934abef7a43a14bb984e574bbb9a"}, 249 | {file = "numpy-1.26.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1c59c046c31a43310ad0199d6299e59f57a289e22f0f36951ced1c9eac3665b9"}, 250 | {file = "numpy-1.26.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d58e8c51a7cf43090d124d5073bc29ab2755822181fcad978b12e144e5e5a4b3"}, 251 | {file = "numpy-1.26.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6081aed64714a18c72b168a9276095ef9155dd7888b9e74b5987808f0dd0a974"}, 252 | {file = "numpy-1.26.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:97e5d6a9f0702c2863aaabf19f0d1b6c2628fbe476438ce0b5ce06e83085064c"}, 253 | {file = "numpy-1.26.1-cp311-cp311-win32.whl", hash = "sha256:b9d45d1dbb9de84894cc50efece5b09939752a2d75aab3a8b0cef6f3a35ecd6b"}, 254 | {file = "numpy-1.26.1-cp311-cp311-win_amd64.whl", hash = "sha256:3649d566e2fc067597125428db15d60eb42a4e0897fc48d28cb75dc2e0454e53"}, 255 | {file = "numpy-1.26.1-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:06934e1a22c54636a059215d6da99e23286424f316fddd979f5071093b648668"}, 256 | {file = "numpy-1.26.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:76ff661a867d9272cd2a99eed002470f46dbe0943a5ffd140f49be84f68ffc42"}, 257 | {file = "numpy-1.26.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:6965888d65d2848e8768824ca8288db0a81263c1efccec881cb35a0d805fcd2f"}, 258 | {file = "numpy-1.26.1.tar.gz", hash = "sha256:c8c6c72d4a9f831f328efb1312642a1cafafaa88981d9ab76368d50d07d93cbe"}, 259 | ] 260 | 261 | [[package]] 262 | name = "packaging" 263 | version = "23.2" 264 | requires_python = ">=3.7" 265 | summary = "Core utilities for Python packages" 266 | files = [ 267 | {file = "packaging-23.2-py3-none-any.whl", hash = "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7"}, 268 | {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, 269 | ] 270 | 271 | [[package]] 272 | name = "pluggy" 273 | version = "1.3.0" 274 | requires_python = ">=3.8" 275 | summary = "plugin and hook calling mechanisms for python" 276 | files = [ 277 | {file = "pluggy-1.3.0-py3-none-any.whl", hash = "sha256:d89c696a773f8bd377d18e5ecda92b7a3793cbe66c87060a6fb58c7b6e1061f7"}, 278 | {file = "pluggy-1.3.0.tar.gz", hash = "sha256:cf61ae8f126ac6f7c451172cf30e3e43d3ca77615509771b3a984a0730651e12"}, 279 | ] 280 | 281 | [[package]] 282 | name = "pycparser" 283 | version = "2.21" 284 | requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 285 | summary = "C parser in Python" 286 | files = [ 287 | {file = "pycparser-2.21-py2.py3-none-any.whl", hash = "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9"}, 288 | {file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"}, 289 | ] 290 | 291 | [[package]] 292 | name = "pydantic" 293 | version = "2.4.2" 294 | requires_python = ">=3.7" 295 | summary = "Data validation using Python type hints" 296 | dependencies = [ 297 | "annotated-types>=0.4.0", 298 | "pydantic-core==2.10.1", 299 | "typing-extensions>=4.6.1", 300 | ] 301 | files = [ 302 | {file = "pydantic-2.4.2-py3-none-any.whl", hash = "sha256:bc3ddf669d234f4220e6e1c4d96b061abe0998185a8d7855c0126782b7abc8c1"}, 303 | {file = "pydantic-2.4.2.tar.gz", hash = "sha256:94f336138093a5d7f426aac732dcfe7ab4eb4da243c88f891d65deb4a2556ee7"}, 304 | ] 305 | 306 | [[package]] 307 | name = "pydantic-core" 308 | version = "2.10.1" 309 | requires_python = ">=3.7" 310 | summary = "" 311 | dependencies = [ 312 | "typing-extensions!=4.7.0,>=4.6.0", 313 | ] 314 | files = [ 315 | {file = "pydantic_core-2.10.1-cp311-cp311-macosx_10_7_x86_64.whl", hash = "sha256:073d4a470b195d2b2245d0343569aac7e979d3a0dcce6c7d2af6d8a920ad0bea"}, 316 | {file = "pydantic_core-2.10.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:600d04a7b342363058b9190d4e929a8e2e715c5682a70cc37d5ded1e0dd370b4"}, 317 | {file = "pydantic_core-2.10.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:39215d809470f4c8d1881758575b2abfb80174a9e8daf8f33b1d4379357e417c"}, 318 | {file = "pydantic_core-2.10.1-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:eeb3d3d6b399ffe55f9a04e09e635554012f1980696d6b0aca3e6cf42a17a03b"}, 319 | {file = "pydantic_core-2.10.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a7a7902bf75779bc12ccfc508bfb7a4c47063f748ea3de87135d433a4cca7a2f"}, 320 | {file = "pydantic_core-2.10.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3625578b6010c65964d177626fde80cf60d7f2e297d56b925cb5cdeda6e9925a"}, 321 | {file = "pydantic_core-2.10.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:caa48fc31fc7243e50188197b5f0c4228956f97b954f76da157aae7f67269ae8"}, 322 | {file = "pydantic_core-2.10.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:07ec6d7d929ae9c68f716195ce15e745b3e8fa122fc67698ac6498d802ed0fa4"}, 323 | {file = "pydantic_core-2.10.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e6f31a17acede6a8cd1ae2d123ce04d8cca74056c9d456075f4f6f85de055607"}, 324 | {file = "pydantic_core-2.10.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:d8f1ebca515a03e5654f88411420fea6380fc841d1bea08effb28184e3d4899f"}, 325 | {file = "pydantic_core-2.10.1-cp311-none-win32.whl", hash = "sha256:6db2eb9654a85ada248afa5a6db5ff1cf0f7b16043a6b070adc4a5be68c716d6"}, 326 | {file = "pydantic_core-2.10.1-cp311-none-win_amd64.whl", hash = "sha256:4a5be350f922430997f240d25f8219f93b0c81e15f7b30b868b2fddfc2d05f27"}, 327 | {file = "pydantic_core-2.10.1-cp311-none-win_arm64.whl", hash = "sha256:5fdb39f67c779b183b0c853cd6b45f7db84b84e0571b3ef1c89cdb1dfc367325"}, 328 | {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-macosx_10_7_x86_64.whl", hash = "sha256:d43002441932f9a9ea5d6f9efaa2e21458221a3a4b417a14027a1d530201ef1b"}, 329 | {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:fcb83175cc4936a5425dde3356f079ae03c0802bbdf8ff82c035f8a54b333521"}, 330 | {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:962ed72424bf1f72334e2f1e61b68f16c0e596f024ca7ac5daf229f7c26e4208"}, 331 | {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2cf5bb4dd67f20f3bbc1209ef572a259027c49e5ff694fa56bed62959b41e1f9"}, 332 | {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:e544246b859f17373bed915182ab841b80849ed9cf23f1f07b73b7c58baee5fb"}, 333 | {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:c0877239307b7e69d025b73774e88e86ce82f6ba6adf98f41069d5b0b78bd1bf"}, 334 | {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:53df009d1e1ba40f696f8995683e067e3967101d4bb4ea6f667931b7d4a01357"}, 335 | {file = "pydantic_core-2.10.1-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:a1254357f7e4c82e77c348dabf2d55f1d14d19d91ff025004775e70a6ef40ada"}, 336 | {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-macosx_10_7_x86_64.whl", hash = "sha256:524ff0ca3baea164d6d93a32c58ac79eca9f6cf713586fdc0adb66a8cdeab96a"}, 337 | {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3f0ac9fb8608dbc6eaf17956bf623c9119b4db7dbb511650910a82e261e6600f"}, 338 | {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:320f14bd4542a04ab23747ff2c8a778bde727158b606e2661349557f0770711e"}, 339 | {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:63974d168b6233b4ed6a0046296803cb13c56637a7b8106564ab575926572a55"}, 340 | {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:417243bf599ba1f1fef2bb8c543ceb918676954734e2dcb82bf162ae9d7bd514"}, 341 | {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:dda81e5ec82485155a19d9624cfcca9be88a405e2857354e5b089c2a982144b2"}, 342 | {file = "pydantic_core-2.10.1-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:14cfbb00959259e15d684505263d5a21732b31248a5dd4941f73a3be233865b9"}, 343 | {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-macosx_10_7_x86_64.whl", hash = "sha256:631cb7415225954fdcc2a024119101946793e5923f6c4d73a5914d27eb3d3a05"}, 344 | {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-macosx_11_0_arm64.whl", hash = "sha256:bec7dd208a4182e99c5b6c501ce0b1f49de2802448d4056091f8e630b28e9a52"}, 345 | {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:149b8a07712f45b332faee1a2258d8ef1fb4a36f88c0c17cb687f205c5dc6e7d"}, 346 | {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4d966c47f9dd73c2d32a809d2be529112d509321c5310ebf54076812e6ecd884"}, 347 | {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:7eb037106f5c6b3b0b864ad226b0b7ab58157124161d48e4b30c4a43fef8bc4b"}, 348 | {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:154ea7c52e32dce13065dbb20a4a6f0cc012b4f667ac90d648d36b12007fa9f7"}, 349 | {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:e562617a45b5a9da5be4abe72b971d4f00bf8555eb29bb91ec2ef2be348cd132"}, 350 | {file = "pydantic_core-2.10.1-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:f23b55eb5464468f9e0e9a9935ce3ed2a870608d5f534025cd5536bca25b1402"}, 351 | {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-macosx_10_7_x86_64.whl", hash = "sha256:e9121b4009339b0f751955baf4543a0bfd6bc3f8188f8056b1a25a2d45099934"}, 352 | {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:0523aeb76e03f753b58be33b26540880bac5aa54422e4462404c432230543f33"}, 353 | {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2e0e2959ef5d5b8dc9ef21e1a305a21a36e254e6a34432d00c72a92fdc5ecda5"}, 354 | {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:da01bec0a26befab4898ed83b362993c844b9a607a86add78604186297eb047e"}, 355 | {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f2e9072d71c1f6cfc79a36d4484c82823c560e6f5599c43c1ca6b5cdbd54f881"}, 356 | {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:f36a3489d9e28fe4b67be9992a23029c3cec0babc3bd9afb39f49844a8c721c5"}, 357 | {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:f64f82cc3443149292b32387086d02a6c7fb39b8781563e0ca7b8d7d9cf72bd7"}, 358 | {file = "pydantic_core-2.10.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:b4a6db486ac8e99ae696e09efc8b2b9fea67b63c8f88ba7a1a16c24a057a0776"}, 359 | {file = "pydantic_core-2.10.1.tar.gz", hash = "sha256:0f8682dbdd2f67f8e1edddcbffcc29f60a6182b4901c367fc8c1c40d30bb0a82"}, 360 | ] 361 | 362 | [[package]] 363 | name = "pytest" 364 | version = "7.4.2" 365 | requires_python = ">=3.7" 366 | summary = "pytest: simple powerful testing with Python" 367 | dependencies = [ 368 | "colorama; sys_platform == \"win32\"", 369 | "iniconfig", 370 | "packaging", 371 | "pluggy<2.0,>=0.12", 372 | ] 373 | files = [ 374 | {file = "pytest-7.4.2-py3-none-any.whl", hash = "sha256:1d881c6124e08ff0a1bb75ba3ec0bfd8b5354a01c194ddd5a0a870a48d99b002"}, 375 | {file = "pytest-7.4.2.tar.gz", hash = "sha256:a766259cfab564a2ad52cb1aae1b881a75c3eb7e34ca3779697c23ed47c47069"}, 376 | ] 377 | 378 | [[package]] 379 | name = "python-dateutil" 380 | version = "2.8.2" 381 | requires_python = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" 382 | summary = "Extensions to the standard Python datetime module" 383 | dependencies = [ 384 | "six>=1.5", 385 | ] 386 | files = [ 387 | {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, 388 | {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, 389 | ] 390 | 391 | [[package]] 392 | name = "sentry-sdk" 393 | version = "1.32.0" 394 | summary = "Python client for Sentry (https://sentry.io)" 395 | dependencies = [ 396 | "certifi", 397 | "urllib3>=1.26.11; python_version >= \"3.6\"", 398 | ] 399 | files = [ 400 | {file = "sentry-sdk-1.32.0.tar.gz", hash = "sha256:935e8fbd7787a3702457393b74b13d89a5afb67185bc0af85c00cb27cbd42e7c"}, 401 | {file = "sentry_sdk-1.32.0-py2.py3-none-any.whl", hash = "sha256:eeb0b3550536f3bbc05bb1c7e0feb3a78d74acb43b607159a606ed2ec0a33a4d"}, 402 | ] 403 | 404 | [[package]] 405 | name = "setuptools" 406 | version = "68.2.2" 407 | requires_python = ">=3.8" 408 | summary = "Easily download, build, install, upgrade, and uninstall Python packages" 409 | files = [ 410 | {file = "setuptools-68.2.2-py3-none-any.whl", hash = "sha256:b454a35605876da60632df1a60f736524eb73cc47bbc9f3f1ef1b644de74fd2a"}, 411 | {file = "setuptools-68.2.2.tar.gz", hash = "sha256:4ac1475276d2f1c48684874089fefcd83bd7162ddaafb81fac866ba0db282a87"}, 412 | ] 413 | 414 | [[package]] 415 | name = "six" 416 | version = "1.16.0" 417 | requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" 418 | summary = "Python 2 and 3 compatibility utilities" 419 | files = [ 420 | {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, 421 | {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, 422 | ] 423 | 424 | [[package]] 425 | name = "sniffio" 426 | version = "1.3.0" 427 | requires_python = ">=3.7" 428 | summary = "Sniff out which async library your code is running under" 429 | files = [ 430 | {file = "sniffio-1.3.0-py3-none-any.whl", hash = "sha256:eecefdce1e5bbfb7ad2eeaabf7c1eeb404d7757c379bd1f7e5cce9d8bf425384"}, 431 | {file = "sniffio-1.3.0.tar.gz", hash = "sha256:e60305c5e5d314f5389259b7f22aaa33d8f7dee49763119234af3755c55b9101"}, 432 | ] 433 | 434 | [[package]] 435 | name = "starlette" 436 | version = "0.27.0" 437 | requires_python = ">=3.7" 438 | summary = "The little ASGI library that shines." 439 | dependencies = [ 440 | "anyio<5,>=3.4.0", 441 | ] 442 | files = [ 443 | {file = "starlette-0.27.0-py3-none-any.whl", hash = "sha256:918416370e846586541235ccd38a474c08b80443ed31c578a418e2209b3eef91"}, 444 | {file = "starlette-0.27.0.tar.gz", hash = "sha256:6a6b0d042acb8d469a01eba54e9cda6cbd24ac602c4cd016723117d6a7e73b75"}, 445 | ] 446 | 447 | [[package]] 448 | name = "timezonefinder" 449 | version = "6.2.0" 450 | requires_python = ">=3.8,<4" 451 | summary = "fast python package for finding the timezone of any point on earth (coordinates) offline" 452 | dependencies = [ 453 | "cffi<2,>=1.15.1", 454 | "h3<4,>=3.7.6", 455 | "numpy<2,>=1.18", 456 | "setuptools>=65.5", 457 | ] 458 | files = [ 459 | {file = "timezonefinder-6.2.0.tar.gz", hash = "sha256:d41fd2650bb4221fae5a61f9c2767158f9727c4aaca95e24da86394feb704220"}, 460 | ] 461 | 462 | [[package]] 463 | name = "typing-extensions" 464 | version = "4.8.0" 465 | requires_python = ">=3.8" 466 | summary = "Backported and Experimental Type Hints for Python 3.8+" 467 | files = [ 468 | {file = "typing_extensions-4.8.0-py3-none-any.whl", hash = "sha256:8f92fc8806f9a6b641eaa5318da32b44d401efaac0f6678c9bc448ba3605faa0"}, 469 | {file = "typing_extensions-4.8.0.tar.gz", hash = "sha256:df8e4339e9cb77357558cbdbceca33c303714cf861d1eef15e1070055ae8b7ef"}, 470 | ] 471 | 472 | [[package]] 473 | name = "tzdata" 474 | version = "2023.3" 475 | requires_python = ">=2" 476 | summary = "Provider of IANA time zone data" 477 | files = [ 478 | {file = "tzdata-2023.3-py2.py3-none-any.whl", hash = "sha256:7e65763eef3120314099b6939b5546db7adce1e7d6f2e179e3df563c70511eda"}, 479 | {file = "tzdata-2023.3.tar.gz", hash = "sha256:11ef1e08e54acb0d4f95bdb1be05da659673de4acbd21bf9c69e94cc5e907a3a"}, 480 | ] 481 | 482 | [[package]] 483 | name = "urllib3" 484 | version = "2.0.7" 485 | requires_python = ">=3.7" 486 | summary = "HTTP library with thread-safe connection pooling, file post, and more." 487 | files = [ 488 | {file = "urllib3-2.0.7-py3-none-any.whl", hash = "sha256:fdb6d215c776278489906c2f8916e6e7d4f5a9b602ccbcfdf7f016fc8da0596e"}, 489 | {file = "urllib3-2.0.7.tar.gz", hash = "sha256:c97dfde1f7bd43a71c8d2a58e369e9b2bf692d1334ea9f9cae55add7d0dd0f84"}, 490 | ] 491 | 492 | [[package]] 493 | name = "uvicorn" 494 | version = "0.23.2" 495 | requires_python = ">=3.8" 496 | summary = "The lightning-fast ASGI server." 497 | dependencies = [ 498 | "click>=7.0", 499 | "h11>=0.8", 500 | ] 501 | files = [ 502 | {file = "uvicorn-0.23.2-py3-none-any.whl", hash = "sha256:1f9be6558f01239d4fdf22ef8126c39cb1ad0addf76c40e760549d2c2f43ab53"}, 503 | {file = "uvicorn-0.23.2.tar.gz", hash = "sha256:4d3cc12d7727ba72b64d12d3cc7743124074c0a69f7b201512fc50c3e3f1569a"}, 504 | ] 505 | 506 | [[package]] 507 | name = "zmanim" 508 | version = "0.3.1" 509 | requires_python = ">=3.6" 510 | summary = "A Zmanim library for Python" 511 | dependencies = [ 512 | "julian", 513 | "memoization", 514 | "python-dateutil", 515 | ] 516 | files = [ 517 | {file = "zmanim-0.3.1-py3-none-any.whl", hash = "sha256:ae3cf6d8878d7a50ed6beb76c6da7abca5063b02f70e781519d705b5cc317d79"}, 518 | {file = "zmanim-0.3.1.tar.gz", hash = "sha256:10883ae3f0903175d5f038ef5a12fba37bec71e0ea1713712720c77b3926d2b0"}, 519 | ] 520 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------