{"id":19313106,"url":"https://github.com/curzon01/mysql_sunriseset","last_synced_at":"2026-05-20T05:02:16.474Z","repository":{"id":77918836,"uuid":"156348983","full_name":"curzon01/mysql_SunRiseSet","owner":"curzon01","description":"MySQL/MariaDB SunRiseSet Calculation","archived":false,"fork":false,"pushed_at":"2023-01-18T07:57:44.000Z","size":18,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-06T02:42:53.992Z","etag":null,"topics":["algorithm","algorithms-implemented","mariadb","mysql","sunrise","sunset"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/curzon01.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-06T08:13:55.000Z","updated_at":"2022-01-15T08:05:25.000Z","dependencies_parsed_at":"2023-02-27T22:00:28.769Z","dependency_job_id":null,"html_url":"https://github.com/curzon01/mysql_SunRiseSet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curzon01%2Fmysql_SunRiseSet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curzon01%2Fmysql_SunRiseSet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curzon01%2Fmysql_SunRiseSet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curzon01%2Fmysql_SunRiseSet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/curzon01","download_url":"https://codeload.github.com/curzon01/mysql_SunRiseSet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240415214,"owners_count":19797599,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","algorithms-implemented","mariadb","mysql","sunrise","sunset"],"created_at":"2024-11-10T00:37:20.912Z","updated_at":"2025-10-04T18:08:45.809Z","avatar_url":"https://github.com/curzon01.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# MySQL SunRiseSet Calculation\n\nMySQL/MariaDB function to calculate the sunrise/sunset time based on date and latitude/longitude.\n\nThis implementation is based by the algorithm found on http://web.archive.org/web/20161202180207/http://williams.best.vwh.net/sunrise_sunset_algorithm.htm\n\nA more powerful variant can be found as a MySQL Loadable Function implementation under [lib_mysqludf_astro](https://github.com/curzon01/lib_mysqludf_astro).\n\n## Installation\n\nExecute the code of SunRiseSet.sql, for example\n```\nmysql -u \u003cusername\u003e -p \u003cyourdb\u003e \u003c SunRiseSet.sql\n```\n\n## Usage\n\nCall the function with date, your location and which time you want to get back (sunrise, sunset)\n\n### SunRiseSet(date, latitude, longitude, zenith, sunriseset)\n\nThe paramater are:\n#### date\nDate of interest - MySQL date format `yyyy-mm-dd`\n\n#### latitude\nLocation latitude - FLOAT\n\n#### longitude\nLocation longitude - FLOAT  \nPositive for east and negative for west.\n\n#### zenith\nSun's zenith for sunrise/sunset: enum['official','civil','nautical','astronomical'] or FLOAT\n\n#### sunriseset\nDesired result - enum['sunrise','sunset']\n\n\n### Examples\nReplace latitude 0.0000 and longitude 0.0000 with your local settings:\n```\n-- official sunset/sunrise\nSELECT system.SunRiseSet(NOW(), 0.0000, 0.0000, 'official', 'sunset'), system.SunRiseSet(NOW(), 0.0000, 0.0000, 'official', 'sunrise');\nSELECT system.SunRiseSet(NOW(), 0.0000, 0.0000, 90+(50/60), 'sunset'), system.SunRiseSet(NOW(), 0.0000, 0.0000, 90.833333333, 'sunrise');\n-- civil\nSELECT system.SunRiseSet(NOW(), 0.0000, 0.0000, 'civil', 'sunset'), system.SunRiseSet(NOW(), 0.0000, 0.0000, 'civil', 'rise');\nSELECT system.SunRiseSet(NOW(), 0.0000, 0.0000, 96, 'sunset'), system.SunRiseSet(NOW(), 0.0000, 0.0000, 96, 'rise');\n-- nautical\nSELECT system.SunRiseSet(NOW(), 0.0000, 0.0000, 'nautical', 'set'), system.SunRiseSet(NOW(), 0.0000, 0.0000, 'nautical', 'rise');\n-- astronomical\nSELECT system.SunRiseSet(NOW(), 0.0000, 0.0000, 'astro', 'sunset'), system.SunRiseSet(NOW(), 0.0000, 0.0000, 'astro', 'sunrise');\n\n-- self defined sun horizon level\nSELECT system.SunRiseSet(NOW(), 0.0000, 0.0000, 86.2, 'sunset'), system.SunRiseSet(NOW(), 0.0000, 0.0000, 86.2, 'sunrise');\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurzon01%2Fmysql_sunriseset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcurzon01%2Fmysql_sunriseset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurzon01%2Fmysql_sunriseset/lists"}