Handle nil date when formatting

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent 2575d01b96
commit 7040437ca6

@ -254,7 +254,13 @@ const NSUInteger kAvatarViewDiameter = 52;
#pragma mark - Date formatting
- (NSAttributedString *)dateAttributedString:(NSDate *)date {
- (NSAttributedString *)dateAttributedString:(nullable NSDate *)date
{
if (date == nil) {
OWSProdLogAndFail(@"%@ date was unexpectedly nil", self.logTag);
return [NSAttributedString new];
}
NSString *timeString;
if ([DateUtil dateIsToday:date]) {
@ -263,6 +269,7 @@ const NSUInteger kAvatarViewDiameter = 52;
timeString = [[DateUtil dateFormatter] stringFromDate:date];
}
OWSAssert(timeString);
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:timeString];
[attributedString addAttribute:NSForegroundColorAttributeName

Loading…
Cancel
Save