Quote:
Originally Posted by yoav
looking good!
if you get stuck transcribing theGrundle's countdown logic i have it in 2 other languages, although i'm sure he's already got you covered... (theGrundle == godfather of katg apps)
|
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.
Code:
NSDate *eventTime = [formatter dateFromString: feedTime];
timeSince = [eventTime timeIntervalSinceNow];
match1 = [feedTitle rangeOfString:@"Live Show" options:NSCaseInsensitiveSearch].location != NSNotFound;
match2 = timeSince > 0;
feedEntryIndex = feedEntryIndex - 1;
}
int s = 0;
int m = 0;
int h = 0;
int d = 0;
int temp = timeSince;
if (timeSince > 60) {
s = timeSince % 60;
timeSince /= 60;
if (timeSince > 60) {
m = timeSince % 60;
timeSince /= 60;
if (timeSince > 24) {
h = timeSince % 24;
timeSince /= 24;
d = timeSince;
} else {
h = timeSince;
}
} else {
m = timeSince;
}
}
timeSince = temp;
days.text = [[NSString alloc] initWithFormat:@"%d",d];
hours.text = [[NSString alloc] initWithFormat:@"%d",h];
minutes.text = [[NSString alloc] initWithFormat:@"%d",m];