package cn.iocoder.yudao.module.tickets.utils;

import cn.hutool.core.date.DateUtil;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 工单操作常用util
 * @author vinjor-M
 * @date 16:15 2024/10/18
**/
@Component
public class TicketsOperateUtil {

    /**
     * 计算车龄
     * @author vinjor-M
     * @date 14:47 2025/1/9
     * @param   registerDate 车辆注册日期
     * @return java.lang.Double
     **/
    public Double computeCarYear(Date registerDate){
        long betweenMonth = DateUtil.betweenMonth(registerDate, new Date(), true);
        String carYear = String.format("%.2f", (double) betweenMonth / 12);
        return Double.parseDouble(carYear);
    }
}
