/sunrise

Simple JavaScript module which may be used to calculates sunrise and sunset time (UTC) in given place at given date.

Primary LanguageJavaScript

Sunrise

It's simple JavaScript module which may be used to sunrise and sunset time calculation in given place.

Todolist:

  • add google maps visualization / location selection
  • calculate altitude of sun at given time

Usage:

var sunriser = sunrise();
sunriser.
    setDate(new Date(Date.UTC(2012, 2, 18))).
    setLocation({"latitude":{d:50, m:3, s:41}, "longitude":{d:19, m:56, s:18}});
sunriser.getTimes();
/* results in:
{ rise: { h: 4, m: 46, s: 14.699580737564247 },
  set: { h: 16, m: 50, s: 8.266904495882045 },
  daytime: { h: 12, m: 3, s: 53.5673237583178 } }
*/

Calculations based on:

  1. http://www.navipedia.pl/,

Tests created in Jasmine (http://pivotal.github.com/jasmine/).