//
//  AV_TaskCell.swift
//  anniversary_Project
//
//  Created by 忆海16 on 2024/4/15.
//

import UIKit

class AV_TaskCell: UITableViewCell {
    
    @IBOutlet weak var dateLabel: UILabel!
    
    @IBOutlet weak var headImagV: UIImageView!
    
    @IBOutlet weak var nameLabel: UILabel!
    
    @IBOutlet weak var timeLabel: UILabel!
    
    @IBOutlet weak var bgView: UIView!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        self.headImagV.layer.cornerRadius = 5
        self.bgView.layer.cornerRadius = 8
       
       
    }
    
    var model:UserModel?{
        didSet{
            let image = model?.getImage()
            self.headImagV.image = image
            self.timeLabel.text = model?.date
            self.nameLabel.text = model?.name
            let dateString = model?.date
            let dateFormatter = DateFormatter()
            dateFormatter.dateFormat = "yyyy-MM-dd"

            if let date = dateFormatter.date(from: dateString!) {
                let outputDateFormatter = DateFormatter()
                outputDateFormatter.dateFormat = "MMM\ndd"
                dateLabel.text = outputDateFormatter.string(from: date)
                
//                print(formattedDate) // Output: May 20
            } else {
                print("Invalid date format")
            }
            
        }
    }
}
