Skip to content

Commit

Permalink
feat(utils): format mc day time supports millisecond
Browse files Browse the repository at this point in the history
  • Loading branch information
lainio24 committed Jun 22, 2022
1 parent 4f8e345 commit eff3eb6
Showing 1 changed file with 4 additions and 12 deletions.
Expand Up @@ -24,25 +24,17 @@ static long[] getTime(Level level) {
}

static int[] formatDayTime(long rawDayTime) {
// change the server time started with 0 at midnight
int dayTime = ((int) (rawDayTime % 2147483647L)) - ticksAtMidnight + ticksPerDay;
int dayTime = (int) (rawDayTime % 2147483647L);

int day = dayTime / ticksPerDay;

/*
* int ticks = dayTime % ticksPerDay;
* int hour = ticks / ticksPerHour;
* ticks -= hour * ticksPerHour;
* int minutes = (int) (ticks / ticksPerMinute);
* ticks -= minutes * ticksPerMinute;
* int seconds = (int) (ticks / ticksPerSecond);
*/
int ticks = dayTime - day * ticksPerDay;
int hour = (ticks / ticksPerHour) % 24;
int hour = (int) (ticks / ticksPerHour + 6) % 24;
int min = (int) (ticks / ticksPerMinute) % 60;
int sec = (int) (ticks / ticksPerSecond) % 60;
int msec = (int) (ticks / ticksPerMillisecond) % 1000;

return new int[] {day, hour, min, sec};
return new int[] {day, hour, min, sec, msec};
}

static int getDay(long dayTime) {
Expand Down

0 comments on commit eff3eb6

Please sign in to comment.