From ef4049fefe2f4c3a2f063a2f7e303bfee17c2498 Mon Sep 17 00:00:00 2001 From: Abhishek Banthia Date: Sun, 15 May 2016 13:04:55 -0400 Subject: [PATCH] Sunset/Sunrise Boundary Check. --- .../CLFloatingWindowController.m | 6 ++++-- .../en.lproj/CLFloatingWindow.xib | 5 ++--- .../ja.lproj/CLFloatingWindow.xib | 5 ++--- .../zh-Hans.lproj/CLFloatingWindow.xib | 5 ++--- .../zh-Hant.lproj/CLFloatingWindow.xib | 5 ++--- Clocker/Model/CLTimezoneData.m | 11 ++++++++--- Clocker/PanelController.m | 6 ++++-- Clocker/en.lproj/Panel.xib | 17 ++++++++--------- Clocker/zh-Hans.lproj/Panel.xib | 5 ++--- Clocker/zh-Hant.lproj/Panel.xib | 5 ++--- 10 files changed, 36 insertions(+), 34 deletions(-) diff --git a/Clocker/Floating Window/CLFloatingWindowController.m b/Clocker/Floating Window/CLFloatingWindowController.m index 1a90987..5865fc4 100644 --- a/Clocker/Floating Window/CLFloatingWindowController.m +++ b/Clocker/Floating Window/CLFloatingWindowController.m @@ -155,12 +155,14 @@ NSString *const CLTimezoneCellIdentifier = @"timeZoneCell"; NSNumber *displaySunriseSunsetTime = [[NSUserDefaults standardUserDefaults] objectForKey:CLSunriseSunsetTime]; - cell.sunriseSetTime.hidden = [displaySunriseSunsetTime isEqualToNumber:@(1)] ? YES : NO; + cell.sunriseSetTime.hidden = ([displaySunriseSunsetTime isEqualToNumber:@(0)] && cell.sunriseSetTime.stringValue.length > 0) ? NO : YES; - cell.sunriseSetImage.hidden = [displaySunriseSunsetTime isEqualToNumber:@(1)] ? YES : NO; + cell.sunriseSetImage.hidden = [displaySunriseSunsetTime isEqualToNumber:@(0)] && cell.sunriseSetTime.stringValue.length > 0 ? NO : YES; [cell setUpAutoLayoutWithCell:cell]; + [cell setAppropriateFont]; + return cell; } diff --git a/Clocker/Floating Window/en.lproj/CLFloatingWindow.xib b/Clocker/Floating Window/en.lproj/CLFloatingWindow.xib index 1c2c105..7f1b6c6 100644 --- a/Clocker/Floating Window/en.lproj/CLFloatingWindow.xib +++ b/Clocker/Floating Window/en.lproj/CLFloatingWindow.xib @@ -63,7 +63,7 @@ - + @@ -71,7 +71,7 @@ - + @@ -290,6 +290,5 @@ - diff --git a/Clocker/Floating Window/ja.lproj/CLFloatingWindow.xib b/Clocker/Floating Window/ja.lproj/CLFloatingWindow.xib index 273c63b..1544e71 100644 --- a/Clocker/Floating Window/ja.lproj/CLFloatingWindow.xib +++ b/Clocker/Floating Window/ja.lproj/CLFloatingWindow.xib @@ -63,7 +63,7 @@ - + @@ -71,7 +71,7 @@ - + @@ -289,6 +289,5 @@ - diff --git a/Clocker/Floating Window/zh-Hans.lproj/CLFloatingWindow.xib b/Clocker/Floating Window/zh-Hans.lproj/CLFloatingWindow.xib index 9f53201..17f1b9a 100644 --- a/Clocker/Floating Window/zh-Hans.lproj/CLFloatingWindow.xib +++ b/Clocker/Floating Window/zh-Hans.lproj/CLFloatingWindow.xib @@ -78,7 +78,7 @@ - + @@ -86,7 +86,7 @@ - + @@ -289,6 +289,5 @@ - diff --git a/Clocker/Floating Window/zh-Hant.lproj/CLFloatingWindow.xib b/Clocker/Floating Window/zh-Hant.lproj/CLFloatingWindow.xib index d08306d..6f4acc7 100644 --- a/Clocker/Floating Window/zh-Hant.lproj/CLFloatingWindow.xib +++ b/Clocker/Floating Window/zh-Hant.lproj/CLFloatingWindow.xib @@ -79,7 +79,7 @@ - + @@ -87,7 +87,7 @@ - + @@ -290,6 +290,5 @@ - diff --git a/Clocker/Model/CLTimezoneData.m b/Clocker/Model/CLTimezoneData.m index 690f446..7787466 100644 --- a/Clocker/Model/CLTimezoneData.m +++ b/Clocker/Model/CLTimezoneData.m @@ -174,7 +174,9 @@ -(void)initializeSunriseSunset { - EDSunriseSet *sunriseSetObject = [EDSunriseSet sunrisesetWithDate:[NSDate date] timezone:[NSTimeZone timeZoneWithName:self.timezoneID] latitude:self.latitude.doubleValue longitude:self.longitude.doubleValue]; + EDSunriseSet *sunriseSetObject = [EDSunriseSet sunrisesetWithDate:[NSDate date] + timezone:[NSTimeZone timeZoneWithName:self.timezoneID] + latitude:self.latitude.doubleValue longitude:self.longitude.doubleValue]; self.sunriseTime = sunriseSetObject.sunrise; self.sunsetTime = sunriseSetObject.sunset; } @@ -388,6 +390,11 @@ { [self initializeSunriseSunset]; + if (!self.sunriseTime && !self.sunsetTime) + { + return CLEmptyString; + } + NSString *timezoneDate = [self getFullFledgedDateForTime]; NSDateFormatter *formatter = [NSDateFormatter new]; @@ -435,8 +442,6 @@ [dateFormatter setDateFormat:@"yyyy-MM-dd hh:mm a"]; - dateFormatter.timeZone = [NSTimeZone timeZoneWithName:self.timezoneID]; - return [dateFormatter stringFromDate:newDate]; } diff --git a/Clocker/PanelController.m b/Clocker/PanelController.m index c37e2fb..78a8ac8 100755 --- a/Clocker/PanelController.m +++ b/Clocker/PanelController.m @@ -328,12 +328,14 @@ static PanelController *sharedPanel = nil; NSNumber *displaySunriseSunsetTime = [[NSUserDefaults standardUserDefaults] objectForKey:CLSunriseSunsetTime]; - cell.sunriseSetTime.hidden = [displaySunriseSunsetTime isEqualToNumber:@(1)] ? YES : NO; + cell.sunriseSetTime.hidden = ([displaySunriseSunsetTime isEqualToNumber:@(0)] && cell.sunriseSetTime.stringValue.length > 0) ? NO : YES; - cell.sunriseSetImage.hidden = [displaySunriseSunsetTime isEqualToNumber:@(1)] ? YES : NO; + cell.sunriseSetImage.hidden = [displaySunriseSunsetTime isEqualToNumber:@(0)] && cell.sunriseSetTime.stringValue.length > 0 ? NO : YES; [cell setUpAutoLayoutWithCell:cell]; + [cell setAppropriateFont]; + return cell; } diff --git a/Clocker/en.lproj/Panel.xib b/Clocker/en.lproj/Panel.xib index 773179c..b009062 100755 --- a/Clocker/en.lproj/Panel.xib +++ b/Clocker/en.lproj/Panel.xib @@ -85,7 +85,7 @@ - + @@ -97,20 +97,20 @@ - + - + - + - + @@ -123,10 +123,10 @@ - - + + - + @@ -290,6 +290,5 @@ - diff --git a/Clocker/zh-Hans.lproj/Panel.xib b/Clocker/zh-Hans.lproj/Panel.xib index 124425e..3c1e981 100755 --- a/Clocker/zh-Hans.lproj/Panel.xib +++ b/Clocker/zh-Hans.lproj/Panel.xib @@ -78,7 +78,7 @@ - + @@ -86,7 +86,7 @@ - + @@ -290,6 +290,5 @@ - diff --git a/Clocker/zh-Hant.lproj/Panel.xib b/Clocker/zh-Hant.lproj/Panel.xib index da3ea35..838afbd 100755 --- a/Clocker/zh-Hant.lproj/Panel.xib +++ b/Clocker/zh-Hant.lproj/Panel.xib @@ -78,7 +78,7 @@ - + @@ -86,7 +86,7 @@ - + @@ -290,6 +290,5 @@ -