Skip to content
/ suncalc Public

A Haxe library for calculating sun/moon positions and phases. Targets a variety of programming languages/platforms.

License

Notifications You must be signed in to change notification settings

ypid/suncalc

Repository files navigation

suncalc

Build Status BSD licensed haxelib version NPM version Packagist version

GitHub stars GitHub forks GitHub watchers GitHub open issues GitHub closed issues GitHub open pull requests GitHub closed pull requests

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

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

Supported languages/platforms

Supported languages/platforms not generated by Haxe

Limitations

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

Unsure/untested

  • 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.

Unsupported

  • 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.

License

BSD-2-Clause

About

A Haxe library for calculating sun/moon positions and phases. Targets a variety of programming languages/platforms.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published