{"id":14036794,"url":"https://github.com/vijinho/moon","last_synced_at":"2025-03-20T01:30:37.436Z","repository":{"id":71221161,"uuid":"153035907","full_name":"vijinho/moon","owner":"vijinho","description":"CLI script/web API to show lunar phase information","archived":false,"fork":false,"pushed_at":"2023-05-08T19:25:39.000Z","size":26,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-08-13T03:05:48.033Z","etag":null,"topics":["api-client","api-service","apis","json-api","moon","moon-phase","php-api","php-cli","solar-system"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vijinho.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2018-10-15T01:24:47.000Z","updated_at":"2023-05-26T09:15:34.000Z","dependencies_parsed_at":"2024-04-16T08:41:42.089Z","dependency_job_id":null,"html_url":"https://github.com/vijinho/moon","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/vijinho%2Fmoon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vijinho%2Fmoon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vijinho%2Fmoon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vijinho%2Fmoon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vijinho","download_url":"https://codeload.github.com/vijinho/moon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219865988,"owners_count":16555917,"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":["api-client","api-service","apis","json-api","moon","moon-phase","php-api","php-cli","solar-system"],"created_at":"2024-08-12T03:02:14.103Z","updated_at":"2024-10-10T18:32:09.896Z","avatar_url":"https://github.com/vijinho.png","language":"PHP","readme":"# moon - A command-line php for the Moon Phase\n\nCLI script `moon.php` instantiates class [solarissmoke/php-moon-phase](https://github.com/solarissmoke/php-moon-phase) and echoes JSON if successful\n\nThe script can also be run as a web-service with PHP's in-built webserver for testing the JSON request/responses.\n\n*NOTE:* Originally this script called the burning soul REST API to get the data, that\nprevious code is on this branch: https://github.com/vijinho/moon/tree/burningsoul\n\n## Features\n\n- Runs on the command-line\n- Can be called as a stand-alone webservice using the php command line built-in server\n- All messages when running with `--debug` or `--verbose` are to *stderr* to avoid interference with *stdout*\n- Can output the result if successful to *stdout*\n- Specify date-format using [php date()](https://secure.php.net/manual/en/function.date.php)\n- Errors are output in JSON as 'errors' with just a bunch of strings\n\n```\n{\n    \"errors\": [\n        \"Unable to parse --date: next sunsaday\"\n    ]\n}\n```\n\n## Returned results fields/columns/keys\n\n - `phase`: the terminator phase angle as a fraction of a full circle (i.e., 0 to 1). Both 0 and 1 correspond to a New Moon, and 0.5 corresponds to a Full Moon.\n - `illumination`: the illuminated fraction of the Moon (0 = New, 1 = Full).\n - `age_days`: the age of the Moon, in days.\n - `distance_km`: the distance of the Moon from the centre of the Earth (kilometres).\n - `diameter`: the angular diameter subtended by the Moon as seen by an observer at the centre of the Earth (degrees).\n - `sun_distance_km`: the distance to the Sun (kilometres).\n - `sun_diameter`: the angular diameter subtended by the Sun as seen by an observer at the centre of the Earth (degrees).\n - `new_moon`: the time of the last New Moon (UNIX timestamp).\n - `next_new_moon`: the time of the next New Moon (UNIX timestamp).\n - `full_moon`: the time of the Full Moon in the current lunar cycle (UNIX timestamp).\n - `next_full_moon`: the time of the next Full Moon in the current lunar cycle (UNIX timestamp).\n - `first_quarter`: the time of the first quarter in the current lunar cycle (UNIX timestamp).\n - `next_first_quarter`: the time of the next first quarter in the current lunar cycle (UNIX timestamp).\n - `last_quarter`: the time of the last quarter in the current lunar cycle (UNIX timestamp).\n - `next_last_quarter`: the time of the next last quarter in the current lunar cycle (UNIX timestamp).\n - `phase_name`: the [phase name](http://aa.usno.navy.mil/faq/docs/moon_phases.php).\n - `stage`: the phase waxing/waning\n\n## Instructions\n\n### Command-line options\n\n```\nUsage: php moon.php\nGet the moon phase data using class https://github.com/solarissmoke/php-moon-phase\n(Specifying any other unknown argument options will be ignored.)\n\n        -h,  --help                   Display this help and exit\n        -v,  --verbose                Run in verbose mode\n        -d,  --debug                  Run in debug mode (implies also -v, --verbose)\n        -r,  --round                  (Optional) Round returned esults\n        -t   --date={now}             (Optional) Date/time default 'now' see: https://secure.php.net/manual/en/function.strtotime.php\n             --date-format={U}        (Optional) Format to output, using date(), default unixtime, see: https://secure.php.net/manual/en/function.date.php\n```\n\n### Requirements/Installation\n\n- PHP7\n- composer: run `composer install` to install dependency [solarissmoke/php-moon-phase](https://github.com/solarissmoke/php-moon-phase)\n\n## Testing Example\n\nRun the following to run the test and view in 'less' text viewer:\n\n`php moon.php --debug 2\u003e\u00261 | less`\n\n```\n[D 1/1] OPTIONS:\nArray\n(\n    [debug] =\u003e 1\n    [round] =\u003e 0\n    [verbose] =\u003e 1\n)\n{\n    \"timestamp\": 0,\n    \"datestamp\": \"Thu, 01 Jan 1970 00:00:00 +0000\",\n    \"phase\": 0.752075462874,\n    \"illumination\": 0.493479925882,\n    \"age_days\": 22.2092311504,\n    \"distance_km\": 391227.193148,\n    \"diameter\": 0.509060110309,\n    \"sundistance_km\": 147099708.642,\n    \"sundiameter\": 0.542184276533,\n    \"new_moon_last\": -1952337.60241,\n    \"new_moon_next\": 592540.734328,\n    \"full_moon\": -714314.659417,\n    \"full_moon_next\": 1860925.62916,\n    \"first_quarter\": -1378241.1266,\n    \"first_quarter_next\": 1171091.16973,\n    \"last_quarter\": -4036.1356616,\n    \"last_quarter_next\": 2558339.3858,\n    \"phase_name\": \"Third Quarter\",\n    \"stage\": \"waning\"\n}[D 1/1] Memory used (1/1) MB (current/peak).\n```\n\nwith rounding '-r'\n\n```\n{\n    \"timestamp\": 0,\n    \"datestamp\": \"Thu, 01 Jan 1970 00:00:00 +0000\",\n    \"phase\": 0.752,\n    \"illumination\": 0.493,\n    \"age_days\": 22.209,\n    \"distance_km\": 391228,\n    \"diameter\": 0.509,\n    \"sundistance_km\": 147099709,\n    \"sundiameter\": 0.542,\n    \"new_moon_last\": -1952338,\n    \"new_moon_next\": 592541,\n    \"full_moon\": -714315,\n    \"full_moon_next\": 1860926,\n    \"first_quarter\": -1378241,\n    \"first_quarter_next\": 1171091,\n    \"last_quarter\": -4036,\n    \"last_quarter_next\": 2558339,\n    \"phase_name\": 0,\n    \"stage\": \"waning\"\n}\n```\n\n### Save to file example\n\n`php moon.php --date='next year' \u003e test.json`\n\n## Running as a webservice\n\n### Starting the service\n\n1. Start the PHP webserver with `php -S 127.0.0.1:12312`\n2. Browse the URL: http://127.0.0.1:12312/moon.php with GET/POST parameters as 'date=\u003cUNIX TIMESTAMP\u003e'  and 'round' for rounding or no param for NOW.\n\n### Webservice Example\n\nSearch for moon phase 'next sunday' with rounding:\n\nhttp://127.0.0.1:12312/moon.php?date=next%20sunday\u0026round\n\nResult:\n\n```\n{\n    \"timestamp\": 1540080000,\n    \"datestamp\": \"Sun, 21 Oct 2018 00:00:00 +0000\",\n    \"phase\": 0.379,\n    \"illumination\": 0.862,\n    \"age_days\": 11.191,\n    \"distance_km\": 400971,\n    \"diameter\": 0.497,\n    \"sundistance_km\": 148914125,\n    \"sundiameter\": 0.536,\n    \"new_moon_last\": 1539056870,\n    \"new_moon_next\": 1541606572,\n    \"full_moon\": 1540399654,\n    \"full_moon_next\": 1542951687,\n    \"first_quarter\": 1539712949,\n    \"first_quarter_next\": 1542293669,\n    \"last_quarter\": 1541004147,\n    \"last_quarter_next\": 1543537278,\n    \"phase_name\": 0,\n    \"stage\": \"waxing\"\n}\n```\n\n----\nvijay@yoyo.org\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvijinho%2Fmoon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvijinho%2Fmoon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvijinho%2Fmoon/lists"}