Changeset 588


Ignore:
Timestamp:
09/20/09 21:08:24 (15 years ago)
Author:
Nicholas Riley
Message:

If date is today and we've picked a time before now, set the date to tomorrow. (Pester for hiptop did this too.)

Location:
trunk/Cocoa/Pester
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cocoa/Pester/Source/PSAlarmSetController.m

    r587 r588  
    588588// called because we're the delegate
    589589
     590- (void)controlTextDidEndEditing:(NSNotification *)notification;
     591{
     592    if ([notification object] != timeOfDay)
     593        return;
     594
     595    // if date is today and we've picked a time before now, set the date for tomorrow
     596    NSDate *dateTime = [NSCalendarDate dateWithDate: [timeDate objectValue] atTime: [timeOfDay objectValue]];
     597    if (dateTime == nil)
     598        return;
     599
     600    NSDate *now = [NSDate date];
     601    NSCalendarDate *today = [NSCalendarDate dateForDay: now];
     602    NSCalendarDate *date = [NSCalendarDate dateForDay: [timeDate objectValue]];
     603    if (![date isEqualToDate: today] || [dateTime compare: now] != NSOrderedAscending)
     604        return;
     605
     606    [timeDate setObjectValue: [today dateByAddingYears: 0 months: 0 days: 1 hours: 0 minutes: 0 seconds: 0]];
     607    [self update: timeOfDay];
     608}
     609
    590610- (void)controlTextDidChange:(NSNotification *)notification;
    591611{
Note: See TracChangeset for help on using the changeset viewer.