iphone에서 NSDate를 입력하고 그날의 요일을 얻어 오는 간단한 프로그램.
흐~ 생각보다 쉽넹~
// return DayofWeek with indate of offset
-(NSString *)findDayofWeek:(NSDate*)inDate offsetDays:(NSInteger)offs{
NSDate *calDate = [[NSDate alloc] initWithTimeInterval:(offs*60*60*24) sinceDate:inDate];
NSLog(@"calDate = %@",calDate);
NSDateFormatter *df = [[[NSDateFormatter alloc] init] autorelease];
[df setDateFormat:@"yyyy-MM-dd HH:mm:ss zzzz"];
[df setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
[df setDateFormat:@"EEEE"];
[df setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]];
NSString *dayofweek = [[df stringFromDate:calDate] substringToIndex:2];
NSLog(@"%@", dayofweek);
return [dayofweek uppercaseString];
}
흐~ 생각보다 쉽넹~