Skip to content

Commit

Permalink
Fix time calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Nincodedo committed Jun 23, 2021
1 parent ae23785 commit ffc6588
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ private String getTimeString(long serverTimeOfDay) {
long currentTime = serverTimeOfDay % 24000;
int hour = (int) (currentTime / 1000 + 6);
int minute = (int) (currentTime % 1000 * 60 / 1000);
String ampm = hour >= 12 ? "PM" : "AM";
hour = hour >= 12 ? hour - 12 : hour;
String ampm = hour > 12 && hour <= 23 ? "PM" : "AM";
if (hour == 0 || hour == 24) {
hour = 12;
}
if (hour != 12) {
hour = hour % 12;
}
return hour + ":" + String.format("%02d", minute) + " " + ampm;
}

Expand Down

0 comments on commit ffc6588

Please sign in to comment.