Quote:
Originally Posted by hayroob
I just poll the events feed and search for a live show, that is in the future. Then I make a NSDate object out of it and ask for time since now. This is fairly snappy and doesn't get tripped up by time zones.
|
Why all the if/then? Wouldn't something like this work? assuming timeSince = total seconds
days = timeSince \ 86400
hours = (timeSince \ 3600) - (days * 24)
minutes = (timeSince \ 60) - (days * 1440) - (hours * 60)
seconds = timeSince Mod 60
I've also done it differently in .NET
Code:
Public Function formatSecs(ByVal sSeconds As Long) As String 'Converts seconds to 0:00
Dim tSpan As TimeSpan = New TimeSpan(0, 0, sSeconds)
Dim sDate As DateTime = New DateTime(tSpan.Ticks)
Return Int(tSpan.TotalHours) & sDate.ToString(":mm:ss")
End Function
Maybe you could do something similar with NSTimeDateFormatString
It just seems like a lot of code to me.