package bou.amine.apps.readerforselfossv2.repository

import bou.amine.apps.readerforselfossv2.utils.DateUtils
import junit.framework.TestCase.assertEquals
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toInstant
import org.junit.Test

class DatesTest {

    private val v3Date = "2013-04-07T13:43:00+01:00"
    private val v4Date = "2013-04-07 13:43:00"

    @Test
    fun v3_date_should_be_parsed() {
        val date = DateUtils.parseDate(v3Date)
        val expected = LocalDateTime(2013, 4, 7, 13, 43, 0, 0).toInstant(TimeZone.of("UTC+1")) .toEpochMilliseconds()

        assertEquals(date, expected)
    }

    @Test
    fun v4_date_should_be_parsed() {
        val date = DateUtils.parseDate(v4Date)
        val expected =
            LocalDateTime(2013, 4, 7, 13, 43, 0, 0).toInstant(TimeZone.currentSystemDefault())
                .toEpochMilliseconds()

        assertEquals(date, expected)
    }

}
