You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2017/03/21 03:43:21 UTC
[14/30] kylin git commit: KYLIN-2508,
Trans the time to UTC time when set the range of building cube
KYLIN-2508,Trans the time to UTC time when set the range of building cube
Signed-off-by: Hongbin Ma <ma...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/3e6992da
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/3e6992da
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/3e6992da
Branch: refs/heads/master-hbase0.98
Commit: 3e6992da3b844d4642985f732c3269e354fed88c
Parents: 5155994
Author: luguosheng <55...@qq.com>
Authored: Wed Mar 15 17:21:39 2017 +0800
Committer: Hongbin Ma <ma...@apache.org>
Committed: Wed Mar 15 18:35:50 2017 +0800
----------------------------------------------------------------------
webapp/app/js/directives/directives.js | 77 +++++++++++++++--------------
1 file changed, 39 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/3e6992da/webapp/app/js/directives/directives.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/directives/directives.js b/webapp/app/js/directives/directives.js
index ca08493..bca3b03 100644
--- a/webapp/app/js/directives/directives.js
+++ b/webapp/app/js/directives/directives.js
@@ -249,49 +249,50 @@ KylinApp.directive('kylinPagination', function ($parse, $q) {
}
};
}).directive('dateTimepickerTimezone', function () {
- // this directive workaround to convert GMT0 timestamp to GMT date for datepicker
- return {
- restrict: 'A',
- priority: 1,
- require: 'ngModel',
- link: function (scope, element, attrs, ctrl) {
- ctrl.$formatters.push(function (value) {
-
- //set null for 0
- if(value===0){
- return '';
- }
-
- //return value;
- var newDate = new Date(value + (60000 * new Date().getTimezoneOffset()));
-
- var year = newDate.getFullYear();
- var month = (newDate.getMonth()+1)<10?'0'+(newDate.getMonth()+1):(newDate.getMonth()+1);
- var date = newDate.getDate()<10?'0'+newDate.getDate():newDate.getDate();
+ return {
+ restrict: 'A',
+ priority: 1,
+ require: 'ngModel',
+ link: function (scope, element, attrs, ctrl) {
+ ctrl.$formatters.push(function (value) {
- var hour = newDate.getHours()<10?'0'+newDate.getHours():newDate.getHours();
- var mins = newDate.getMinutes()<10?'0'+newDate.getMinutes():newDate.getMinutes();
- var seconds = newDate.getSeconds()<10?'0'+newDate.getSeconds():newDate.getSeconds();
+ //set null for 0
+ if(value===0){
+ return '';
+ }
- var viewVal = year+"-"+month+"-"+date+" "+hour+":"+mins+":"+seconds;
- return viewVal;
- });
+ //return value;
+ var newDate = new Date(value);
+ var year = newDate.getUTCFullYear();
+ var month = (newDate.getUTCMonth()+1)<10?'0'+(newDate.getUTCMonth()+1):(newDate.getUTCMonth()+1);
+ var date = newDate.getUTCDate()<10?'0'+newDate.getUTCDate():newDate.getUTCDate();
+ var hour = newDate.getUTCHours()<10?'0'+newDate.getUTCHours():newDate.getUTCHours();
+ var mins = newDate.getUTCMinutes()<10?'0'+newDate.getUTCMinutes():newDate.getUTCMinutes();
+ var seconds = newDate.getUTCSeconds()<10?'0'+newDate.getUTCSeconds():newDate.getUTCSeconds();
+ var viewVal = year+"-"+month+"-"+date+" "+hour+":"+mins+":"+seconds;
+ return viewVal;
+ });
- ctrl.$parsers.push(function (value) {
- var date;
- if(/^\d{4}-\d{1,2}-\d{1,2}(\s+\d{1,2}:\d{1,2}:\d{1,2})?$/.test(value)) {
- date=new Date(value);
- if(!date||date&&!date.getTime()){
- return value;
+ ctrl.$parsers.push(function (value) {
+ var date;
+ if(/^\d{4}-\d{1,2}-\d{1,2}(\s+\d{1,2}:\d{1,2}:\d{1,2})?$/.test(value)) {
+ date=new Date(value);
+ if(!date||date&&!date.getTime()){
+ return value;
+ }else{
+ var dateSplit=value.replace(/^\s+|\s+$/,'').replace(/\s+/,'-').split(/[:-]/);
+ var resultDate=[];
+ for(var i=0;i<6;i++){
+ resultDate[i]=dateSplit[i]||0;
+ }
+ return Date.UTC(resultDate[0],resultDate[1]-1,resultDate[2],resultDate[3],resultDate[4],resultDate[5]);
+ }
}else{
- return date.getTime()-(60000 * date.getTimezoneOffset());
+ return value;
}
- }else{
- return value;
- }
- });
- }
- };
+ });
+ }
+ };
}).directive("parametertree", function($compile) {
return {
restrict: "E",