package com.ruoyi.test.DataRange;

import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author 赫兹
 */
@Slf4j
public class JUnitTest {
    
    @Test
    public void testDateSplitUtil() {
        //2019-10-25 13:25:55
        LocalDateTime startTime = LocalDateTime.of(2019, 10, 25, 13, 25, 55);
        //2020-01-25 12:30:32
        LocalDateTime endTime = LocalDateTime.of(2020, 1, 25, 12, 30, 32);
        List<DateRange> dateYearRanges = DateSplitUtil.splitAndGetByType(1, startTime, endTime);
        log.info("按年切分后的结果：\n\t{}",dateYearRanges);

        List<DateRange> dateMonthRanges = DateSplitUtil.splitAndGetByType(2, startTime, endTime);
        log.info("按月切分后的结果：\n\t{}",dateMonthRanges);

        List<DateRange> dateWeekRanges = DateSplitUtil.splitAndGetByType(3, startTime, endTime);
        log.info("按周切分后的结果：\n\t{}",dateWeekRanges);

        List<DateRange> dateDayRanges = DateSplitUtil.splitAndGetByType(4, startTime, endTime);
        log.info("按日切分后的结果：\n\t{}",dateDayRanges);


        //获取割后的第二段时间
        DateRange dateYearRangeByTurn = DateSplitUtil.splitAndGetByTurn(1,2, startTime, endTime);
        log.info("第二段时间：\n\t{}",dateYearRangeByTurn);
    }

}
