suncalc
, (*1)
, (*2)
, (*3)
The SunCalc module allows to calculate sun position,
sunlight phases (times for sunrise, sunset, dusk, etc.),
moon position and lunar phase for the given location and time., (*4)
SunCalc was ported to Haxe by Robin ypid Schneider to allow using it in a planed rewrite of the opening hours library., (*5)
It is based on the JavaScript implementation
created by Vladimir Agafonkin (@mourner)
as a part of the SunCalc.net project., (*6)
Most calculations are based on the formulas given in the excellent Astronomy Answers articles
about position of the sun
and the planets.
You can read about different twilight phases calculated by SunCalc
in the Twilight article on Wikipedia., (*7)
Refer to the API documentation for details., (*8)
Install
Install the library for your favorite language by executing one of the following commands:, (*9)
haxelib install suncalc # Haxe
npm install suncalc # JavaScript/Node.JS
composer require ypid/suncalc # PHP
Getting started
Check out the following example to get started., (*10)
## Needed when executed in the root of this repository.
require_once __DIR__ . '/lib/php/Boot.class.php';
## Needed when installed via composer. FIXME
# require_once __DIR__ . '/vendor/ypid/suncalc/lib/php/Boot.class.php';
echo suncalc_SunCalc::getMoonIllumination(new Date(2000, 1, 1, 0, 0, 0));
TODO
Maintainer/tester with PHP knowledge wanted :wink:, (*11)
Composer does provide a autoload feature which is currently not used.
My experience with PHP is very limited which is the reason I wrote in Haxe and
generated this PHP target only because all unit tests for PHP passed. If you
know how to properly support the autoload feature for this library, I will be
happy to integrate it., (*12)
Internals
This library was automatically build using Haxe to target PHP., (*13)
Refer to https://github.com/ypid/suncalc when you want to contribute. Note that you should only report issues against the PHP target repository when you think the issue only occurs in the PHP port of this library. If you are unsure, report against the source repository instead., (*14)
Unit testing
Unit testing is done against the source repository in Haxe,
as well as against each transcompile target (PHP in this
case). You can check them out in the source repository., (*15)
Maintainer
License
BSD-2-Clause, (*16)