package space.nstart.pcp.pcp_types_lib.utils

import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import java.time.LocalDateTime

class UtcDateTimesTest {

    @Test
    fun `normalizes offset date-time to utc naive LocalDateTime`() {
        val actual = UtcDateTimes.parse("2026-06-17T09:28:27.334+03:00")

        assertEquals(LocalDateTime.of(2026, 6, 17, 6, 28, 27, 334_000_000), actual)
    }

    @Test
    fun `treats legacy naive date-time as utc naive LocalDateTime`() {
        val actual = UtcDateTimes.parse("2026-06-17T06:28:27.334")

        assertEquals(LocalDateTime.of(2026, 6, 17, 6, 28, 27, 334_000_000), actual)
    }

    @Test
    fun `formats utc naive LocalDateTime with Z suffix`() {
        val actual = UtcDateTimes.format(LocalDateTime.of(2026, 6, 17, 6, 28, 27, 334_000_000))

        assertEquals("2026-06-17T06:28:27.334Z", actual)
    }
}
