//
//  ICContactsBackupCell.m
//  superCleaner
//
//  Created by GY.Z on 2020/7/7.
//  Copyright © 2020 Mazy. All rights reserved.
//

#import "ICContactsBackupCell.h"
#import "ICContactsBackup.h"

@interface ICContactsBackupCell ()

@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property (weak, nonatomic) IBOutlet UILabel *noteLabel;
@property (weak, nonatomic) IBOutlet UILabel *countLabel;


@end

@implementation ICContactsBackupCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)setModel:(ICContactsBackup *)model
{
    _model = model;
    
    self.dateLabel.text = [NSString stringWithFormat:@"%@",[self convertStrToTime:model.timestamp]];
    self.noteLabel.text = [NSString stringWithFormat:@"%ldKB",(long)[model.kMDItemFSSize integerValue]/1000];
    if (model.choose) {
        [self.button setImage:[UIImage imageNamed:@"contact_choosed"] forState:UIControlStateNormal];
    }else{
        [self.button setImage:[UIImage imageNamed:@"contact_choose"] forState:UIControlStateNormal];
    }
}

- (NSString *)convertStrToTime:(NSString *)timeStr
{
    long long time=[timeStr longLongValue];
    NSDate *date = [[NSDate alloc]initWithTimeIntervalSince1970:time];
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString *timeString=[formatter stringFromDate:date];
    return timeString;
}


@end
