Streamlined autoenable function a little.

This commit is contained in:
Mitchell Livingston 2006-08-11 23:18:56 +00:00
parent cc66511f98
commit e6d81110d9
3 changed files with 7 additions and 16 deletions

View File

@ -1266,23 +1266,14 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
== (offHour = [fDefaults integerForKey: @"SpeedLimitAutoOffHour"]))
return;
BOOL rangeForOn = onHour < offHour;
int min, max;
if (rangeForOn)
{
min = onHour;
max = offHour;
}
else
{
min = offHour;
max = onHour;
}
BOOL shouldBeOn;
int hour = [[NSCalendarDate calendarDate] hourOfDay];
BOOL inRange = hour >= min && hour < max;
if (onHour < offHour)
shouldBeOn = hour >= onHour && hour < offHour;
else
shouldBeOn = hour < offHour || hour >= onHour;
if ((!fSpeedLimitEnabled && (rangeForOn == inRange)) || (fSpeedLimitEnabled && (rangeForOn != inRange)))
if ((!fSpeedLimitEnabled && shouldBeOn) || (fSpeedLimitEnabled && !shouldBeOn))
{
[self toggleSpeedLimit: nil];

View File

@ -7,7 +7,7 @@
<key>IBEditorPositions</key>
<dict>
<key>153</key>
<string>119 348 584 311 0 0 1152 842 </string>
<string>285 423 582 311 0 0 1152 842 </string>
<key>28</key>
<string>58 372 582 290 0 0 1152 842 </string>
<key>41</key>