Skip to content

Commit

Permalink
[chore]: Remove moment package
Browse files Browse the repository at this point in the history
  • Loading branch information
zzyangh committed Jan 20, 2025
1 parent 136b8b8 commit 3ac62aa
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 21 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@
"json2md": "^2.0.0",
"lodash": "^4.17.21",
"lz-string": "1.5.0",
"moment": "^2.29.4",
"monaco-editor": "^0.34.1",
"nprogress": "^0.2.0",
"query-string": "^7.1.1",
Expand Down
5 changes: 2 additions & 3 deletions packages/shared/lib/utils/Common.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { AxiosResponse } from 'axios';
import moment from 'moment';
import i18n from 'i18next';
import { MIMETypeEnum, ResponseBlobJsonType } from '../enum';
import { Dayjs } from 'dayjs';
import dayjs, { Dayjs } from 'dayjs';

export const emailValidate = (email: string): boolean => {
if (!email || typeof email !== 'string') {
Expand Down Expand Up @@ -47,7 +46,7 @@ export const formatTime = (
if (!timeVal) {
return defaultVal;
}
return moment(timeVal).format('YYYY-MM-DD HH:mm:ss');
return dayjs(timeVal).format('YYYY-MM-DD HH:mm:ss');
};

export function translateTimeForRequest(time: undefined): undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/lib/utils/__tests__/Common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('utils/Common', () => {
spy.mockRestore();
});

test('should format moment to YYYY-MM-DD HH:mm:ss', () => {
test('should format dayjs to YYYY-MM-DD HH:mm:ss', () => {
expect(formatTime('2021-06-09T08:11:52Z')).toBe('2021-06-09 16:11:52');
expect(formatTime('2021-06-09T08:11:52Z', '--')).toBe(
'2021-06-09 16:11:52'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { Progress, Typography } from 'antd';
import { useTranslation } from 'react-i18next';
import useThemeStyleData from '../../../../../hooks/useThemeStyleData';
import { useGetLevelData } from '../../../hooks/useGetLevelData';
import moment from 'moment';
import { ClockCircleOutlined } from '@actiontech/icons';
import { formatTime } from '@actiontech/shared/lib/utils/Common';

const WorkflowTemplateAuthInfo: React.FC<WorkflowTemplateAuthInfoProps> = ({
level,
Expand Down Expand Up @@ -60,9 +60,7 @@ const WorkflowTemplateAuthInfo: React.FC<WorkflowTemplateAuthInfoProps> = ({
</Typography.Text>
<Typography.Paragraph className="auth-info-item auth-info-time">
<ClockCircleOutlined />
<span className="update-time">
{time ? moment(time).format('YYYY-MM-DD HH:mm:ss') : '-'}
</span>
<span className="update-time">{time ? formatTime(time) : '-'}</span>
</Typography.Paragraph>
</WorkflowTemplateAuthInfoStyleWrapper>
</WorkflowTemplateDetailRightContentStyleWrapper>
Expand Down
16 changes: 4 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3ac62aa

Please sign in to comment.