iranholidays


Nameiranholidays JSON
Version 0.2.4 PyPI version JSON
download
home_pageNone
Summaryprovides functions to tell if a date is a holiday in Iran or not
upload_time2024-09-09 11:58:55
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ``iranholidays`` is a small python library that provides functions to check if a date is a holiday in Iran or not. 

**Warning:** For Islamic holidays, like Eid al-Fitr, the calculation may be off by a day or two since those events depend on seeing the moon by naked eye and cannot be predicted by computers.

Usage
-----

.. code-block:: python

    from iranholidays import holiday_occasion

    assert holiday_occasion((2024, 4, 1, 'G')) == 'Sizdah Be-dar'  # Gregorian
    assert holiday_occasion((1403, 1, 13, 'S')) == 'Sizdah Be-dar'  # Solar
    assert holiday_occasion((1403, 1, 14, 'S')) is None
    assert holiday_occasion((1445, 9, 21, 'L')) == 'Martyrdom of Ali'  # Lunar


In case you have a date object from the following libraries, you can check it directly using one of the ``off_occasion_*`` functions:

.. code-block:: python

    import datetime

    import hijri_converter
    import jdatetime

    from iranholidays import (
        off_occasion_gregorian,
        off_occasion_lunar,
        off_occasion_solar,
    )

    date = datetime.date(2024, 4, 1)
    assert off_occasion_gregorian(date, weekend=()) == 'Sizdah Be-dar'

    date = jdatetime.date(1403, 1, 13)
    assert off_occasion_solar(date, weekend=()) == 'Sizdah Be-dar'

    date = hijri_converter.Hijri(1445, 9, 21)
    assert off_occasion_lunar(date, weekend=()) == 'Martyrdom of Ali'

``off_occasion`` function checks if a date is a weekend or holiday and returns the occasion string or ``None``. The default value for weekend parameter is ``(4,)`` which means Friday. Either pass a different value to ``weekend`` parameter to override it or use ``set_default_weekend`` function to change this default for all functions:

.. code-block:: python

    from iranholidays import off_occasion, set_default_weekend
    date = (2024, 2, 5, 'G')  # a non-holiday Monday
    assert off_occasion(date) is None
    assert off_occasion(date, weekend=(0,)) == 'Weekend'
    set_default_weekend((0,))  # set default weekends to Thursday and Friday
    assert off_occasion(date) == 'Weekend'


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "iranholidays",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "5j9 <5j9@users.noreply.github.com>",
    "download_url": "https://files.pythonhosted.org/packages/15/4c/5a888e05bd4e80db5428978d31d63e7b8f4a470e611aa4f76b69241d6b96/iranholidays-0.2.4.tar.gz",
    "platform": null,
    "description": "``iranholidays`` is a small python library that provides functions to check if a date is a holiday in Iran or not. \n\n**Warning:** For Islamic holidays, like Eid al-Fitr, the calculation may be off by a day or two since those events depend on seeing the moon by naked eye and cannot be predicted by computers.\n\nUsage\n-----\n\n.. code-block:: python\n\n    from iranholidays import holiday_occasion\n\n    assert holiday_occasion((2024, 4, 1, 'G')) == 'Sizdah Be-dar'  # Gregorian\n    assert holiday_occasion((1403, 1, 13, 'S')) == 'Sizdah Be-dar'  # Solar\n    assert holiday_occasion((1403, 1, 14, 'S')) is None\n    assert holiday_occasion((1445, 9, 21, 'L')) == 'Martyrdom of Ali'  # Lunar\n\n\nIn case you have a date object from the following libraries, you can check it directly using one of the ``off_occasion_*`` functions:\n\n.. code-block:: python\n\n    import datetime\n\n    import hijri_converter\n    import jdatetime\n\n    from iranholidays import (\n        off_occasion_gregorian,\n        off_occasion_lunar,\n        off_occasion_solar,\n    )\n\n    date = datetime.date(2024, 4, 1)\n    assert off_occasion_gregorian(date, weekend=()) == 'Sizdah Be-dar'\n\n    date = jdatetime.date(1403, 1, 13)\n    assert off_occasion_solar(date, weekend=()) == 'Sizdah Be-dar'\n\n    date = hijri_converter.Hijri(1445, 9, 21)\n    assert off_occasion_lunar(date, weekend=()) == 'Martyrdom of Ali'\n\n``off_occasion`` function checks if a date is a weekend or holiday and returns the occasion string or ``None``. The default value for weekend parameter is ``(4,)`` which means Friday. Either pass a different value to ``weekend`` parameter to override it or use ``set_default_weekend`` function to change this default for all functions:\n\n.. code-block:: python\n\n    from iranholidays import off_occasion, set_default_weekend\n    date = (2024, 2, 5, 'G')  # a non-holiday Monday\n    assert off_occasion(date) is None\n    assert off_occasion(date, weekend=(0,)) == 'Weekend'\n    set_default_weekend((0,))  # set default weekends to Thursday and Friday\n    assert off_occasion(date) == 'Weekend'\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "provides functions to tell if a date is a holiday in Iran or not",
    "version": "0.2.4",
    "project_urls": {
        "Homepage": "https://github.com/5j9/iranholidays"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "53f581b3cd5ac393c8e243caaf4500337d70715a428c9d2778010d2fab6799c9",
                "md5": "33083fd27a7fbab2b677f3e42353b92f",
                "sha256": "c30a917c678f1d267de595e7e4e0e49cb1d9a86cbcc2d16c1ddd7976c131d1aa"
            },
            "downloads": -1,
            "filename": "iranholidays-0.2.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "33083fd27a7fbab2b677f3e42353b92f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 15976,
            "upload_time": "2024-09-09T11:58:54",
            "upload_time_iso_8601": "2024-09-09T11:58:54.368732Z",
            "url": "https://files.pythonhosted.org/packages/53/f5/81b3cd5ac393c8e243caaf4500337d70715a428c9d2778010d2fab6799c9/iranholidays-0.2.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "154c5a888e05bd4e80db5428978d31d63e7b8f4a470e611aa4f76b69241d6b96",
                "md5": "72be47035eb59eda5b2a4e011125c8b4",
                "sha256": "c2e2079ecd92b491c0c3bc6cfab959289a89b70eda68d121c552a64c9b09e91d"
            },
            "downloads": -1,
            "filename": "iranholidays-0.2.4.tar.gz",
            "has_sig": false,
            "md5_digest": "72be47035eb59eda5b2a4e011125c8b4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 16328,
            "upload_time": "2024-09-09T11:58:55",
            "upload_time_iso_8601": "2024-09-09T11:58:55.824149Z",
            "url": "https://files.pythonhosted.org/packages/15/4c/5a888e05bd4e80db5428978d31d63e7b8f4a470e611aa4f76b69241d6b96/iranholidays-0.2.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-09 11:58:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "5j9",
    "github_project": "iranholidays",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "iranholidays"
}
        
Elapsed time: 0.50211s