From 4218f529c3bd31e6a3bd56852ab607a81b41db35 Mon Sep 17 00:00:00 2001 From: Weiqing Yang Date: Tue, 9 Aug 2016 22:53:13 -0700 Subject: [PATCH] [SPARK-16986][WEB UI] Make 'Started' time, 'Completed' time and 'Last Updated' time in history server UI to the user local time --- .../org/apache/spark/ui/static/historypage.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/core/src/main/resources/org/apache/spark/ui/static/historypage.js b/core/src/main/resources/org/apache/spark/ui/static/historypage.js index 5b9afb59ef8e2..00346e7b62af5 100644 --- a/core/src/main/resources/org/apache/spark/ui/static/historypage.js +++ b/core/src/main/resources/org/apache/spark/ui/static/historypage.js @@ -31,9 +31,20 @@ function makeIdNumeric(id) { return resl; } +function padLeft(val) { + if(val < 10) return "0" + val; + else return val; +} + function formatDate(date) { - if (date <= 0) return "-"; - else return date.split(".")[0].replace("T", " "); + if (date <= 0) { + return "-"; + } else { + var localDate = new Date(date.split(".")[0].replace("T", " ") + " UTC"); + return localDate.getFullYear() + "-" + padLeft(localDate.getMonth() + 1) + "-" + + padLeft(localDate.getDate()) + " " + padLeft(localDate.getHours()) + ":" + + padLeft(localDate.getMinutes()) + ":" + padLeft(localDate.getSeconds()); + } } function getParameterByName(name, searchString) {