suntime


Namesuntime JSON
Version 1.3.2 PyPI version JSON
download
home_pagehttps://github.com/SatAgro/suntime
SummarySimple sunset and sunrise time calculation python library
upload_time2024-03-10 21:48:47
maintainer
docs_urlNone
authorKrzysztof Stopa
requires_python
licenseLGPLv3
keywords
VCS
bugtrack_url
requirements python-dateutil
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SunTime
Simple sunset and sunrise time calculation python library.

## Installation

Using pip:

    pip3 install suntime
    
Or download and type:

    python3 setup.py install

## Usage

You can use the library to get UTC and local time sunrise and sunset times typing:

```python3
import datetime
from dateutil import tz
from suntime import Sun, SunTimeException

warsaw_lat = 51.21
warsaw_lon = 21.01

sun = Sun(warsaw_lat, warsaw_lon)

# Get today's sunrise and sunset in UTC
today_sr = sun.get_sunrise_time()
today_ss = sun.get_sunset_time()
print('Today at Warsaw the sun raised at {} and get down at {} UTC'.
      format(today_sr.strftime('%H:%M'), today_ss.strftime('%H:%M')))

# On a special date in your machine's local time zone
abd = datetime.date(2014, 10, 3)
abd_sr = sun.get_sunrise_time(abd, tz.gettz('Europe/Warsaw'))
abd_ss = sun.get_sunset_time(abd, tz.gettz('Europe/Warsaw'))
print('On {} the sun at Warsaw raised at {} and get down at {}.'.
      format(abd, abd_sr.strftime('%H:%M'), abd_ss.strftime('%H:%M')))

# Error handling (no sunset or sunrise on given location)
latitude = 87.55
longitude = 0.1
sun = Sun(latitude, longitude)
try:
    abd_sr = sun.get_sunrise_time(abd)
    abd_ss = sun.get_sunset_time(abd)
    print('On {} at somewhere in the north the sun raised at {} and get down at {}.'.
          format(abd, abd_sr.strftime('%H:%M'), abd_ss.strftime('%H:%M')))
except SunTimeException as e:
    print("Error: {0}.".format(e))
```

## Testing

To run the tests, type:

> pytest tests.py

For linting checks, type:

> flake8 .

## License

