nathan-osman / go-sunrise

Go package for calculating the sunrise and sunset times for a given location
MIT License
141 stars 17 forks source link

Distinguish between continuous darkness / daylight #13

Open susannahameyer opened 3 weeks ago

susannahameyer commented 3 weeks ago

https://github.com/nathan-osman/go-sunrise/blob/master/sunrise.go#L26-L28

This currently returns Time{} for sunrise and sunset when either sunrise or sunset never occurs. Is there a way to represent if the sun never sets vs. never rises to know whether there's darkness or daylight?

Example using latitude 78.22240149999999, longitude 15.651782 for Svalbard.

DateTime: 2024-06-12T23:21:00Z Sunrise: 0001-01-01 00:00:00 +0000 UTC Sunset: 0001-01-01 00:00:00 +0000 UTC

DateTime: 2024-12-12T23:21:00Z Sunrise: 0001-01-01 00:00:00 +0000 UTC Sunset: 0001-01-01 00:00:00 +0000 UTC

elgohr commented 1 week ago

Could return nil, but this would break the interface See https://github.com/nathan-osman/go-sunrise/blob/master/sunrise_test.go#L39