ashikahmad / PrayerTimes-Swift

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

Error in Minutes when Minutes 60 #8

Open aqkhana2002 opened 5 years ago

aqkhana2002 commented 5 years ago
func floatToHourMinute(_ time:Double)->(hours:Int, minutes:Int)? {
    if time.isNaN {
        return nil
    }

    let ttime = fixHour(time + 0.5 / 60.0)  // add 0.5 minutes to round
    var hours = Int(floor(time))
    var minutes = Int(floor((ttime - Double(hours)) * 60.0))
    return (hours: hours, minutes: minutes)
}

Change to : ` func floatToHourMinute(_ time:Double)->(hours:Int, minutes:Int)? { if time.isNaN { return nil }

    let ttime = fixHour(time + 0.5 / 60.0)  // add 0.5 minutes to round
    var hours = Int(floor(time))
    var minutes = Int(floor((ttime - Double(hours)) * 60.0))
    if (minutes>=60)
    {
        hours = hours + 1
        minutes=0
    }
    return (hours: hours, minutes: minutes)
}

`