Changeset 608 for trunk/Cocoa/Pester/Source/PSAlarm.m
- Timestamp:
- 12/21/09 22:13:21 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/Pester/Source/PSAlarm.m
r602 r608 29 29 30 30 static NSDateFormatter *dateFormatter, *shortDateFormatter, *timeFormatter; 31 32 static NSCalendar *gregorianCalendar; 33 34 static NSDate *midnightOnDate(NSDate *date) { 35 return [gregorianCalendar dateFromComponents: 36 [gregorianCalendar components: NSMonthCalendarUnit|NSDayCalendarUnit|NSYearCalendarUnit fromDate: date]]; 37 } 31 38 32 39 @implementation PSAlarm … … 46 53 [timeFormatter setTimeStyle: NSDateFormatterMediumStyle]; 47 54 [timeFormatter setDateStyle: NSDateFormatterNoStyle]; 55 gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar]; 48 56 } 49 57 … … 246 254 } 247 255 256 - (NSDate *)midnightOnDate; 257 { 258 if (alarmType == PSAlarmInterval) [self _setDateFromInterval]; 259 260 return midnightOnDate(alarmDate); 261 } 262 248 263 - (NSDate *)time; 249 264 { … … 251 266 if (alarmType == PSAlarmInterval) [self _setDateFromInterval]; 252 267 253 NSCalendar *calendar = [NSCalendar currentCalendar]; 254 255 return [calendar dateFromComponents: 256 [calendar components: NSHourCalendarUnit|NSMinuteCalendarUnit|NSSecondCalendarUnit fromDate: alarmDate]]; 268 return [gregorianCalendar dateFromComponents: 269 [gregorianCalendar components: NSHourCalendarUnit|NSMinuteCalendarUnit|NSSecondCalendarUnit fromDate: alarmDate]]; 270 } 271 272 - (int)daysFromToday; 273 { 274 if (alarmType == PSAlarmInterval) [self _setDateFromInterval]; 275 276 return [[gregorianCalendar components: NSDayCalendarUnit fromDate: midnightOnDate([NSDate date]) toDate: alarmDate options: 0] day]; 257 277 } 258 278
Note:
See TracChangeset
for help on using the changeset viewer.