You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2020/09/03 06:31:02 UTC

[skywalking-rocketbot-ui] branch master updated: set dateformat with timezone (#348)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-rocketbot-ui.git


The following commit(s) were added to refs/heads/master by this push:
     new 8bb656c  set dateformat with timezone (#348)
8bb656c is described below

commit 8bb656cdae28f7b99a90ccb07646f5830cacc29a
Author: xbkaishui <bi...@mycredigo.com>
AuthorDate: Thu Sep 3 14:30:53 2020 +0800

    set dateformat with timezone (#348)
    
    Co-authored-by: 吴晟 Wu Sheng <wu...@foxmail.com>
---
 package.json |  2 +-
 src/main.ts  | 14 +++++++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/package.json b/package.json
index 86ef869..a766cde 100644
--- a/package.json
+++ b/package.json
@@ -24,7 +24,7 @@
     "axios": "^0.18.0",
     "d3": "^5.9.1",
     "d3-tip": "^0.9.1",
-    "dayjs": "^1.8.8",
+    "dayjs": "^1.8.28",
     "echarts": "^4.1.0",
     "lodash": "^4.17.15",
     "noty": "^3.2.0-beta",
diff --git a/src/main.ts b/src/main.ts
index 122c2ff..7bd6f8d 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -17,6 +17,7 @@
 
 import Vue from 'vue';
 import moment from 'dayjs';
+import utcPlugin from 'dayjs/plugin/utc';
 import clickout from '@/utils/clickout';
 import tooltip from '@/utils/tooltip';
 import zh from '@/assets/lang/zh';
@@ -46,11 +47,14 @@ Vue.use(VModal, { dialog: true });
 Vue.directive('clickout', clickout);
 Vue.directive('tooltip', tooltip);
 
-Vue.filter(
-  'dateformat',
-  (dataStr: any, pattern: string = 'YYYY-MM-DD HH:mm:ss') =>
-    moment(dataStr).format(pattern),
-);
+moment.extend(utcPlugin);
+
+Vue.filter('dateformat', (dataStr: any, pattern: string = 'YYYY-MM-DD HH:mm:ss') => {
+  let utc: string = window.localStorage.getItem('utc') || (-(new Date().getTimezoneOffset() / 60)).toString();
+  return moment(dataStr)
+    .utcOffset(Number(utc) * 60)
+    .format(pattern);
+});
 
 const savedLanguage = window.localStorage.getItem('lang');
 let language = navigator.language.split('-')[0];