// // UserLoginFastCell.m // XenonSDK // // Created by SAGESSE on 2019/5/30. // Copyright © 2019 SAGESSE. All rights reserved. // #import "XenonSDK.h" #import "UserLoginFastCell.h" @implementation UserLoginFastCell - (void)setUser:(XSUser*)user { _user = user; NSTimeInterval lasttime = user.lastTime; NSTimeInterval diff = NSDate.new.timeIntervalSince1970 - lasttime; id str = @"很久以前"; if (diff < 60) { str = @"刚刚"; } else if (diff < 3600) { str = [NSString stringWithFormat:@"%zd分钟前", (NSInteger)(diff / 60)]; } else if (diff < 86400) { str = [NSString stringWithFormat:@"%zd小时前", (NSInteger)(diff / 60 / 60)]; } else if (diff < 2592000) { str = [NSString stringWithFormat:@"%zd天前", (NSInteger)(diff / 60 / 60 / 24)]; } self.titleLabel.text = user.account ?: [NSString stringWithFormat:@"游客 - %@", user.userName ?: @""]; self.subtitleLabel.text = [NSString stringWithFormat:@"上次登录 %@", str]; } @end