Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,8 @@

public class PersianDateFixedLeapYear extends PersianDate {

/**
* Thanks to <a href="https://github.com/persian-calendar/calendar/blob/3294e3929bf986fe8fa27c606694360cb1bded01/src/main/java/io/github/persiancalendar/calendar/persian/LookupTableConverter.java#L14">Persian Calendar Project</>
*/
private final List<Integer> leapYears = Arrays.asList(
1210, 1214, 1218, 1222, 1226, 1230, 1234, 1238, 1243, 1247, 1251, 1255, 1259, 1263,
1267, 1271, 1276, 1280, 1284, 1288, 1292, 1296, 1300, 1304, 1309, 1313, 1317, 1321,
1325, 1329, 1333, 1337, 1342, 1346, 1350, 1354, 1358, 1362, 1366, 1370, 1375, 1379,
1383, 1387, 1391, 1395, 1399, 1403, 1408, 1412, 1416, 1420, 1424, 1428, 1432, 1436,
1441, 1445, 1449, 1453, 1457, 1461, 1465, 1469, 1474, 1478, 1482, 1486, 1490, 1494,
1498);


public PersianDateFixedLeapYear() {
}

public PersianDateFixedLeapYear(Long timeInMilliSecond) {
super(timeInMilliSecond);
}
Expand All @@ -33,11 +20,16 @@ public PersianDateFixedLeapYear(Date date) {

@Override
public boolean isLeap(int year) {
if (year > 1500) {
return super.isLeap(year);
int[] matches = { 1, 5, 9, 13, 17, 22, 26, 30 };
int modulus = year % 33;
boolean isLeapYear = false;
for (int match : matches){
if (match == modulus) {
isLeapYear = true;
break;
}
}
return leapYears.contains(year);
return isLeapYear;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,6 @@ public static long persianToJulian(long year, int month, int day) {
* ((long) Math.floor((year - 474L) / 2820D)) + (month < 7 ? 31 * month : 30 * month + 6) + day;
}

/**
* Calculate whether current year is Leap year in persian or not
*
* @return boolean
*/
public static boolean isPersianLeapYear(int persianYear) {
return PersianCalendarUtils.ceil((38D + (PersianCalendarUtils.ceil(persianYear - 474L, 2820L) + 474L)) * 682D, 2816D) < 682L;
}

/**
* Converts a provided Julian Day Number (i.e. the number of days since
* January 1 in the year 4713 BC) to the Persian (Shamsi) date. Since the
Expand Down