batoulapps / adhan-swift

High precision Islamic prayer time library for Swift
MIT License
182 stars 42 forks source link

SolarTime cannot be calculated for extreme north locations (i.e., Norway) #73

Closed basememara closed 1 year ago

basememara commented 2 years ago

Prayer times cannot be calculated for Norway this time of year since SolarTime returns nil:

let coordinates = Coordinates(latitude: 70.5308, longitude: 23.5717)
let solarTime = SolarTime(date: date(year: 2022, month: 7, day: 19, hours: 0), coordinates: coordinates)
// solarTime == nil

The angles in Astronomical.correctedHourAngle are returning NaN for this scenario. Any idea on how to accommodate these extreme north scenarios?

z3bi commented 2 years ago

This is currently expected as nil indicates that the location has no sunset/sunrise for that day which can happen inside the polar circle near the solstices (see https://en.wikipedia.org/wiki/Polar_circle). We have opened issue #45 to address this. This feature was added to the JS library, its turning out to be slightly more complicated in Swift due to the way some of the data structures are setup.