Skip to content

Commit

Permalink
chore: use hours in two digits
Browse files Browse the repository at this point in the history
  • Loading branch information
70CentsApple committed Oct 1, 2024
1 parent 93e8a56 commit da54006
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static Text work(Text message, String hashcode) {
String offsetString = ZoneId.systemDefault().getRules().getOffset(instant).getId();
Text shortTimeDisplay = TextUtils.of(timeInFormat((String) ChatTools.CONFIG.get("general.Timestamp.Pattern")));
// yyyy/MM/dd HH:mm:ss UTC±XX:XX
Text longTimeDisplay = TextUtils.of(String.format("%4d/%d/%d %d:%02d:%02d\nUTC%s", currentTime.getYear(), currentTime
Text longTimeDisplay = TextUtils.of(String.format("%4d/%d/%d %02d:%02d:%02d\nUTC%s", currentTime.getYear(), currentTime
.getMonth()
.getValue(), currentTime.getDayOfMonth(), currentTime.getHour(), currentTime.getMinute(), currentTime.getSecond(), offsetString));
if ((boolean) ChatTools.CONFIG.get("general.Timestamp.CopyToChatBar.Enabled")) {
Expand All @@ -40,7 +40,7 @@ public static Text work(Text message, String hashcode) {
private static String timeInFormat(String formatter) {
formatter = TextUtils.encodeColorCodes(formatter);
LocalDateTime time = LocalDateTime.now();
formatter = formatter.replace("{hour}", String.format("%d", time.getHour()))
formatter = formatter.replace("{hour}", String.format("%02d", time.getHour()))
.replace("{minute}", String.format("%02d", time.getMinute()))
.replace("{second}", String.format("%02d", time.getSecond()));
return formatter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public Text getTooltip() {
.getOffset(Instant.now()));
String offsetString = ZoneId.systemDefault().getRules().getOffset(Instant.now()).getId();
// yyyy/MM/dd HH:mm:ss UTC±XX:XX
Text longTimeDisplay = TextUtils.of(String.format("%4d/%d/%d %d:%02d:%02d\nUTC%s", time.getYear(), time
Text longTimeDisplay = TextUtils.of(String.format("%4d/%d/%d %02d:%02d:%02d\nUTC%s", time.getYear(), time
.getMonth()
.getValue(), time.getDayOfMonth(), time.getHour(), time.getMinute(), time.getSecond(), offsetString));
return longTimeDisplay;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private String getLongTimeDisplay(long timestamp) {
.getOffset(instant));
String offsetString = ZoneId.systemDefault().getRules().getOffset(instant).getId();
// yyyy/MM/dd HH:mm:ss UTC±XX:XX
String longTimeDisplay = String.format("%4d/%d/%d %d:%02d:%02d\nUTC%s", currentTime.getYear(), currentTime
String longTimeDisplay = String.format("%4d/%d/%d %02d:%02d:%02d\nUTC%s", currentTime.getYear(), currentTime
.getMonth()
.getValue(), currentTime.getDayOfMonth(), currentTime.getHour(), currentTime.getMinute(), currentTime.getSecond(), offsetString);
return longTimeDisplay;
Expand Down

0 comments on commit da54006

Please sign in to comment.