Fixed BotReportTable calendar schedule calculations.

This commit is contained in:
MobiusDevelopment
2022-10-14 04:14:26 +00:00
parent 31d35e5c58
commit 1ca3152121
26 changed files with 470 additions and 430 deletions

View File

@@ -120,16 +120,17 @@ public class BotReportTable
long lastResetTime = 0;
try
{
final String[] hour = Config.BOTREPORT_RESETPOINT_HOUR;
final Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, Integer.parseInt(hour[0]));
c.set(Calendar.MINUTE, Integer.parseInt(hour[1]));
if (System.currentTimeMillis() < c.getTimeInMillis())
final int hour = Integer.parseInt(Config.BOTREPORT_RESETPOINT_HOUR[0]);
final int minute = Integer.parseInt(Config.BOTREPORT_RESETPOINT_HOUR[1]);
final long currentTime = System.currentTimeMillis();
final Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
if (calendar.getTimeInMillis() < currentTime)
{
c.set(Calendar.DAY_OF_YEAR, c.get(Calendar.DAY_OF_YEAR) - 1);
calendar.add(Calendar.DAY_OF_YEAR, 1);
}
lastResetTime = c.getTimeInMillis();
lastResetTime = currentTime;
}
catch (Exception e)
{
@@ -414,16 +415,17 @@ public class BotReportTable
{
try
{
final String[] hour = Config.BOTREPORT_RESETPOINT_HOUR;
final Calendar c = Calendar.getInstance();
c.set(Calendar.HOUR_OF_DAY, Integer.parseInt(hour[0]));
c.set(Calendar.MINUTE, Integer.parseInt(hour[1]));
if (System.currentTimeMillis() > c.getTimeInMillis())
final int hour = Integer.parseInt(Config.BOTREPORT_RESETPOINT_HOUR[0]);
final int minute = Integer.parseInt(Config.BOTREPORT_RESETPOINT_HOUR[1]);
final long currentTime = System.currentTimeMillis();
final Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
if (calendar.getTimeInMillis() < currentTime)
{
c.set(Calendar.DAY_OF_YEAR, c.get(Calendar.DAY_OF_YEAR) + 1);
calendar.add(Calendar.DAY_OF_YEAR, 1);
}
ThreadPool.schedule(new ResetPointTask(), c.getTimeInMillis() - System.currentTimeMillis());
ThreadPool.schedule(new ResetPointTask(), calendar.getTimeInMillis() - currentTime);
}
catch (Exception e)
{