YARN-7750. [UI2] Render time related fields in all pages to the browser timezone. Contributed by Vasudevan Skm.

This commit is contained in:
Sunil G 2018-01-18 18:49:19 +05:30
parent 1093a73689
commit 8e5472b1e6
3 changed files with 31 additions and 4 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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');