YARN-7750. [UI2] Render time related fields in all pages to the browser timezone. Contributed by Vasudevan Skm.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/8e5472b1 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/8e5472b1 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/8e5472b1 Branch: refs/heads/HDFS-7240 Commit: 8e5472b1e63f1c50e253e64702468da2bb38e476 Parents: 1093a73 Author: Sunil G <[email protected]> Authored: Thu Jan 18 18:49:19 2018 +0530 Committer: Sunil G <[email protected]> Committed: Thu Jan 18 18:54:41 2018 +0530 ---------------------------------------------------------------------- .../src/main/webapp/app/utils/converter.js | 7 +++-- .../src/main/webapp/app/utils/date-utils.js | 27 ++++++++++++++++++++ .../src/main/webapp/ember-cli-build.js | 1 + 3 files changed, 31 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/8e5472b1/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/utils/converter.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/utils/converter.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/utils/converter.js index 74cc916..d7de4e7 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/utils/converter.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/utils/converter.js @@ -17,6 +17,7 @@ */ import Constants from 'yarn-ui/constants'; +import { convertTimestampWithTz } from "./date-utils"; export default { containerIdToAttemptId: function(containerId) { @@ -82,12 +83,10 @@ export default { return total * 1000; }, timeStampToDate: function(timeStamp) { - var dateTimeString = moment(parseInt(timeStamp)).format("YYYY/MM/DD HH:mm:ss"); - return dateTimeString; + return convertTimestampWithTz(timeStamp, "YYYY/MM/DD HH:mm:ss"); }, timeStampToDateOnly: function(timeStamp) { - var dateTimeString = moment(parseInt(timeStamp)).format("YYYY/MM/DD"); - return dateTimeString; + return convertTimestampWithTz(timeStamp, "YYYY/MM/DD"); }, dateToTimeStamp: function(date) { if (date) { http://git-wip-us.apache.org/repos/asf/hadoop/blob/8e5472b1/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/utils/date-utils.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/utils/date-utils.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/utils/date-utils.js new file mode 100644 index 0000000..83dd200 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/utils/date-utils.js @@ -0,0 +1,27 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +const defaultTz = "America/Los_Angeles"; + +const getDefaultTimezone = () => { + return moment.tz.guess() || defaultTz; +}; + +export const convertTimestampWithTz = (timestamp, format = "YYYY/MM/DD") => + moment.tz(timestamp, getDefaultTimezone()).format(format); http://git-wip-us.apache.org/repos/asf/hadoop/blob/8e5472b1/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/ember-cli-build.js ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/ember-cli-build.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/ember-cli-build.js index 6af45fc..db09ae3 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/ember-cli-build.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/ember-cli-build.js @@ -42,6 +42,7 @@ module.exports = function(defaults) { app.import("bower_components/datatables/media/css/jquery.dataTables.min.css"); app.import("bower_components/datatables/media/js/jquery.dataTables.min.js"); app.import("bower_components/momentjs/min/moment.min.js"); + app.import("bower_components/moment-timezone/builds/moment-timezone-with-data-2010-2020.min.js"); app.import("bower_components/select2/dist/css/select2.min.css"); app.import("bower_components/select2/dist/js/select2.min.js"); app.import('bower_components/jquery-ui/jquery-ui.js'); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
