diff --git a/Vector/Assets/en.lproj/Vector.strings b/Vector/Assets/en.lproj/Vector.strings index 5b071cc42..5d68d274d 100644 --- a/Vector/Assets/en.lproj/Vector.strings +++ b/Vector/Assets/en.lproj/Vector.strings @@ -186,6 +186,8 @@ // Others "you" = "You"; +"today" = "Today"; +"yesterday" = "Yesterday"; "public_room_section_title" = "Public Rooms (at %@):"; "bug_report_prompt" = "The application has crashed last time. Would you like to submit a crash report?"; "rage_shake_prompt" = "You seem to be shaking the phone in frustration. Would you like to submit a bug report?"; diff --git a/Vector/Utils/EventFormatter.m b/Vector/Utils/EventFormatter.m index f6328a8c0..3ca3d5858 100644 --- a/Vector/Utils/EventFormatter.m +++ b/Vector/Utils/EventFormatter.m @@ -100,14 +100,32 @@ NSTimeInterval localZoneOffset = [localTimeZone secondsFromGMT]; NSTimeInterval interval = -[date timeIntervalSinceDate:today] - localZoneOffset; - if (interval > 60*60*24*6) + + if (interval > 60*60*24*364) { - [dateFormatter setDateFormat:@"EEE MMM dd yyyy"]; - return [super dateStringFromDate:date withTime:time]; + [dateFormatter setDateFormat:@"MMM dd yyyy"]; + + // Ignore time information here + return [super dateStringFromDate:date withTime:NO]; + } + else if (interval > 60*60*24*6) + { + [dateFormatter setDateFormat:@"MMM dd"]; + + // Ignore time information here + return [super dateStringFromDate:date withTime:NO]; } else if (interval > 60*60*24) { - [dateFormatter setDateFormat:@"EEEE"]; + if (time) + { + [dateFormatter setDateFormat:@"EEE"]; + } + else + { + [dateFormatter setDateFormat:@"EEEE"]; + } + return [super dateStringFromDate:date withTime:time]; } else if (interval > 0) @@ -115,9 +133,9 @@ if (time) { [dateFormatter setDateFormat:nil]; - return [NSString stringWithFormat:@"yesterday %@", [super dateStringFromDate:date withTime:YES]]; + return [NSString stringWithFormat:@"%@ %@", NSLocalizedStringFromTable(@"yesterday", @"Vector", nil), [super dateStringFromDate:date withTime:YES]]; } - return @"yesterday"; + return NSLocalizedStringFromTable(@"yesterday", @"Vector", nil); } else if (interval > - 60*60*24) { @@ -126,7 +144,7 @@ [dateFormatter setDateFormat:nil]; return [NSString stringWithFormat:@"%@", [super dateStringFromDate:date withTime:YES]]; } - return @"today"; + return NSLocalizedStringFromTable(@"today", @"Vector", nil); } else {