Changeset 6225


Ignore:
Timestamp:
Jun 19, 2008, 3:23:50 AM (13 years ago)
Author:
livings124
Message:

start removal of NSCalendarDate, as recommended by Apple in the 10.5 docs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r6223 r6225  
    23812381}
    23822382
     2383//only called from fSpeedLimitTimer
    23832384- (void) autoSpeedLimit: (NSTimer *) timer
    23842385{
     
    24142415- (void) setAutoSpeedLimitTimer: (BOOL) nextIsOn
    24152416{
    2416     NSCalendarDate * timerDate = [NSCalendarDate dateWithTimeIntervalSinceReferenceDate: [[fDefaults objectForKey:
    2417                                     nextIsOn ? @"SpeedLimitAutoOnDate" : @"SpeedLimitAutoOffDate"] timeIntervalSinceReferenceDate]],
    2418                     * nowDate = [NSCalendarDate calendarDate];
     2417    NSDate * timerDate = [fDefaults objectForKey: nextIsOn ? @"SpeedLimitAutoOnDate" : @"SpeedLimitAutoOffDate"],
     2418            * nowDate = [NSDate date];
    24192419   
    24202420    //create date with combination of the current date and the date to go off
    2421     NSDateComponents * components = [[NSDateComponents alloc] init];
    2422     [components setDay: [nowDate dayOfMonth]];
    2423     [components setMonth: [nowDate monthOfYear]];
    2424     [components setYear: [nowDate yearOfCommonEra]];
    2425     [components setHour: [timerDate hourOfDay]];
    2426     [components setMinute: [timerDate minuteOfHour]];
    2427     [components setSecond: 0];
    2428    
    24292421    NSCalendar * calendar = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar];
    2430     NSDate * dateToUse = [calendar dateFromComponents: components];
     2422   
     2423    NSDateComponents * nowComponents = [calendar components: NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit
     2424                                        | NSHourCalendarUnit | NSMinuteCalendarUnit fromDate: nowDate];
     2425    NSDateComponents * timerComponents = [calendar components: NSHourCalendarUnit | NSMinuteCalendarUnit fromDate: timerDate];
     2426   
     2427    int nowTime = [nowComponents hour] * 60 + [nowComponents minute],
     2428        timerTime = [timerComponents hour] * 60 + [timerComponents minute];
     2429   
     2430    [nowComponents setHour: [timerComponents hour]];
     2431    [nowComponents setMinute: [timerComponents minute]];
     2432    [nowComponents setSecond: 0];
     2433   
     2434    NSDate * dateToUse = [calendar dateFromComponents: nowComponents];
    24312435    [calendar release];
    2432     [components release];
    24332436   
    24342437    //check if should be the next day
    2435     int timerTime = [timerDate hourOfDay] * 60 + [timerDate minuteOfHour],
    2436         nowTime = [nowDate hourOfDay] * 60 + [nowDate minuteOfHour];
    24372438    if (timerTime < nowTime)
    24382439        dateToUse = [dateToUse addTimeInterval: 60 * 60 * 24]; //60 sec * 60 min * 24 hr
Note: See TracChangeset for help on using the changeset viewer.