8000 Automatic Adjust For Prayer Times Settings · Issue #41 · batoulapps/adhan-swift · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Automatic Adjust For Prayer Times Settings #41
Open
@iTarek

Description

@iTarek

I know that you have plan to include automatic adjust for prayer times, and right now I am working on update for Ela-Salaty and I will use adhan-swift for that...

I already have database with all countries I converted it to json and added adhan-swift paramters...
Please check the json here...

https://www.dropbox.com/s/52kcom2vg1cagq4/Countries.json?dl=1

I use this func to get prayer settings for a country iso

struct Countries: Decodable {
    let ISO: String
    let Madhab: Int
    let Method: String
    let HighLatitudeRule: String
}

 static func getPrayerSettingsForCountry(iso: String) -> Countries {
        let decoder = JSONDecoder()
        guard
            let url = Bundle.main.url(forResource: "Countries", withExtension: "json"),
            let data = try? Data(contentsOf: url),
            let countries: [Countries] = try? decoder.decode([Countries].self, from: data),
            let index = countries.firstIndex(where: { $0.ISO == iso })
        else {
            return (Countries(ISO: iso, Madhab: 1, Method: "muslimWorldLeague", HighLatitudeRule: "middleOfTheNight"))
        }
        
        return countries[index]
    }

I don't know if this good enough for you, or you have a better solution, but I thought I should share this anyway it could be seed to smothing bigger.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0