ashikahmad / PrayerTimes-Swift

Islamic Prayer (salah) Time calculation written in swift.
61 stars 21 forks source link

print prayer times for the next 5 days #4

Closed mohmando closed 5 years ago

mohmando commented 6 years ago

i just want to get the times for the next 5 days , problem that it print the same times every day so what should i do ?

for index in 0...5{
            let kit : AKPrayerTime =  AKPrayerTime(lat: locationCoord().0, lng:locationCoord().1)
            kit.calculationMethod = .Egypt
            kit.asrJuristic  = .Shafii
            kit.outputFormat = .Date
            let nextdate = Calendar.current.date(byAdding: .day, value: index, to: Date())
            kit.calcDate = nextdate
            let kitTimes = kit.getPrayerTimes()

            let Fajr = kitTimes![.Fajr]
            let Dhuhr = kitTimes![.Dhuhr]
            let Asr = kitTimes![.Asr]
            let Maghrib = kitTimes![.Maghrib]
            let Isha = kitTimes![.Isha]
            print(index)
            print("current: \(String(describing: nextdate!))")
            print("Fajr: \(Fajr!)")
            print("Dhuhr: \(Dhuhr!)")
            print("Asr: \(Asr!)")
            print("Maghrib: \(Maghrib!)")
            print("Isha: \(Isha!)")
            print("-----------------------------------")
}
mohmando commented 6 years ago

i think i found a soulution by using

   let nextdate = Calendar.current.date(byAdding: .day, value: index, to: Date())
            kit.calcDate = nextdate
            let dayInt = Calendar.current.component(.day, from: nextdate!)
            let monthInt = Calendar.current.component(.month, from: nextdate!)
            let yearInt = Calendar.current.component(.year, from: nextdate!)

            let kitTimes = kit.getDatePrayerTimes(year: yearInt, month: monthInt, day: dayInt, latitude: locationCoord().0, longitude: locationCoord().1, tZone: 2)