* Console: Display durations with new formatDuration2()
This commit is contained in:
@ -32,8 +32,9 @@ then
|
||||
sed 's/..,\(..*\)/_("\1");/' $CFILE >> $JFILE
|
||||
fi
|
||||
|
||||
# list specific files in router/ here, so we don't scan the whole tree
|
||||
# list specific files in core/ and router/ here, so we don't scan the whole tree
|
||||
ROUTERFILES="\
|
||||
../../../core/java/src/net/i2p/data/DataHelper.java \
|
||||
../../../router/java/src/net/i2p/router/RouterThrottleImpl.java \
|
||||
../../../router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java \
|
||||
../../../router/java/src/net/i2p/router/transport/TransportManager.java \
|
||||
|
@ -62,12 +62,12 @@ public class ConfigRestartBean {
|
||||
buf.append("</b></center>");
|
||||
} else if (shuttingDown) {
|
||||
buf.append("<center><b>");
|
||||
buf.append(_("Shutdown in {0}", DataHelper.formatDuration(timeRemaining), ctx));
|
||||
buf.append(_("Shutdown in {0}", DataHelper.formatDuration2(timeRemaining), ctx));
|
||||
buf.append("</b></center><br>");
|
||||
buttons(ctx, buf, urlBase, systemNonce, SET1);
|
||||
} else if (restarting) {
|
||||
buf.append("<center><b>");
|
||||
buf.append(_("Restart in {0}", DataHelper.formatDuration(timeRemaining), ctx));
|
||||
buf.append(_("Restart in {0}", DataHelper.formatDuration2(timeRemaining), ctx));
|
||||
buf.append("</b></center><br>");
|
||||
buttons(ctx, buf, urlBase, systemNonce, SET2);
|
||||
} else {
|
||||
|
@ -130,7 +130,7 @@ public class ConfigUpdateHandler extends FormHandler {
|
||||
try { oldFreq = Long.parseLong(oldFreqStr); } catch (NumberFormatException nfe) {}
|
||||
if (_refreshFrequency != oldFreq) {
|
||||
_context.router().setConfigSetting(PROP_REFRESH_FREQUENCY, ""+_refreshFrequency);
|
||||
addFormNotice(_("Updating refresh frequency to") + " " + DataHelper.formatDuration(_refreshFrequency));
|
||||
addFormNotice(_("Updating refresh frequency to") + " " + DataHelper.formatDuration2(_refreshFrequency));
|
||||
}
|
||||
|
||||
if ( (_updatePolicy != null) && (_updatePolicy.length() > 0) ) {
|
||||
|
@ -87,7 +87,7 @@ public class ConfigUpdateHelper extends HelperBase {
|
||||
if (PERIODS[i] == -1)
|
||||
buf.append("\">" + _("Never") + "</option>\n");
|
||||
else
|
||||
buf.append("\">" + _("Every") + " ").append(DataHelper.formatDuration(PERIODS[i])).append("</option>\n");
|
||||
buf.append("\">" + _("Every") + " ").append(DataHelper.formatDuration2(PERIODS[i])).append("</option>\n");
|
||||
}
|
||||
buf.append("</select>\n");
|
||||
return buf.toString();
|
||||
|
@ -93,7 +93,7 @@ public class GraphHelper extends HelperBase {
|
||||
SummaryListener lsnr = (SummaryListener)iter.next();
|
||||
Rate r = lsnr.getRate();
|
||||
// e.g. "statname for 60m"
|
||||
String title = _("{0} for {1}", r.getRateStat().getName(), DataHelper.formatDuration(_periodCount * r.getPeriod()));
|
||||
String title = _("{0} for {1}", r.getRateStat().getName(), DataHelper.formatDuration2(_periodCount * r.getPeriod()));
|
||||
_out.write("<a href=\"viewstat.jsp?stat="
|
||||
+ r.getRateStat().getName()
|
||||
+ "&showEvents=" + _showEvents
|
||||
|
@ -150,9 +150,9 @@ public class NetDbRenderer {
|
||||
buf.append(")</b><br>\n");
|
||||
long exp = ls.getEarliestLeaseDate()-now;
|
||||
if (exp > 0)
|
||||
buf.append(_("Expires in {0}", DataHelper.formatDuration(exp))).append("<br>\n");
|
||||
buf.append(_("Expires in {0}", DataHelper.formatDuration2(exp))).append("<br>\n");
|
||||
else
|
||||
buf.append(_("Expired {0} ago", DataHelper.formatDuration(0-exp))).append("<br>\n");
|
||||
buf.append(_("Expired {0} ago", DataHelper.formatDuration2(0-exp))).append("<br>\n");
|
||||
if (debug) {
|
||||
buf.append("RAP? " + ls.getReceivedAsPublished() + ' ');
|
||||
buf.append("RAR? " + ls.getReceivedAsReply() + ' ');
|
||||
@ -352,13 +352,13 @@ public class NetDbRenderer {
|
||||
long age = _context.clock().now() - info.getPublished();
|
||||
if (isUs && _context.router().isHidden()) {
|
||||
buf.append("<b>").append(_("Hidden")).append(", ").append(_("Updated")).append(":</b> ")
|
||||
.append(_("{0} ago", DataHelper.formatDuration(age))).append("<br>\n");
|
||||
.append(_("{0} ago", DataHelper.formatDuration2(age))).append("<br>\n");
|
||||
} else if (age > 0) {
|
||||
buf.append("<b>").append(_("Published")).append(":</b> ")
|
||||
.append(_("{0} ago", DataHelper.formatDuration(age))).append("<br>\n");
|
||||
.append(_("{0} ago", DataHelper.formatDuration2(age))).append("<br>\n");
|
||||
} else {
|
||||
// shouldnt happen
|
||||
buf.append("<b>" + _("Published") + ":</b> in ").append(DataHelper.formatDuration(0-age)).append("???<br>\n");
|
||||
buf.append("<b>" + _("Published") + ":</b> in ").append(DataHelper.formatDuration2(0-age)).append("???<br>\n");
|
||||
}
|
||||
buf.append("<b>" + _("Address(es)") + ":</b> ");
|
||||
String country = _context.commSystem().getCountry(info.getIdentity().getHash());
|
||||
|
@ -80,13 +80,13 @@ public class NewsFetcher implements Runnable, EepGet.StatusListener {
|
||||
long now = _context.clock().now();
|
||||
if (_lastUpdated > 0) {
|
||||
buf.append(Messages.getString("News last updated {0} ago.",
|
||||
DataHelper.formatDuration(now - _lastUpdated),
|
||||
DataHelper.formatDuration2(now - _lastUpdated),
|
||||
_context))
|
||||
.append('\n');
|
||||
}
|
||||
if (_lastFetch > _lastUpdated) {
|
||||
buf.append(Messages.getString("News last checked {0} ago.",
|
||||
DataHelper.formatDuration(now - _lastFetch),
|
||||
DataHelper.formatDuration2(now - _lastFetch),
|
||||
_context));
|
||||
}
|
||||
return buf.toString();
|
||||
@ -136,7 +136,7 @@ public class NewsFetcher implements Runnable, EepGet.StatusListener {
|
||||
return true;
|
||||
} else {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Last fetched " + DataHelper.formatDuration(_context.clock().now() - _lastFetch) + " ago");
|
||||
_log.debug("Last fetched " + DataHelper.formatDuration2(_context.clock().now() - _lastFetch) + " ago");
|
||||
return false;
|
||||
}
|
||||
} catch (NumberFormatException nfe) {
|
||||
|
@ -217,26 +217,26 @@ class ProfileOrganizerRenderer {
|
||||
buf.append("<td align=\"right\">").append(num(prof.getIntegrationValue())).append("</td>");
|
||||
long time;
|
||||
time = now - prof.getLastHeardAbout();
|
||||
buf.append("<td align=\"right\">").append(DataHelper.formatDuration(time)).append("</td>");
|
||||
buf.append("<td align=\"right\">").append(DataHelper.formatDuration2(time)).append("</td>");
|
||||
time = now - prof.getLastHeardFrom();
|
||||
buf.append("<td align=\"right\">").append(DataHelper.formatDuration(time)).append("</td>");
|
||||
buf.append("<td align=\"right\">").append(DataHelper.formatDuration2(time)).append("</td>");
|
||||
time = now - prof.getLastSendSuccessful();
|
||||
buf.append("<td align=\"right\">").append(DataHelper.formatDuration(time)).append("</td>");
|
||||
buf.append("<td align=\"right\">").append(DataHelper.formatDuration2(time)).append("</td>");
|
||||
time = now - prof.getLastSendFailed();
|
||||
buf.append("<td align=\"right\">").append(DataHelper.formatDuration(time)).append("</td>");
|
||||
buf.append("<td align=\"right\">").append(DataHelper.formatDuration2(time)).append("</td>");
|
||||
buf.append("<td align=\"right\">").append(avg(prof, 10*60*1000l)).append("</td>");
|
||||
buf.append("<td align=\"right\">").append(avg(prof, 60*60*1000l)).append("</td>");
|
||||
buf.append("<td align=\"right\">").append(avg(prof, 24*60*60*1000l)).append("</td>");
|
||||
DBHistory dbh = prof.getDBHistory();
|
||||
if (dbh != null) {
|
||||
time = now - dbh.getLastLookupSuccessful();
|
||||
buf.append("<td align=\"right\">").append(DataHelper.formatDuration(time)).append("</td>");
|
||||
buf.append("<td align=\"right\">").append(DataHelper.formatDuration2(time)).append("</td>");
|
||||
time = now - dbh.getLastLookupFailed();
|
||||
buf.append("<td align=\"right\">").append(DataHelper.formatDuration(time)).append("</td>");
|
||||
buf.append("<td align=\"right\">").append(DataHelper.formatDuration2(time)).append("</td>");
|
||||
time = now - dbh.getLastStoreSuccessful();
|
||||
buf.append("<td align=\"right\">").append(DataHelper.formatDuration(time)).append("</td>");
|
||||
buf.append("<td align=\"right\">").append(DataHelper.formatDuration2(time)).append("</td>");
|
||||
time = now - dbh.getLastStoreFailed();
|
||||
buf.append("<td align=\"right\">").append(DataHelper.formatDuration(time)).append("</td>");
|
||||
buf.append("<td align=\"right\">").append(DataHelper.formatDuration2(time)).append("</td>");
|
||||
buf.append("<td align=\"right\">").append(davg(dbh, 60*60*1000l)).append("</td>");
|
||||
buf.append("<td align=\"right\">").append(davg(dbh, 24*60*60*1000l)).append("</td>");
|
||||
} else {
|
||||
@ -323,7 +323,7 @@ class ProfileOrganizerRenderer {
|
||||
if (c == 0)
|
||||
return _(NA);
|
||||
double d = r.getCurrentTotalValue() + r.getLastTotalValue();
|
||||
return Math.round(d/c) + "ms";
|
||||
return DataHelper.formatDuration2(Math.round(d/c));
|
||||
}
|
||||
|
||||
private String davg (DBHistory dbh, long rate) {
|
||||
|
@ -52,7 +52,7 @@ public class ShitlistRenderer {
|
||||
buf.append("<li>").append(_context.commSystem().renderPeerHTML(key));
|
||||
buf.append(' ');
|
||||
long expires = entry.expireOn-_context.clock().now();
|
||||
String expireString = DataHelper.formatDuration(expires);
|
||||
String expireString = DataHelper.formatDuration2(expires);
|
||||
if (expires < 5l*24*60*60*1000)
|
||||
buf.append(_("Temporary ban expiring in {0}", expireString));
|
||||
else
|
||||
|
@ -366,7 +366,7 @@ public class SummaryBarRenderer {
|
||||
.append(_("Used"))
|
||||
.append(":</b></td><td align=\"right\">")
|
||||
.append(_helper.getInboundTransferred())
|
||||
.append(" / ")
|
||||
.append(" / ")
|
||||
.append(_helper.getOutboundTransferred())
|
||||
.append("</td></tr></table>\n" +
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class SummaryHelper extends HelperBase {
|
||||
if (router == null)
|
||||
return "[not up]";
|
||||
else
|
||||
return DataHelper.formatDuration(router.getUptime());
|
||||
return DataHelper.formatDuration2(router.getUptime());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,7 +74,7 @@ public class SummaryHelper extends HelperBase {
|
||||
long diff = Math.abs(ms);
|
||||
if (diff < 3000)
|
||||
return "";
|
||||
return " (" + DataHelper.formatDuration(diff) + " " + _("skew") + ")";
|
||||
return " (" + DataHelper.formatDuration2(diff) + " " + _("skew") + ")";
|
||||
}
|
||||
**/
|
||||
|
||||
@ -105,7 +105,7 @@ public class SummaryHelper extends HelperBase {
|
||||
long skew = _context.commSystem().getFramedAveragePeerClockSkew(33);
|
||||
// Display the actual skew, not the offset
|
||||
if (Math.abs(skew) > 30*1000)
|
||||
return _("ERR-Clock Skew of {0}", DataHelper.formatDuration(Math.abs(skew)));
|
||||
return _("ERR-Clock Skew of {0}", DataHelper.formatDuration2(Math.abs(skew)));
|
||||
if (_context.router().isHidden())
|
||||
return _("Hidden");
|
||||
|
||||
@ -321,7 +321,7 @@ public class SummaryHelper extends HelperBase {
|
||||
fmt = new DecimalFormat("#0.0");
|
||||
else
|
||||
fmt = new DecimalFormat("#0.00");
|
||||
return fmt.format(in) + " / " + fmt.format(out) +
|
||||
return fmt.format(in) + " / " + fmt.format(out) + " " +
|
||||
(mega ? 'M' : 'K');
|
||||
}
|
||||
|
||||
@ -336,7 +336,7 @@ public class SummaryHelper extends HelperBase {
|
||||
|
||||
long received = _context.bandwidthLimiter().getTotalAllocatedInboundBytes();
|
||||
|
||||
return DataHelper.formatSize(received) + 'B';
|
||||
return DataHelper.formatSize2(received) + 'B';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -349,7 +349,7 @@ public class SummaryHelper extends HelperBase {
|
||||
return "0";
|
||||
|
||||
long sent = _context.bandwidthLimiter().getTotalAllocatedOutboundBytes();
|
||||
return DataHelper.formatSize(sent) + 'B';
|
||||
return DataHelper.formatSize2(sent) + 'B';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -389,7 +389,7 @@ public class SummaryHelper extends HelperBase {
|
||||
long timeToExpire = ls.getEarliestLeaseDate() - _context.clock().now();
|
||||
if (timeToExpire < 0) {
|
||||
// red or yellow light
|
||||
buf.append("<td><img src=\"/themes/console/images/local_inprogress.png\" alt=\"").append(_("Rebuilding")).append("…\" title=\"").append(_("Leases expired")).append(" ").append(DataHelper.formatDuration(0-timeToExpire));
|
||||
buf.append("<td><img src=\"/themes/console/images/local_inprogress.png\" alt=\"").append(_("Rebuilding")).append("…\" title=\"").append(_("Leases expired")).append(" ").append(DataHelper.formatDuration2(0-timeToExpire));
|
||||
buf.append(" ").append(_("ago")).append(". ").append(_("Rebuilding")).append("…\"></td></tr>\n");
|
||||
} else {
|
||||
// green light
|
||||
@ -510,10 +510,10 @@ public class SummaryHelper extends HelperBase {
|
||||
*/
|
||||
public String getJobLag() {
|
||||
if (_context == null)
|
||||
return "0ms";
|
||||
return "0 ms";
|
||||
|
||||
Rate lagRate = _context.statManager().getRate("jobQueue.jobLag").getRate(60*1000);
|
||||
return ((int)lagRate.getAverageValue()) + "ms";
|
||||
return DataHelper.formatDuration2((long)lagRate.getAverageValue());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -523,9 +523,9 @@ public class SummaryHelper extends HelperBase {
|
||||
*/
|
||||
public String getMessageDelay() {
|
||||
if (_context == null)
|
||||
return "0ms";
|
||||
return "0 ms";
|
||||
|
||||
return _context.throttle().getMessageDelay() + "ms";
|
||||
return DataHelper.formatDuration2(_context.throttle().getMessageDelay());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -535,9 +535,9 @@ public class SummaryHelper extends HelperBase {
|
||||
*/
|
||||
public String getTunnelLag() {
|
||||
if (_context == null)
|
||||
return "0ms";
|
||||
return "0 ms";
|
||||
|
||||
return _context.throttle().getTunnelLag() + "ms";
|
||||
return DataHelper.formatDuration2(_context.throttle().getTunnelLag());
|
||||
}
|
||||
|
||||
public String getTunnelStatus() {
|
||||
|
@ -78,7 +78,12 @@ class SummaryRenderer {
|
||||
def.setBaseValue(1024);
|
||||
if (!hideTitle) {
|
||||
String title;
|
||||
String p = DataHelper.formatDuration(_listener.getRate().getPeriod());
|
||||
String p;
|
||||
// we want the formatting and translation of formatDuration2(), except not zh, and not the
|
||||
if ("zh".equals(Messages.getLanguage(_context)))
|
||||
p = DataHelper.formatDuration(_listener.getRate().getPeriod());
|
||||
else
|
||||
p = DataHelper.formatDuration2(_listener.getRate().getPeriod()).replace(" ", " ");
|
||||
if (showEvents)
|
||||
// Note to translators: all runtime zh translation disabled in this file, no font available in RRD
|
||||
title = name + ' ' + _("events in {0}", p);
|
||||
|
@ -102,7 +102,7 @@ public class TunnelRenderer {
|
||||
out.write("<td class=\"cells\"> </td>");
|
||||
long timeLeft = cfg.getExpiration()-_context.clock().now();
|
||||
if (timeLeft > 0)
|
||||
out.write("<td class=\"cells\" align=\"center\">" + DataHelper.formatDuration(timeLeft) + "</td>");
|
||||
out.write("<td class=\"cells\" align=\"center\">" + DataHelper.formatDuration2(timeLeft) + "</td>");
|
||||
else
|
||||
out.write("<td class=\"cells\" align=\"center\">(" + _("grace period") + ")</td>");
|
||||
out.write("<td class=\"cells\" align=\"center\">" + cfg.getProcessedMessagesCount() + " KB</td>");
|
||||
@ -175,7 +175,7 @@ public class TunnelRenderer {
|
||||
out.write("<tr> <td class=\"cells\" align=\"center\"><img src=\"/themes/console/images/inbound.png\" alt=\"Inbound\" title=\"Inbound\"></td>");
|
||||
else
|
||||
out.write("<tr> <td class=\"cells\" align=\"center\"><img src=\"/themes/console/images/outbound.png\" alt=\"Outbound\" title=\"Outbound\"></td>");
|
||||
out.write(" <td class=\"cells\" align=\"center\">" + DataHelper.formatDuration(timeLeft) + "</td>\n");
|
||||
out.write(" <td class=\"cells\" align=\"center\">" + DataHelper.formatDuration2(timeLeft) + "</td>\n");
|
||||
out.write(" <td class=\"cells\" align=\"center\">" + info.getProcessedMessagesCount() + " KB</td>\n");
|
||||
for (int j = 0; j < info.getLength(); j++) {
|
||||
Hash peer = info.getPeer(j);
|
||||
|
Reference in New Issue
Block a user