From af61b59c5eade626ff394383d622e628cb013f39 Mon Sep 17 00:00:00 2001 From: Hongchao Deng Date: Thu, 17 Dec 2020 20:11:18 -0800 Subject: [PATCH] return go time in Format RFC3339 to match js Date (#785) Signed-off-by: Hongchao Deng --- dashboard/src/pages/Application/index.tsx | 3 +-- dashboard/src/utils/compatibleDayjs.ts | 14 -------------- pkg/serverlib/application.go | 3 ++- 3 files changed, 3 insertions(+), 17 deletions(-) delete mode 100644 dashboard/src/utils/compatibleDayjs.ts diff --git a/dashboard/src/pages/Application/index.tsx b/dashboard/src/pages/Application/index.tsx index 266d3c22e..9c1652d0e 100644 --- a/dashboard/src/pages/Application/index.tsx +++ b/dashboard/src/pages/Application/index.tsx @@ -4,7 +4,6 @@ import { Button, Card, message, Popconfirm, Space, Table } from 'antd'; import { Link, useModel, useRequest } from 'umi'; import { deleteApplication, getApplications } from '@/services/application'; -import compatibleDayjs from '@/utils/compatibleDayjs'; import { PlusOutlined } from '@ant-design/icons'; import { PageContainer } from '@ant-design/pro-layout'; @@ -81,7 +80,7 @@ export default () => { dataIndex: 'createdTime', key: 'createdTime', render: (text) => { - return compatibleDayjs(text).format('YYYY-MM-DD HH:mm:ss'); + return text; }, }, { diff --git a/dashboard/src/utils/compatibleDayjs.ts b/dashboard/src/utils/compatibleDayjs.ts deleted file mode 100644 index 7d858c10d..000000000 --- a/dashboard/src/utils/compatibleDayjs.ts +++ /dev/null @@ -1,14 +0,0 @@ -import dayjs from 'dayjs'; -import customParseFormat from 'dayjs/plugin/customParseFormat'; -import timezone from 'dayjs/plugin/timezone'; -import utc from 'dayjs/plugin/utc'; - -dayjs.extend(customParseFormat); -dayjs.extend(utc); -dayjs.extend(timezone); - -const FORMAT = 'YYYY-MM-DD HH:mm:ss ZZ'; - -export default function compatibleDayjs(date: string) { - return dayjs(date, FORMAT).tz(); -} diff --git a/pkg/serverlib/application.go b/pkg/serverlib/application.go index 90b68d721..2f3423d08 100644 --- a/pkg/serverlib/application.go +++ b/pkg/serverlib/application.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "sort" + "time" "github.com/AlecAivazis/survey/v2" "github.com/spf13/cobra" @@ -153,7 +154,7 @@ func RetrieveApplicationStatusByName(ctx context.Context, c client.Client, appli } applicationMeta.Name = appConfig.Name applicationMeta.Status = status - applicationMeta.CreatedTime = appConfig.CreationTimestamp.String() + applicationMeta.CreatedTime = appConfig.CreationTimestamp.Format(time.RFC3339) for _, com := range appConfig.Spec.Components { componentName := com.ComponentName