robc (owner)

Revisions

gist: 217538 Download_button fork
public
Public Clone URL: git://gist.github.com/217538.git
Embed All Files: show embed
FBDateConversionUtilities.m #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
+ (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;
}