41 lines
1.1 KiB
Objective-C
41 lines
1.1 KiB
Objective-C
//
|
|
// KBAIReplyModel.m
|
|
// keyBoard
|
|
//
|
|
// Created by Mac on 2026/1/16.
|
|
//
|
|
|
|
#import "KBAIReplyModel.h"
|
|
#import <MJExtension/MJExtension.h>
|
|
|
|
@implementation KBAIReplyModel
|
|
|
|
+ (NSDictionary *)mj_replacedKeyFromPropertyName {
|
|
return @{
|
|
@"replyId" : @"id",
|
|
@"userName" : @[ @"userName", @"nickname", @"name" ],
|
|
@"avatarUrl" : @[ @"avatarUrl", @"avatar" ],
|
|
};
|
|
}
|
|
|
|
- (NSString *)formattedTime {
|
|
NSDate *date = [NSDate dateWithTimeIntervalSince1970:self.createTime];
|
|
NSTimeInterval interval = [[NSDate date] timeIntervalSinceDate:date];
|
|
|
|
if (interval < 60) {
|
|
return @"刚刚";
|
|
} else if (interval < 3600) {
|
|
return [NSString stringWithFormat:@"%.0f分钟前", interval / 60];
|
|
} else if (interval < 86400) {
|
|
return [NSString stringWithFormat:@"%.0f小时前", interval / 3600];
|
|
} else if (interval < 86400 * 30) {
|
|
return [NSString stringWithFormat:@"%.0f天前", interval / 86400];
|
|
} else {
|
|
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
|
formatter.dateFormat = @"MM-dd";
|
|
return [formatter stringFromDate:date];
|
|
}
|
|
}
|
|
|
|
@end
|