Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4978)

Unified Diff: appengine/swarming/ui/res/imp/common/common-behavior.html

Issue 2920473002: Make tasklist and taskpage use subsecond durations (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/swarming/ui/res/imp/common/common-behavior.html
diff --git a/appengine/swarming/ui/res/imp/common/common-behavior.html b/appengine/swarming/ui/res/imp/common/common-behavior.html
index bbb605d58194a3cdc3888bfd70f80b42a45dd10d..2b753162608abdd0073f3cdc396adf8f68691fb5 100644
--- a/appengine/swarming/ui/res/imp/common/common-behavior.html
+++ b/appengine/swarming/ui/res/imp/common/common-behavior.html
@@ -157,7 +157,29 @@
},
_humanDuration: function(timeInSecs) {
- return sk.human.strDuration(timeInSecs) || "0s";
+ // If the timeInSecs is 0 (e.g. duration of Terminate bot tasks), we
+ // still want to display 0s.
+ if (timeInSecs === 0 || timeInSecs === "0") {
stephana 2017/05/31 15:00:42 .... timeInSecs === "0" should be omitted IMO. Str
kjlubick 2017/05/31 15:02:53 I put it in there such that 0 and "0" become "0s"
stephana 2017/05/31 17:29:19 Ack
+ return "0s";
+ }
+ // Otherwise, if timeInSecs is falsey (e.g. undefined), return empty
+ // string to reflect that.
+ if (!timeInSecs) {
+ return "";
+ }
+ ptimeInSecs = parseFloat(timeInSecs);
+ // On a bad parse (shouldn't happen), show original.
+ if (!ptimeInSecs) {
+ return timeInSecs + " seconds";
+ }
+
+ // For times greater than a minute, make them human readable
+ // e.g. 2h 43m or 13m 42s
+ if (ptimeInSecs > 60){
+ return sk.human.strDuration(ptimeInSecs);
+ }
+ // For times less than a minute, add 10ms resolution.
+ return ptimeInSecs.toFixed(2)+"s";
},
_not: function(a) {
« no previous file with comments | « appengine/swarming/ui/build/elements.html ('k') | appengine/swarming/ui/res/imp/tasklist/task-list-data.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698