suncalc icon indicating copy to clipboard operation
suncalc copied to clipboard

SunCalc.getMoonTimes returns undefined when today's moon rise was yesterday

Open leonidhtc opened this issue 3 years ago • 1 comments

https://github.com/mourner/suncalc/blob/6bc2757074c1e5eaa2389aa2ab36806f04c6d2a0/suncalc.js#L303 Today Thu Nov 17 2022 21:23:39 GMT+0300 (Moscow Standard Time) in Moscow lat = 55.8215625, lng = 37.3774375 the function SunCalc.getMoonTimes returns undefined because rise = undefined. Today's moon rise was yesterday. See the screenshot. rise-undefined

leonidhtc avatar Nov 17 '22 18:11 leonidhtc

Types also miss to reflect this, either rise or set attributes may be missing if it happens on another day:

export interface GetMoonTimes {
    rise: Date; // actually optional
    set: Date; // actually optional
    alwaysUp?: true;
    alwaysDown?: true;
}

Example:

10.7.2024 12:00 Berlin/Europe { rise: 2024-07-10T08:11:47.515Z }

But the next day, I find the alignment I'm looking for?:

11.7.2024 12:00 Berlin/Europe { rise: 2024-07-11T09:19:42.301Z, set: 2024-07-10T22:01:34.456Z }

Sunset: 11.7.2024, 21:30:20 Moonset: 11.7.2024, 00:01:34

I should get the moonset in the first query for the 10th, why not?

Phoscur avatar Jun 11 '24 18:06 Phoscur