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 74cc9161d31c..d7de4e7dca1c 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) { 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 000000000000..83dd200143f6 --- /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); 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 6af45fc9c357..db09ae3c7e8d 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');