Cap mute/ban/jail to 10 years (any more is silly).

Cap time descriptions to 3 significant notions.
This commit is contained in:
KHobbits 2012-04-04 01:55:06 +01:00
parent e52996609a
commit eeea16a99a

View File

@ -80,11 +80,17 @@ public class Util
_("second"),
_("seconds")
};
int accuracy = 0;
for (int i = 0; i < types.length; i++)
{
if (accuracy > 2)
{
break;
}
int diff = dateDiff(types[i], fromDate, toDate, future);
if (diff > 0)
{
accuracy++;
sb.append(" ").append(diff).append(" ").append(names[i * 2 + (diff > 1 ? 1 : 0)]);
}
}
@ -92,7 +98,7 @@ public class Util
{
return "now";
}
return sb.toString();
return sb.toString().trim();
}
private static int dateDiff(int type, Calendar fromDate, Calendar toDate, boolean future)
@ -181,6 +187,10 @@ public class Util
throw new Exception(_("illegalDate"));
}
Calendar c = new GregorianCalendar();
if (years > 10)
{
years = 10;
}
if (years > 0)
{
c.add(Calendar.YEAR, years * (future ? 1 : -1));