Skip to content

Commit

Permalink
Merge branch 'master' into master-172
Browse files Browse the repository at this point in the history
  • Loading branch information
RecursiveG committed Dec 2, 2015
2 parents dc34715 + 464fa9e commit 3d18176
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
15 changes: 6 additions & 9 deletions src/main/java/cat/nyaa/playtimetracker/Locale.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,25 @@ public static String get(String name, String... args) {
}

public static String formatTime(long ms) {
ConfigurationSection s = lang.getConfigurationSection("statistic-time-format");
String str = "";
if (ms == 0)
return "0";
return s.getString("zero");

if (ms > 0) {
str = String.format("%dms", ms % 1000) + str;
str = String.format(s.getString("ms"), ms % 1000) + str;
ms = Math.floorDiv(ms, 1000);
}
if (ms > 0) {
str = String.format("%ds ", ms % 60) + str;
str = String.format(s.getString("s"), ms % 60) + str;
ms = Math.floorDiv(ms, 60);
}
if (ms > 0) {
str = String.format("%dm ", ms % 60) + str;
str = String.format(s.getString("m"), ms % 60) + str;
ms = Math.floorDiv(ms, 60);
}
if (ms > 0) {
str = String.format("%dh ", ms % 24) + str;
ms = Math.floorDiv(ms, 24);
}
if (ms > 0) {
str = String.format("%dd ", ms) + str;
str = String.format(s.getString("h"), ms) + str;
}

return str;
Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ message:
statistic-month: "Online time this month: %s"
statistic-session: "Online time this session: %s"
statistic-total: "Online time total: %s"
#statistic-time-format: "D'd'H'h'm'm's's'S'ms'" # http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
statistic-time-format:
ms: "%dms"
s: "%dseconds "
m: "%dminutes "
h: "%dhours "
zero: "No Record"
statistic-no-record: "No record for that player."

ignore-afk: true
Expand Down

0 comments on commit 3d18176

Please sign in to comment.