Skip to content

Error in Minutes when Minutes 60 #8

@aqkhana2002

Description

@aqkhana2002
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)
}

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions