このコードセットをwp7に移植する方法
-(NSString *) timeSincePosted:(NSString *)ad_date {
if (!ad_date || ([ad_date compare:@""] == NSOrderedSame) || ([ad_date rangeOfString:@"-"].location == NSNotFound))
return @"";
// date format
//2010-04-22, 5:27PM EDT
NSDateFormatter *dateFormatter_CL = [[[NSDateFormatter alloc] init] autorelease];
NSLocale *enUSPOSIXLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease];
[dateFormatter_CL setLocale:enUSPOSIXLocale];
[dateFormatter_CL setDateFormat:@"yyyy-MM-dd, h:mma zzz"];
NSDate *CL_adDate = [dateFormatter_CL dateFromString: ad_date];
// Time since now
NSTimeInterval deltaT = -[CL_adDate timeIntervalSinceNow];
int deltaMin = deltaT/60;
int deltaHr = deltaMin/60;
int deltaDay = deltaHr/24;
if (deltaMin < 1) return [NSString stringWithString:@"0 mins"];
if (deltaMin == 1) return [NSString stringWithString:@"1 min"];
if (deltaMin < 60) return [NSString stringWithFormat:@"%d mins", deltaMin];
if (deltaHr <= 1) return [NSString stringWithString:@"1 hr"];
if (deltaHr < 24) return [NSString stringWithFormat:@"%d hrs", deltaHr];
if (deltaDay < 2) return [NSString stringWithString:@"1 day ago"];
return [NSString stringWithFormat:@"%d days ago", deltaDay];
}