package com.ruoyi.web.modules.diagnosis.support;

import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

/**
 * 接诊列表默认 3 个月时间窗（Asia/Shanghai 自然日）。
 */
public final class ConsultThreeMonthsWindow
{
    private static final String ZONE_ID = "Asia/Shanghai";

    private ConsultThreeMonthsWindow()
    {
    }

    public static Date calcThreeMonthsAgo(Date reference)
    {
        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(ZONE_ID));
        cal.setTime(reference != null ? reference : new Date());
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        cal.add(Calendar.MONTH, -3);
        return cal.getTime();
    }
}
