package net.ranides.assira.time2;

import org.junit.Test;

import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;

import static org.junit.Assert.*;

public class ZonedTimeTest {


    @Test
    public void testWithDate() {
        ZonedTime time = ZonedTime.of(DateTimeUtils.ZONE_PL, LocalTime.of(14, 25, 31));

        System.out.println(time);
        System.out.println(time.withDate(ZonedDate.of(DateTimeUtils.ZONE_PL, LocalDate.of(0,1,1))));
    }

    @Test
    public void testUntil() {
        LocalTime timeL1 = LocalTime.of(8, 15);
        LocalTime timeL2 = LocalTime.of(9, 20);

        System.out.println(timeL1.until(timeL2, ChronoUnit.MINUTES));

        ZonedTime timeA1 = ZonedTime.of(DateTimeUtils.ZONE_PL, LocalTime.of(8, 15, 0));
        ZonedTime timeA2 = ZonedTime.of(DateTimeUtils.ZONE_PL, LocalTime.of(9, 20, 0));

        System.out.println(timeA1.until(timeA2, ChronoUnit.MINUTES));

        ZonedTime timeB1 = ZonedTime.of(ZonedDateTime.of(1980, 1, 1, 8, 15, 0, 0, DateTimeUtils.ZONE_PL));
        ZonedTime timeB2 = ZonedTime.of(ZonedDateTime.of(1980, 1, 1, 9, 20, 0, 0, DateTimeUtils.ZONE_PL));

        System.out.println(timeB1.until(timeB2, ChronoUnit.MINUTES));

        ZonedDateTime datetimeC1 = DateTimeLiteral.datetimeUtc(1980, 1, 1, 23, 45, 0);
        ZonedDateTime datetimeC2 = DateTimeLiteral.datetime(1980, 1, 1, 23, 45, 0);

        System.out.println(datetimeC1);
        System.out.println(datetimeC2);
        System.out.println(DateTimeUtils.diff(datetimeC1, datetimeC2));

    }
}