|
|
@ -126,64 +126,6 @@ |
|
|
|
return menuTitle; |
|
|
|
return menuTitle; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
- (NSString *)compareSystemDate:(NSString *)systemDate toTimezoneDate:(NSString *)date |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
NSDateFormatter *localFormatter = [NSDateFormatter new]; |
|
|
|
|
|
|
|
localFormatter.timeStyle = NSDateFormatterMediumStyle; |
|
|
|
|
|
|
|
localFormatter.dateStyle = NSDateFormatterMediumStyle; |
|
|
|
|
|
|
|
localFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NSDate *localDate = [localFormatter dateFromString:systemDate]; |
|
|
|
|
|
|
|
NSDate *timezoneDate = [localFormatter dateFromString:date]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Specify which units we would like to use |
|
|
|
|
|
|
|
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; |
|
|
|
|
|
|
|
NSInteger weekday = [calendar component:NSCalendarUnitWeekday fromDate:localDate]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NSInteger timezoneWeekday = [calendar component:NSCalendarUnitWeekday fromDate:timezoneDate]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ([self.dataObject.nextUpdate isKindOfClass:[NSString class]]) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NSUInteger units = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay; |
|
|
|
|
|
|
|
NSDateComponents *comps = [[NSCalendar currentCalendar] components:units fromDate:timezoneDate]; |
|
|
|
|
|
|
|
comps.day = comps.day + 1; |
|
|
|
|
|
|
|
NSDate *tomorrowMidnight = [[NSCalendar currentCalendar] dateFromComponents:comps]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NSDictionary *dictionary = @{CLTimezoneID : self.dataObject.timezoneID, @"latitude" : self.dataObject.latitude, |
|
|
|
|
|
|
|
@"longitude" : self.dataObject.longitude, CLCustomLabel : self.dataObject.customLabel, |
|
|
|
|
|
|
|
CLPlaceIdentifier : self.dataObject.place_id, CLTimezoneName : self.dataObject.formattedAddress}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CLTimezoneData *newDataObject = [[CLTimezoneData alloc] initWithDictionary:dictionary]; |
|
|
|
|
|
|
|
[newDataObject setNextUpdateForSunriseSet:tomorrowMidnight]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PanelController *panelController = [PanelController getPanelControllerInstance]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(panelController.defaultPreferences)[[panelController.defaultPreferences indexOfObject:self]] = newDataObject; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:panelController.defaultPreferences forKey:CLDefaultPreferenceKey]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NSInteger daysApart = [timezoneDate daysFrom:localDate]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (daysApart == 0) { |
|
|
|
|
|
|
|
return @"Today"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (daysApart == -1) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return @"Yesterday"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (daysApart == 1) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return @"Tomorrow"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return [self getWeekdayFromInteger:weekday+2]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (NSString *)getDateForTimeZoneWithFutureSliderValue:(NSInteger)futureSliderValue |
|
|
|
- (NSString *)getDateForTimeZoneWithFutureSliderValue:(NSInteger)futureSliderValue |
|
|
|
andDisplayType:(CLDateDisplayType)type |
|
|
|
andDisplayType:(CLDateDisplayType)type |
|
|
|
{ |
|
|
|
{ |
|
|
|