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.
SunCalc was ported to Haxe by Robin ypid
Schneider to allow using it in a planed rewrite of the opening hours library.
It is based on the JavaScript implementation created by Vladimir Agafonkin (@mourner) as a part of the SunCalc.net project.
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.
Refer to the API documentation for details.
Install the library for your favorite language by executing one of the following commands:
haxelib install suncalc # Haxe
npm install suncalc # JavaScript/Node.JS
composer require ypid/suncalc # PHP
- C++
- Haxe
- Java (native port repository)
- JavaScript/Node.JS (native port repository)
- NekoVM
- PHP (target build repository)
- Python (native port repository)
- Go (native port repository)
- Objective-C (native port repository)
- Swift (native port repository)
The following limitations seems to be related which should mean that when they are fixed for one target, the tests for the other targets should also pass. If you need SunCalc.getMoonTimes
for one of those targets, feel free to debug it further.
- Python:
SunCalc.getMoonTimes
(rise
date can not be calculated.). - C++:
SunCalc.getMoonTimes
(segmentation fault
). - Java:
SunCalc.getMoonTimes
(java.lang.NullPointerException
). - Neko:
SunCalc.getMoonTimes
- ActionScript 3: Does compile but I have no idea how to test it.
- Flash: Does compile but I have no idea how to test it.
-
C#: Dependency
datetime
does not compile on target "datetime/3,0,2/src/datetime/DateTime.hx:146: characters 28-110 : haxe.Int64 should be Float"Priority low.