package net.northking.cctp.element;

import net.northking.cctp.element.core.IExecuteContext;
import net.northking.cctp.element.datetime.keywords.DateTime;
import net.northking.cctp.element.core.annotation.Autowired;
import net.northking.cctp.element.test.AbstractLibraryTest;
import net.northking.cctp.element.test.ParamsBuilder;
import net.northking.cctp.element.test.SampleExecuteContext;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.testng.annotations.Test;

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

public class DateTimeLibraryTest extends AbstractLibraryTest {

    @Autowired
    protected DateTime dateTime;

    @Test
    public void test() throws Exception {

//        IExecuteContext build = new SampleExecuteContext.Builder().build();
        //getCurrentDate
//        System.out.println(dateTime.getCurrentDate("yyyy-MM-dd", "GMT+08:00","${aaa}",build));
        //convertDate
//        System.out.println(dateTime.convertDate("0","2022-12-20","yyyy-MM-dd","yyyy:MM:dd","#{bbb}",build));
//        System.out.println(dateTime.convertDate("1","Sat, 12 Aug 2022 13:30:00 GMT",null,"yyyy:MM:dd","#{bbb}",build));
        //addTimeToDate
//        System.out.println(dateTime.addTimeToDate("0","2022-12-20","yyyy-MM-dd","1day 2hours 5mins 30s","yyyy:MM:dd","${ccc}",build));
//        System.out.println(dateTime.addTimeToDate("1","Sat, 12 Aug 2022 13:30:00 GMT",null,"1day 2hours 5mins 30s","yyyy:MM:dd","${ccc}",build));
    }

    @Test
    public void test1() throws Exception {
//        System.out.println(dateTime.formatTimestamp(1589188564854L, "yyyy-MM-dd", "GMT+08:00"));
//        System.out.println(dateTime.formatTimestamp(1589188564854L, "yyyy-MM-dd HH:mm:ss", "GMT+08:00"));
    }

    public static void main(String[] args) {
        System.out.println(TimeZone.getDefault());
        TimeZone timeZone = TimeZone.getTimeZone("GMT+09:00");
        String date = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss", timeZone);
        System.out.println(date);
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeZone(timeZone);
        System.out.println(calendar.getTimeZone());
    }

}