Browse files

Tweaked -(NSString*)formatDateTime method so that it shows the year i…

…f the date is older than a year ago.
  • Loading branch information...
1 parent a06bbd1 commit c071dba43ecfffb0edc681faa301388258f851a8 @jmascia committed Oct 24, 2011
Showing with 10 additions and 1 deletion.
  1. +10 −1 src/Three20Core/Sources/NSDateAdditions.m
View
11 src/Three20Core/Sources/NSDateAdditions.m
@@ -130,14 +130,23 @@ - (NSString*)formatDateTime {
}
return [formatter stringFromDate:self];
- } else {
+ } else if (diff < TT_YEAR) {
static NSDateFormatter* formatter = nil;
if (nil == formatter) {
formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = TTLocalizedString(@"MMM d h:mm a", @"Date format: Jul 27 1:05 pm");
formatter.locale = TTCurrentLocale();
}
return [formatter stringFromDate:self];
+
+ } else {
+ static NSDateFormatter* formatter = nil;
+ if (nil == formatter) {
+ formatter = [[NSDateFormatter alloc] init];
+ formatter.dateFormat = TTLocalizedString(@"MMM d, YYYY", @"Date format: Jul 27, 2011");
+ formatter.locale = TTCurrentLocale();
+ }
+ return [formatter stringFromDate:self];
}
}

0 comments on commit c071dba

Please sign in to comment.