Skip to content

Commit

Permalink
Fixed bug: Set/Rise time can be more than 24 hours
Browse files Browse the repository at this point in the history
  • Loading branch information
Aliaksei-epam committed Oct 11, 2012
1 parent 68606bc commit 8529659
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions DayCalendar/DCDayInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,11 @@ + (RiseSetTimes)calculateSunWithGeoPoint2:(DCGeoPoint *)geoPoint{
times.rise =[riseComponents hour] + riseMinute / 60 + [geoPoint.timeZone secondsFromGMT] / SECONDS_IN_HOUR;
times.set = [setComponents hour] + setMinute / 60 + [geoPoint.timeZone secondsFromGMT] / SECONDS_IN_HOUR;

if (times.rise >= HOURS_IN_DAY)
times.rise -= HOURS_IN_DAY;
if (times.set >= HOURS_IN_DAY)
times.set -= HOURS_IN_DAY;

return times;
}

Expand Down
6 changes: 5 additions & 1 deletion DayCalendar/DCViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ - (NSDateComponents*)putDayInfo {
riseHour = floor(sunTimes.rise);
setHour = floor(sunTimes.set);

durationTime = sunTimes.set - sunTimes.rise;
if (setHour >= riseHour) {
durationTime = sunTimes.set - sunTimes.rise;
} else {
durationTime = MAGIC_NUMBER(24) - (sunTimes.rise - sunTimes.set);
}
durationHour = floor(durationTime);
}
NSString *timeInfoRise, *timeInfoSet;
Expand Down

0 comments on commit 8529659

Please sign in to comment.