suncalc icon indicating copy to clipboard operation
suncalc copied to clipboard

The values do not seem to be correct in different longitude

Open ghost opened this issue 6 years ago • 1 comments

I tested it through the following codes:

const suncalc=require('suncalc');

console.log(suncalc.getTimes(new Date(1971, 10, 27), 25.0, 119.0).sunrise); console.log(suncalc.getTimes(new Date(1971, 10, 27), 25.0, 120.0).sunrise); console.log(suncalc.getTimes(new Date(1971, 10, 27), 25.0, 121.0).sunrise); console.log(suncalc.getTimes(new Date(1971, 10, 27), 25.0, 122.0).sunrise);

The results are:

1971-11-25T22:29:44.251Z 1971-11-25T22:25:44.130Z 1971-11-26T22:22:27.438Z 1971-11-26T22:18:27.318Z

I think the date shouldn't be 11-25.

ghost avatar Jul 19 '18 22:07 ghost

Maybe the problem is in time zones. Test this: console.log(suncalc.getTimes(new Date(Date.UTC(1971, 10, 27)), 25.0, 119.0).sunrise); console.log(suncalc.getTimes(new Date(Date.UTC(1971, 10, 27)), 25.0, 120.0).sunrise); console.log(suncalc.getTimes(new Date(Date.UTC(1971, 10, 27)), 25.0, 121.0).sunrise); console.log(suncalc.getTimes(new Date(Date.UTC(1971, 10, 27)), 25.0, 122.0).sunrise);

aoizoijoizj avatar Aug 08 '18 15:08 aoizoijoizj