mourner / suncalc

A tiny JavaScript library for calculating sun/moon positions and phases.
BSD 2-Clause "Simplified" License
3.08k stars 412 forks source link

moonTimes tests fail #40

Closed esemwy closed 8 years ago

esemwy commented 9 years ago

Tests 23 and 24 fail.

getMoonTimes returns moon rise and set times

not ok 23 should be equal


operator: equal
expected: 'Mon, 04 Mar 2013 23:57:55 GMT'
actual:   'Mon, 04 Mar 2013 23:57:52 GMT'
at: Test.<anonymous> (/devel/suncalc/test.js:68:7)

... not ok 24 should be equal


operator: equal
expected: 'Tue, 05 Mar 2013 08:41:31 GMT'
actual:   'Mon, 04 Mar 2013 07:19:22 GMT'
at: Test.<anonymous> (/devel/suncalc/test.js:69:7)

...

mourner commented 9 years ago

Right, will look into it.

Broham commented 9 years ago

+1

ywadi commented 8 years ago

I assume the issue is from here The new Date creates a new date to your Local device (ex: GMT+4) Then sets it to Zero so its Zero on local time not UTC, could be wrong responses.

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

mourner commented 8 years ago

@ywadi great find! I'll looking into fixing this tomorrow if confirmed.

mourner commented 8 years ago

Fixed.