Copyright © 2024 [SatAgro Sp. z o.o.](https://satagro.pl) and our awesome contributors:

* Andrey Kobyshev ([yokotoka](https://github.com/yokotoka))
* Hadrien Bertrand ([hbertrand](https://github.com/hbertrand))
* Ingo Randolf ([i-n-g-o](https://github.com/i-n-g-o))
* John Vandenberg ([jayvdb](https://github.com/jayvdb))
* Krzysztof Stopa ([kstopa](https://github.com/kstopa))
* Matthias ([palto42](https://github.com/plato42))
* Muhammad Yasirroni ([yasirroni](https://github.com/yasirroni))

This file is part of SunTime library for python (SunTime).

SunTime is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.

SunTime is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with CAMS tools. If not, see http://www.gnu.org/licenses/.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/SatAgro/suntime",
    "name": "suntime",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Krzysztof Stopa",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/15/c2/326d74790070491bf28e0e304b951f5e47d65c0abfab33677d379117db29/suntime-1.3.2.tar.gz",
    "platform": null,
    "description": "# SunTime\nSimple sunset and sunrise time calculation python library.\n\n## Installation\n\nUsing pip:\n\n    pip3 install suntime\n    \nOr download and type:\n\n    python3 setup.py install\n\n## Usage\n\nYou can use the library to get UTC and local time sunrise and sunset times typing:\n\n```python3\nimport datetime\nfrom dateutil import tz\nfrom suntime import Sun, SunTimeException\n\nwarsaw_lat = 51.21\nwarsaw_lon = 21.01\n\nsun = Sun(warsaw_lat, warsaw_lon)\n\n# Get today's sunrise and sunset in UTC\ntoday_sr = sun.get_sunrise_time()\ntoday_ss = sun.get_sunset_time()\nprint('Today at Warsaw the sun raised at {} and get down at {} UTC'.\n      format(today_sr.strftime('%H:%M'), today_ss.strftime('%H:%M')))\n\n# On a special date in your machine's local time zone\nabd = datetime.date(2014, 10, 3)\nabd_sr = sun.get_sunrise_time(abd, tz.gettz('Europe/Warsaw'))\nabd_ss = sun.get_sunset_time(abd, tz.gettz('Europe/Warsaw'))\nprint('On {} the sun at Warsaw raised at {} and get down at {}.'.\n      format(abd, abd_sr.strftime('%H:%M'), abd_ss.strftime('%H:%M')))\n\n# Error handling (no sunset or sunrise on given location)\nlatitude = 87.55\nlongitude = 0.1\nsun = Sun(latitude, longitude)\ntry:\n    abd_sr = sun.get_sunrise_time(abd)\n    abd_ss = sun.get_sunset_time(abd)\n    print('On {} at somewhere in the north the sun raised at {} and get down at {}.'.\n          format(abd, abd_sr.strftime('%H:%M'), abd_ss.strftime('%H:%M')))\nexcept SunTimeException as e:\n    print(\"Error: {0}.\".format(e))\n```\n\n## Testing\n\nTo run the tests, type:\n\n> pytest tests.py\n\nFor linting checks, type:\n\n> flake8 .\n\n## License\n\nCopyright \u00a9 2024 [SatAgro Sp. z o.o.](https://satagro.pl) and our awesome contributors:\n\n* Andrey Kobyshev ([yokotoka](https://github.com/yokotoka))\n* Hadrien Bertrand ([hbertrand](https://github.com/hbertrand))\n* Ingo Randolf ([i-n-g-o](https://github.com/i-n-g-o))\n* John Vandenberg ([jayvdb](https://github.com/jayvdb))\n* Krzysztof Stopa ([kstopa](https://github.com/kstopa))\n* Matthias ([palto42](https://github.com/plato42))\n* Muhammad Yasirroni ([yasirroni](https://github.com/yasirroni))\n\nThis file is part of SunTime library for python (SunTime).\n\nSunTime is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.\n\nSunTime is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License along with CAMS tools. If not, see http://www.gnu.org/licenses/.\n",
    "bugtrack_url": null,
    "license": "LGPLv3",
    "summary": "Simple sunset and sunrise time calculation python library",
    "version": "1.3.2",
    "project_urls": {
        "Homepage": "https://github.com/SatAgro/suntime"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d1d5bb9997169b8b64d48f9a807fb2ec2413ff5e75c4b77612e75dd0aac8369c",
                "md5": "91a94d4da2a4a6309b9aa8beaa410187",
                "sha256": "33ac6ec2a3e14758cc690f7573f689d19c3131a6c9753f1bb54460bd70372ca4"
            },
            "downloads": -1,
            "filename": "suntime-1.3.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "91a94d4da2a4a6309b9aa8beaa410187",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7211,
            "upload_time": "2024-03-10T21:48:46",
            "upload_time_iso_8601": "2024-03-10T21:48:46.769394Z",
            "url": "https://files.pythonhosted.org/packages/d1/d5/bb9997169b8b64d48f9a807fb2ec2413ff5e75c4b77612e75dd0aac8369c/suntime-1.3.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "15c2326d74790070491bf28e0e304b951f5e47d65c0abfab33677d379117db29",
                "md5": "0f6226410557351f4a21786ffade7c79",
                "sha256": "4834f7907ad13dbb369904cb5f4376edc0b06c6e8a1cfc0aac1268f64d0ecdcf"
            },
            "downloads": -1,
            "filename": "suntime-1.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "0f6226410557351f4a21786ffade7c79",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6914,
            "upload_time": "2024-03-10T21:48:47",
            "upload_time_iso_8601": "2024-03-10T21:48:47.788409Z",
            "url": "https://files.pythonhosted.org/packages/15/c2/326d74790070491bf28e0e304b951f5e47d65c0abfab33677d379117db29/suntime-1.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-10 21:48:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SatAgro",
    "github_project": "suntime",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "python-dateutil",
            "specs": [
                [
                    ">=",
                    "2.1.0"
                ]
            ]
        }
    ],
    "lcname": "suntime"
}
        
Elapsed time: 1.20511s