suncalc icon indicating copy to clipboard operation
suncalc copied to clipboard

night and nightEnd

Open scargill opened this issue 7 years ago • 3 comments

Hi

I'm having an issue with suncalc.. I use it all the time in my node-red bigtimer and node-red requires version 1.x but isn't more fussy than that. I just had someone on saying that night and nightEnd don't work. I tried and while sunset, sunrise etc are fine, night and nightEnd sure enough return null. I'm guessing this is new (ish). Can you advise?

Regards

Pete

scargill avatar May 30 '18 10:05 scargill

I can confirm night, nightEndreturns Invalid Date of Berlin/Germany at lat 52.520008, lon 13.404954. It seems to work for other coordinates though. I have tried Ho Chi Minh/Vietnam which worked for me.

{ solarNoon: Thu Jun 07 2018 13:06:38 GMT+0200 (Mitteleuropäische Sommerzeit),
  nadir: Thu Jun 07 2018 01:06:38 GMT+0200 (Mitteleuropäische Sommerzeit),
  sunrise: Thu Jun 07 2018 04:46:55 GMT+0200 (Mitteleuropäische Sommerzeit),
  sunset: Thu Jun 07 2018 21:26:20 GMT+0200 (Mitteleuropäische Sommerzeit),
  sunriseEnd: Thu Jun 07 2018 04:51:31 GMT+0200 (Mitteleuropäische Sommerzeit),
  sunsetStart: Thu Jun 07 2018 21:21:44 GMT+0200 (Mitteleuropäische Sommerzeit),
  dawn: Thu Jun 07 2018 03:58:07 GMT+0200 (Mitteleuropäische Sommerzeit),
  dusk: Thu Jun 07 2018 22:15:09 GMT+0200 (Mitteleuropäische Sommerzeit),
  nauticalDawn: Thu Jun 07 2018 02:40:36 GMT+0200 (Mitteleuropäische Sommerzeit),
  nauticalDusk: Thu Jun 07 2018 23:32:40 GMT+0200 (Mitteleuropäische Sommerzeit),
  nightEnd: Invalid Date,
  night: Invalid Date,
  goldenHourEnd: Thu Jun 07 2018 05:42:08 GMT+0200 (Mitteleuropäische Sommerzeit),
  goldenHour: Thu Jun 07 2018 20:31:07 GMT+0200 (Mitteleuropäische Sommerzeit) } 

mwittig avatar Jun 07 '18 13:06 mwittig

I should scrap it as there are several places it does not work. Dust, dawn, sunrise, sunset work just fine

On 7 June 2018 14:01:40 Marcus Wittig [email protected] wrote:

I can confirm night, nightEndreturns Invalid Date of Berlin/Germany at lat 52.520008, lon 13.404954 { solarNoon: Thu Jun 07 2018 13:06:38 GMT+0200 (Mitteleuropäische Sommerzeit), nadir: Thu Jun 07 2018 01:06:38 GMT+0200 (Mitteleuropäische Sommerzeit), sunrise: Thu Jun 07 2018 04:46:55 GMT+0200 (Mitteleuropäische Sommerzeit), sunset: Thu Jun 07 2018 21:26:20 GMT+0200 (Mitteleuropäische Sommerzeit), sunriseEnd: Thu Jun 07 2018 04:51:31 GMT+0200 (Mitteleuropäische Sommerzeit), sunsetStart: Thu Jun 07 2018 21:21:44 GMT+0200 (Mitteleuropäische Sommerzeit), dawn: Thu Jun 07 2018 03:58:07 GMT+0200 (Mitteleuropäische Sommerzeit), dusk: Thu Jun 07 2018 22:15:09 GMT+0200 (Mitteleuropäische Sommerzeit), nauticalDawn: Thu Jun 07 2018 02:40:36 GMT+0200 (Mitteleuropäische Sommerzeit), nauticalDusk: Thu Jun 07 2018 23:32:40 GMT+0200 (Mitteleuropäische Sommerzeit), nightEnd: Invalid Date, night: Invalid Date, goldenHourEnd: Thu Jun 07 2018 05:42:08 GMT+0200 (Mitteleuropäische Sommerzeit), goldenHour: Thu Jun 07 2018 20:31:07 GMT+0200 (Mitteleuropäische Sommerzeit) } — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

scargill avatar Jun 07 '18 15:06 scargill

Well, it depends on where you are. Like in polar regions, they sometimes have day (or night) for weeks at a time. This is basically not an error but how lighting works on Earth ;-)

I modified mine to calculate a little better and have it return "null" for times that are currently not applicable. Here is a more visual example for some place in Finland, right now:

Finland 2018-06-09

As you can see, they only just reach civil twilight, so no data for blue hour, nautical twilight, astronomical twilight or night.

Moonbase59 avatar Jun 09 '18 11:06 Moonbase59