{"id":22422,"library":"suntime","title":"Suntime","description":"Simple sunset and sunrise time calculation Python library. Current version 1.3.2. Released irregularly.","status":"active","version":"1.3.2","language":"python","source_language":"en","source_url":"https://github.com/SatAgro/suntime","tags":["sunrise","sunset","astronomy","coordinates"],"install":[{"cmd":"pip install suntime","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"note":null,"wrong":null,"symbol":"Sun","correct":"from suntime import Sun"}],"quickstart":{"code":"from suntime import Sun\nfrom datetime import datetime, timedelta\n\n# Example coordinates: London\nlat = 51.5\nlon = -0.13\nsun = Sun(lat, lon)\n\n# Get sunrise and sunset for today\ntoday = datetime.now().date()\nsunrise = sun.get_sunrise_time(today)\nsunset = sun.get_sunset_time(today)\nprint(f\"Sunrise: {sunrise}, Sunset: {sunset}\")\n\n# Deprecated (remove in future): get_local_sunrise_time, get_local_sunset_time\n# sunrise_local = sun.get_local_sunrise_time(today)\n# sunset_local = sun.get_local_sunset_time(today)","lang":"python","description":"Initialize Sun with latitude and longitude, then call get_sunrise_time/get_sunset_time with a date."},"warnings":[{"fix":"Use get_sunrise_time and get_sunset_time which return UTC datetime objects. Convert to local timezone with pytz or zoneinfo.","message":"get_local_sunrise_time and get_local_sunset_time are deprecated since v1.3.0.","severity":"deprecated","affected_versions":">=1.3.0"},{"fix":"Ensure correct sign: e.g., London is +51.5, -0.13.","message":"Coordinates are in decimal degrees. Negative longitude for west, negative latitude for south.","severity":"gotcha","affected_versions":"all"},{"fix":"Understand that reported seconds are approximate; do not rely on sub-minute accuracy.","message":"Results are approximate (seconds calculation depends on orography).","severity":"gotcha","affected_versions":">=1.3.0"},{"fix":"Pass a datetime.date object: e.g., datetime.now().date().","message":"get_sunrise_time and get_sunset_time require a date object (not datetime).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Upgrade to latest version: pip install --upgrade suntime. Or use get_local_sunrise_time if staying on older version.","cause":"Using an older version of suntime (<1.3.0) where only get_local_sunrise_time existed.","error":"AttributeError: 'Sun' object has no attribute 'get_sunrise_time'"},{"fix":"Check coordinate values. For example, lat=51.5, lon=-0.13.","cause":"Latitude or longitude out of range. Latitude must be -90 to 90, longitude -180 to 180.","error":"ValueError: Invalid latitude/longitude"},{"fix":"Use .date() on datetime: e.g., sun.get_sunrise_time(datetime.now().date()).","cause":"Passing a datetime object instead of date object to get_sunrise_time/get_sunset_time.","error":"TypeError: unsupported type for timedelta seconds component: datetime.date"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}