View Single Post
Old 05-22-2009, 10:11 PM   #367 (permalink)
TheGrundle
Senior Member
 
TheGrundle's Avatar
 
Join Date: Jun 2006
Location: New Orleans
Posts: 748
Quote:
Originally Posted by hayroob View Post
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.

Last edited by TheGrundle; 05-22-2009 at 10:13 PM.
(Offline)   Reply With Quote