Changeset 113 for trunk/Cocoa/Pester/Source/PSAlarm.m
- Timestamp:
- 03/10/03 05:48:21 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/Pester/Source/PSAlarm.m
r105 r113 32 32 static NSDictionary *locale; 33 33 34 // XXX need to reset pending alarms after sleep, they "freeze" and never expire.35 36 34 @implementation PSAlarm 37 35 … … 137 135 if (interval == 0) return nil; 138 136 if (interval < minute) return [NSString stringWithFormat: @"%us", (unsigned)interval]; 137 if (interval < hour) return [NSString stringWithFormat: @"%um", (unsigned)(interval / minute)]; 139 138 if (interval < day) return [NSString stringWithFormat: @"%uh %um", (unsigned)(interval / hour), (unsigned)((interval % hour) / minute)]; 140 139 if (interval < 2 * day) return @"One day"; … … 399 398 { 400 399 [timer invalidate]; [timer release]; timer = nil; 401 [self setRepeating: NO]; 400 } 401 402 - (void)resetTimer; 403 { 404 if (timer != nil || alarmType != PSAlarmSet) 405 return; 406 407 alarmType = PSAlarmDate; 408 if (![self isRepeating]) { 409 [self setTimer]; 410 } else { 411 // don't want to put this logic in setTimer or isValid because it can cause invalid alarms to be set (consider when someone clicks the "repeat" checkbox, then switches to a [nonrepeating, by design] date alarm, and enters a date that has passed: we do -not- want the alarm to magically morph into a repeating interval alarm) 412 NSTimeInterval savedInterval = alarmInterval; 413 if (![self setTimer]) { 414 alarmType = PSAlarmInterval; 415 [self setInterval: savedInterval]; 416 [self setTimer]; 417 } 418 } 402 419 } 403 420 … … 489 506 [self setAlerts: alarmAlerts]; 490 507 [alarmAlerts release]; 491 if (alarmType == PSAlarmSet) { 492 alarmType = PSAlarmDate; 493 // don't want to put this logic in setTimer or isValid because it can cause invalid alarms to be set (consider when someone clicks the "repeat" checkbox, then switches to a [nonrepeating, by design] date alarm, and enters a date that has passed: we do -not- want the alarm to magically morph into a repeating interval alarm) 494 if (![self setTimer] && [self isRepeating]) { 495 alarmType = PSAlarmInterval; 496 [self setInterval: [[dict objectForRequiredKey: PLAlarmInterval] doubleValue]]; 497 [self setTimer]; 498 } 499 } 508 [self resetTimer]; 500 509 if (alarmType == PSAlarmExpired) { 501 510 [self setTimer];
Note:
See TracChangeset
for help on using the changeset viewer.