Skip to content

Commit

Permalink
Time unit symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
Navid200 committed Dec 16, 2024
1 parent a2bbca9 commit 35b6ab7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
23 changes: 13 additions & 10 deletions app/src/main/java/com/eveningoutpost/dexdrip/models/JoH.java
Original file line number Diff line number Diff line change
Expand Up @@ -754,26 +754,29 @@ public static String niceTimeTill(long t) {
}

// temporary
public static String niceTimeScalar(long t) {
public static String niceTimeScalar(long t) { // If forceSym is not entered as a parameter, a value of false will be assumed for it.
return niceTimeScalar(t, false); // The method will use translations, instead of symbols, if forceSym is set to false.
}
public static String niceTimeScalar(long t, boolean forceSym) { // Symbols will be used if forceSym is true, regardless of the chosen language
String unit = xdrip.getAppContext().getString(R.string.unit_second);
t = t / 1000;
if (t != 1) unit = xdrip.getAppContext().getString(R.string.unit_seconds);
if (t != 1) unit = forceSym? "s" : xdrip.getAppContext().getString(R.string.unit_seconds);
if (t > 59) {
unit = xdrip.getAppContext().getString(R.string.unit_minute);
unit = forceSym? "min" : xdrip.getAppContext().getString(R.string.unit_minute);
t = t / 60;
if (t != 1) unit = xdrip.getAppContext().getString(R.string.unit_minutes);
if (t != 1) unit = forceSym? "min" : xdrip.getAppContext().getString(R.string.unit_minutes);
if (t > 59) {
unit = xdrip.getAppContext().getString(R.string.unit_hour);
unit = forceSym? "h" : xdrip.getAppContext().getString(R.string.unit_hour);
t = t / 60;
if (t != 1) unit = xdrip.getAppContext().getString(R.string.unit_hours);
if (t != 1) unit = forceSym? "h" : xdrip.getAppContext().getString(R.string.unit_hours);
if (t > 24) {
unit = xdrip.getAppContext().getString(R.string.unit_day);
unit = forceSym? "d" : xdrip.getAppContext().getString(R.string.unit_day);
t = t / 24;
if (t != 1) unit = xdrip.getAppContext().getString(R.string.unit_days);
if (t != 1) unit = forceSym? "d" : xdrip.getAppContext().getString(R.string.unit_days);
if (t > 28) {
unit = xdrip.getAppContext().getString(R.string.unit_week);
unit = forceSym? "wk" : xdrip.getAppContext().getString(R.string.unit_week);
t = t / 7;
if (t != 1) unit = xdrip.getAppContext().getString(R.string.unit_weeks);
if (t != 1) unit = forceSym? "wk" : xdrip.getAppContext().getString(R.string.unit_weeks);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2175,7 +2175,9 @@ public static List<StatusItem> megaStatus() {
}

if (static_last_connected > 0) {
l.add(new StatusItem("Last Connected", niceTimeScalar(msSince(static_last_connected)) + " ago"));
l.add(new StatusItem("Last Connected", niceTimeScalar(msSince(static_last_connected), true) + " ago")); // Time symbols are used to avoid translations.
// This parameter is extremely important when troubleshooting connectivity. Let's use symbols for this parameter on this page so that those helping won't have to
// translate back to English or other languages, which could possibly cause errors.
}

if ((!lastState.startsWith("Service Stopped")) && (!lastState.startsWith("Not running")))
Expand Down

0 comments on commit 35b6ab7

Please sign in to comment.