Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- + (NSDate *)localDateForEventDate:(NSDate *)eventDate
- {
- NSTimeZone *pacificTimeZone = [NSTimeZone timeZoneWithName:@"America/Los_Angeles"];
- NSCalendar *pacificCalendar = [NSCalendar currentCalendar];
- [pacificCalendar setTimeZone:pacificTimeZone];
- unsigned int unitFlags = NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit|NSHourCalendarUnit|NSMinuteCalendarUnit|NSSecondCalendarUnit;
- NSDateComponents *eventDateComponents = [pacificCalendar components:unitFlags fromDate:eventDate];
- NSCalendar *localCalendar = [NSCalendar currentCalendar];
- [localCalendar setTimeZone:[NSTimeZone systemTimeZone]];
- NSDate *localDate = [localCalendar dateFromComponents:eventDateComponents];
- return localDate;
- }
Add Comment
Please, Sign In to add comment