Skip to content

Commit

Permalink
attempt to fix moon test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Nov 11, 2015
1 parent 062226f commit 5eb3348
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 1 addition & 4 deletions suncalc.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,7 @@ function hoursLater(date, h) {

SunCalc.getMoonTimes = function (date, lat, lng) {
var t = new Date(date);
t.setHours(0);
t.setMinutes(0);
t.setSeconds(0);
t.setMilliseconds(0);
t.setHours(0, 0, 0, 0);

var hc = 0.133 * rad,
h0 = SunCalc.getMoonPosition(t, lat, lng).altitude - hc,
Expand Down
7 changes: 6 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ t.test('getMoonIllumination returns fraction and angle of moon\'s illuminated li
});

t.test('getMoonTimes returns moon rise and set times', function (t) {
var moonTimes = SunCalc.getMoonTimes(date, lat, lng);
var date2 = new Date(date);
date2.setHours(0, 0, 0, 0);
if (date2.getDate() !== date.getDate()) date2.setDate(date.getDate());

var moonTimes = SunCalc.getMoonTimes(date2, lat, lng);

t.equal(moonTimes.rise.toUTCString(), 'Mon, 04 Mar 2013 23:57:55 GMT');
t.equal(moonTimes.set.toUTCString(), 'Tue, 05 Mar 2013 08:41:31 GMT');

t.end();
});

0 comments on commit 5eb3348

Please sign in to comment.