Skip to content

Commit

Permalink
Support Islamic calendar of 1402
Browse files Browse the repository at this point in the history
  • Loading branch information
ebraminio committed Oct 15, 2022
1 parent affefa5 commit bf52d0b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class IranianIslamicDateConverter {

// This is a package public API used in the app
public final static int latestSupportedYearOfIran = 1401;
public final static int latestSupportedYearOfIran = 1402;

private final static long jdSupportStart = 2425063; // CivilDate(1927, 7, 1).toJdn()
private final static long jdSupportEnd;
Expand Down Expand Up @@ -118,7 +118,8 @@ public class IranianIslamicDateConverter {
/*1441*/29, 30, 29, 30, 30, 29, 30, 30, 29, 30, 29, 30,
/*1442*/29, 29, 30, 29, 30, 29, 30, 30, 29, 30, 30, 29,
/*1443*/29, 30, 30, 29, 29, 30, 29, 30, 30, 29, 30, 29,
/*1444*/30, 30, 29, 30, 29, 29, 30,/**/30, 29, 30, 29, 29
/*1444*/30, 30, 29, 30, 29, 29, 30, 29, 30, 29, 30, 29,
/*1445*/30, 30, 30, 29, 30, 29, 29, 30/**/, 29, 30, 29, 29,
};

supportedYears = hijriMonths.length / 12;
Expand Down
29 changes: 27 additions & 2 deletions src/test/kotlin/io/github/persiancalendar/calendar/MainTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class MainTests {
}

@Test
fun `Supported Year Islamic Calendar Conversions`() {
fun `Islamic Calendar Conversions of 1401`() {
val dates = listOf(
listOf(1401, 1, 14, 1443, 9, 1),
listOf(1401, 2, 13, 1443, 10, 1),
Expand All @@ -244,8 +244,33 @@ class MainTests {
listOf(1401, 11, 3, 1444, 7, 1),
listOf(1401, 12, 3, 1444, 8, 1),
)
assertEquals(dates.count { it[0] == 1401 }, 12)
dates.forEach {
assertEquals(
PersianDate(it[0], it[1], it[2]).toJdn(), IslamicDate(it[3], it[4], it[5]).toJdn()
)
}
}

@Test
fun `Supported Year Islamic Calendar Conversions`() {
val dates = listOf(
listOf(1402, 1, 3, 1444, 9, 1),
listOf(1402, 2, 2, 1444, 10, 1),
listOf(1402, 2, 31, 1444, 11, 1),
listOf(1402, 3, 30, 1444, 12, 1),
listOf(1402, 4, 28, 1445, 1, 1),
listOf(1402, 5, 27, 1445, 2, 1),
listOf(1402, 6, 26, 1445, 3, 1),
listOf(1402, 7, 25, 1445, 4, 1),
listOf(1402, 8, 24, 1445, 5, 1),
listOf(1402, 9, 24, 1445, 6, 1),
listOf(1402, 10, 23, 1445, 7, 1),
listOf(1402, 11, 22, 1445, 8, 1),
listOf(1402, 12, 22, 1445, 9, 1),
)
assertEquals(
dates.count { it[0] == IranianIslamicDateConverter.latestSupportedYearOfIran }, 12
dates.count { it[0] == IranianIslamicDateConverter.latestSupportedYearOfIran }, 13
)
dates.forEach {
assertEquals(
Expand Down

0 comments on commit bf52d0b

Please sign in to comment.