From e961a6ea5ff2660d895146fef8f865d6f2f91bbc Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Thu, 2 Jul 2026 10:40:32 -0600 Subject: [PATCH 1/6] Add Int.toYear API to MainAPI --- .../commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt index 30167332049..e83184bcb77 100644 --- a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt @@ -2560,6 +2560,9 @@ fun Episode.addDate(date: Instant?) { this.date = date?.toEpochMilliseconds() } +@Prerelease +fun Int.toYear(): LocalDate = LocalDate(this, 1, 1) + // Deprecate after next stable /* @Deprecated( message = "Use addDate with LocalDate, Instant, or String instead.", From 74ea81ab219e382fa47fd89e198136296a8cccd0 Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Thu, 2 Jul 2026 10:46:31 -0600 Subject: [PATCH 2/6] Add tests --- .../lagradost/cloudstream3/IntToYearTest.kt | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt diff --git a/library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt b/library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt new file mode 100644 index 00000000000..aad872a5d5f --- /dev/null +++ b/library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt @@ -0,0 +1,64 @@ +package com.lagradost.cloudstream3 + +import kotlinx.datetime.LocalDate +import kotlinx.datetime.TimeZone +import kotlinx.datetime.atStartOfDayIn +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse + +class IntToYearTest { + + @Test + fun toYearReturnsFirstOfJanuary() { + val result = 2026.toYear() + assertEquals(LocalDate(2026, 1, 1), result) + } + + @Test + fun toYearSetsCorrectYear() { + val result = 1999.toYear() + assertEquals(1999, result.year) + } + + @Test + fun toYearSetsMonthToJanuary() { + val result = 2026.toYear() + assertEquals(1, result.monthNumber) + } + + @Test + fun toYearSetsDayToFirst() { + val result = 2026.toYear() + assertEquals(1, result.dayOfMonth) + } + + @Test + fun toYearHandlesLeapYear() { + val result = 2028.toYear() + assertEquals(LocalDate(2028, 1, 1), result) + } + + @Test + fun toYearHandlesEpochYear() { + val result = 1970.toYear() + assertEquals(LocalDate(1970, 1, 1), result) + } + + @Test + fun toYearHandlesFarPastYear() { + val result = 1.toYear() + assertEquals(LocalDate(1, 1, 1), result) + } + + @Test + fun toYearHandlesFarFutureYear() { + val result = 9999.toYear() + assertEquals(LocalDate(9999, 1, 1), result) + } + + @Test + fun toYearDifferentYearsProduceDifferentDates() { + assertFalse(2025.toYear() == 2026.toYear()) + } +} From be9116b2d0b2000d2fcc4261d88b2b44ee83c4cd Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Thu, 2 Jul 2026 10:47:28 -0600 Subject: [PATCH 3/6] - --- .../kotlin/com/lagradost/cloudstream3/IntToYearTest.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt b/library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt index aad872a5d5f..18eec70d176 100644 --- a/library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt +++ b/library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt @@ -1,8 +1,6 @@ package com.lagradost.cloudstream3 import kotlinx.datetime.LocalDate -import kotlinx.datetime.TimeZone -import kotlinx.datetime.atStartOfDayIn import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFalse From 6a93a5540e042d126626a99da44fbaa70546148c Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Thu, 2 Jul 2026 10:57:51 -0600 Subject: [PATCH 4/6] Update --- .../kotlin/com/lagradost/cloudstream3/IntToYearTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt b/library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt index 18eec70d176..1f4d15e13dd 100644 --- a/library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt +++ b/library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt @@ -22,13 +22,13 @@ class IntToYearTest { @Test fun toYearSetsMonthToJanuary() { val result = 2026.toYear() - assertEquals(1, result.monthNumber) + assertEquals(1, result.month) } @Test fun toYearSetsDayToFirst() { val result = 2026.toYear() - assertEquals(1, result.dayOfMonth) + assertEquals(1, result.day) } @Test From 61e6aecbbfc286cf49ff8df7fb49816d68983909 Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Thu, 2 Jul 2026 11:04:58 -0600 Subject: [PATCH 5/6] Fix --- .../kotlin/com/lagradost/cloudstream3/IntToYearTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt b/library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt index 1f4d15e13dd..f7bc73d4b33 100644 --- a/library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt +++ b/library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt @@ -22,7 +22,7 @@ class IntToYearTest { @Test fun toYearSetsMonthToJanuary() { val result = 2026.toYear() - assertEquals(1, result.month) + assertEquals(1, result.month.number) } @Test From 20d199c6c3494bce9700b77c4edaaadd26eb81d7 Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Thu, 2 Jul 2026 11:10:39 -0600 Subject: [PATCH 6/6] Fix --- .../kotlin/com/lagradost/cloudstream3/IntToYearTest.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt b/library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt index f7bc73d4b33..e6f8fb9cfc8 100644 --- a/library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt +++ b/library/src/commonTest/kotlin/com/lagradost/cloudstream3/IntToYearTest.kt @@ -1,6 +1,7 @@ package com.lagradost.cloudstream3 import kotlinx.datetime.LocalDate +import kotlinx.datetime.number import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFalse