Bug Fix Date/time formatter #44

This commit is contained in:
giomfo 2016-01-13 12:47:50 +01:00
parent cf56b94509
commit 8081799a99
2 changed files with 27 additions and 7 deletions

View file

@ -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?";

View file

@ -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
{