batoulapps / adhan-swift

High precision Islamic prayer time library for Swift
MIT License
185 stars 45 forks source link

Muslim World League way off for London, England #35

Closed basememara closed 4 years ago

basememara commented 4 years ago

It seems MWL doesn't work well with England. It's showing Isha is 1am and Fajr a few minutes later. I tried plugging it into a test and it shows a large variance for those 2 prayers:

{
    "params": {
        "latitude": 51.507194,
        "longitude": -0.116711,
        "timezone": "Europe/London",
        "method": "MuslimWorldLeague",
        "madhab": "Shafi",
        "highLatitudeRule": "MiddleOfTheNight"
    },
    "source": [
        "https://www.islamicfinder.org/world/united-kingdom/2643743/london-prayer-times/"
    ],
    "times": [
        {
            "date": "2020-05-29",
            "fajr": "2:28 AM",
            "sunrise": "4:50 AM",
            "dhuhr": "1:08 PM",
            "asr": "5:28 PM",
            "maghrib": "9:07 PM",
            "isha": "11:16 PM"
        }
    ]
}

Error:

XCTAssertLessThanOrEqual failed: ("89.0") is greater than ("0.0") - Fajr variance larger than accepted value of 0.0
XCTAssertLessThanOrEqual failed: ("1.0") is greater than ("0.0") - Sunrise variance larger than accepted value of 0.0
XCTAssertLessThanOrEqual failed: ("9.0") is greater than ("0.0") - Dhuhr variance larger than accepted value of 0.0
XCTAssertLessThanOrEqual failed: ("11.0") is greater than ("0.0") - Asr variance larger than accepted value of 0.0
XCTAssertLessThanOrEqual failed: ("2.0") is greater than ("0.0") - Maghrib variance larger than accepted value of 0.0
XCTAssertLessThanOrEqual failed: ("102.0") is greater than ("0.0") - Isha variance larger than accepted value of 0.0

The other calculations work fine for London, but wondering what could be making MWL not work well and if this was always a problem or a regression. I checked older date and they are also off with MWL.

z3bi commented 4 years ago

For locations above 50 degrees latitude you should use the high latitude rule of seventh of the night. This will keep fajr and Isha values from becoming too extreme during the summer.

basememara commented 4 years ago

Jazak’Allah Khair for the details. I feel like the library should give warnings somehow. It might tie in to auto suggesting calculation methods based on coordinates we’ve always wanted to do. Will give it some thought. Thanks again!