Changeset 358
- Timestamp:
- 11/24/07 03:03:52 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/Pester/Source/PSAlarm.m
r355 r358 11 11 #import "PSAlerts.h" 12 12 #import "PSTimer.h" 13 #import "NJRDateFormatter.h"14 13 #import "NSCalendarDate-NJRExtensions.h" 15 14 #import "NSDictionary-NJRExtensions.h" … … 29 28 static NSString * const PLAlarmRepeating = @"repeating"; // NSNumber 30 29 31 static NSString *dateFormat, *shortDateFormat, *timeFormat; 32 static NSDictionary *locale; 30 static NSDateFormatter *dateFormatter, *shortDateFormatter, *timeFormatter; 33 31 34 32 @implementation PSAlarm … … 36 34 #pragma mark initialize-release 37 35 38 + (void)initialize; // XXX change on locale modification, subscribe to NSNotifications 39 { 40 dateFormat = [[NJRDateFormatter localizedDateFormatIncludingWeekday: YES] retain]; 41 shortDateFormat = [[NJRDateFormatter localizedShortDateFormatIncludingWeekday: NO] retain]; 42 timeFormat = [[NJRDateFormatter localizedTimeFormatIncludingSeconds: YES] retain]; 43 locale = [[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] retain]; 36 + (void)initialize; 37 { 38 [NSDateFormatter setDefaultFormatterBehavior: NSDateFormatterBehavior10_4]; 39 dateFormatter = [[NSDateFormatter alloc] init]; 40 [dateFormatter setTimeStyle: NSDateFormatterNoStyle]; 41 [dateFormatter setDateStyle: NSDateFormatterFullStyle]; 42 shortDateFormatter = [[NSDateFormatter alloc] init]; 43 [shortDateFormatter setTimeStyle: NSDateFormatterNoStyle]; 44 [shortDateFormatter setDateStyle: NSDateFormatterShortStyle]; 45 timeFormatter = [[NSDateFormatter alloc] init]; 46 [timeFormatter setTimeStyle: NSDateFormatterMediumStyle]; 47 [timeFormatter setDateStyle: NSDateFormatterNoStyle]; 44 48 } 45 49 … … 291 295 - (NSString *)dateString; 292 296 { 293 return [ [self date] descriptionWithCalendarFormat: dateFormat locale: locale];297 return [dateFormatter stringFromDate: [self date]]; 294 298 } 295 299 296 300 - (NSString *)shortDateString; 297 301 { 298 return [ [self date] descriptionWithCalendarFormat: shortDateFormat locale: locale];302 return [shortDateFormatter stringFromDate: [self date]]; 299 303 } 300 304 301 305 - (NSString *)timeString; 302 306 { 303 return [ [self date] descriptionWithCalendarFormat: timeFormat locale: locale];307 return [timeFormatter stringFromDate: [self date]]; 304 308 } 305 309 … … 316 320 NSCalendarDate *date = [[NSCalendarDate alloc] initWithTimeIntervalSinceNow: [self interval]]; 317 321 NSString *nextDateTimeString = [NSString stringWithFormat: @"%@ at %@", 318 [date descriptionWithCalendarFormat: dateFormat locale: locale],319 [date descriptionWithCalendarFormat: timeFormat locale: locale]];322 [dateFormatter stringFromDate: date], 323 [timeFormatter stringFromDate: date]]; 320 324 [date release]; 321 325 return nextDateTimeString;
Note:
See TracChangeset
for help on using the changeset viewer.