mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-04-26 16:39:45 +00:00
Limit max time delta in years to 100k
This commit is contained in:
parent
844a4a0574
commit
7c59d61b32
1 changed files with 10 additions and 0 deletions
|
@ -94,6 +94,16 @@ public class DateUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dateDiff(int type, Calendar fromDate, Calendar toDate, boolean future) {
|
static int dateDiff(int type, Calendar fromDate, Calendar toDate, boolean future) {
|
||||||
|
int year = Calendar.YEAR;
|
||||||
|
int maxYears = 100000;
|
||||||
|
|
||||||
|
int fromYear = fromDate.get(year);
|
||||||
|
int toYear = toDate.get(year);
|
||||||
|
if (Math.abs(fromYear - toYear) > maxYears) {
|
||||||
|
toDate.set(year, fromYear +
|
||||||
|
(future ? maxYears : -maxYears));
|
||||||
|
}
|
||||||
|
|
||||||
int diff = 0;
|
int diff = 0;
|
||||||
long savedDate = fromDate.getTimeInMillis();
|
long savedDate = fromDate.getTimeInMillis();
|
||||||
while ((future && !fromDate.after(toDate)) || (!future && !fromDate.before(toDate))) {
|
while ((future && !fromDate.after(toDate)) || (!future && !fromDate.before(toDate))) {
|
||||||
|
|
Loading…
Reference in a new issue