package com.cooleshow.teacher;

import com.cooleshow.base.utils.TimeUtils;

import java.sql.Time;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Author by pq, Date on 2022/4/24.
 */
public class CourseHelper {
    public static Map<String, com.haibin.calendarview.Calendar> filterDate(List<String> targetList) {
        Map<String, com.haibin.calendarview.Calendar> calendarMap = new HashMap<>();
        try {
            for (int i = 0; i < targetList.size(); i++) {
                String s = targetList.get(i);
                Date date = TimeUtils.stringToDate(s);
                int year = TimeUtils.getValueByCalendarField(date, Calendar.YEAR);
                int month = TimeUtils.getValueByCalendarField(date, Calendar.MONTH) + 1;
                int day = TimeUtils.getValueByCalendarField(date, Calendar.DAY_OF_MONTH);
                com.haibin.calendarview.Calendar calendar = new com.haibin.calendarview.Calendar();
                calendar.setYear(year);
                calendar.setMonth(month);
                calendar.setDay(day);
                calendarMap.put(calendar.toString(), calendar);
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return calendarMap;
    }
}
