batoulapps / adhan-swift

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

User selectable calculation method? #76

Closed Babyyoda777 closed 1 year ago

Babyyoda777 commented 2 years ago

Is it possible to have this? This is my setup so far: `

func calculateTime()->Void{ let date = cal.dateComponents([.year, .month, .day], from: Date()) var params = CalculationMethod.moonsightingCommittee.params

    params.madhab = .hanafi
    params.adjustments.fajr = 3
    params.adjustments.sunrise = 2
    params.adjustments.dhuhr = 3
    params.adjustments.maghrib = -1
    params.adjustments.asr = 3
    params.adjustments.isha = 3
    if let prayers = PrayerTimes(coordinates: coordinates, date: date, calculationParameters: params) {
        let formatter = DateFormatter()
        formatter.timeStyle = .short
        formatter.timeZone = TimeZone(identifier: "Europe/London")!

        self.sunrise = formatter.string(from: prayers.sunrise)
        self.fajr = formatter.string(from: prayers.fajr)
        self.zuhr = formatter.string(from: prayers.dhuhr)
        self.asr = formatter.string(from: prayers.asr)
        self.maghrib = formatter.string(from: prayers.maghrib)
        self.isha = formatter.string(from: prayers.isha)
        if let currentPrayer = prayers.currentPrayer() {
            self.current = formatter.string(from: prayers.time(for: currentPrayer))
        } else {
            // if there's no current prayer then it means its between midnight and fajr.
            // It's up to you to decide how you want to handle this situation
            self.current = formatter.string(from: prayers.fajr)
        }
        if let nextPrayer = prayers.nextPrayer() {
            self.next = formatter.string(from: prayers.time(for: nextPrayer))
        } else {
            // if there's no current prayer then it means its between midnight and fajr.
            // It's up to you to decide how you want to handle this situation
            self.next = formatter.string(from: prayers.fajr)
        }

    }
}`
z3bi commented 1 year ago

@Babyyoda777 I don't understand the question, what are you asking?

Babyyoda777 commented 1 year ago

Oh sorry I should've closed this a long time ago, just ignore it lol