feat: add code onwer

chore: update readme.md

chore: update deps

chore: update deps

chore: update deps
This commit is contained in:
vben
2024-06-16 19:17:34 +08:00
parent 382652e0f4
commit 9278c4b416
42 changed files with 607 additions and 507 deletions

View File

@@ -33,7 +33,6 @@
},
"dependencies": {
"@vben-core/cache": "workspace:*",
"@vben-core/helpers": "workspace:*",
"@vben-core/toolkit": "workspace:*",
"@vben-core/typings": "workspace:*",
"@vueuse/core": "^10.11.0",

View File

@@ -35,7 +35,6 @@
"publishConfig": {
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
}
}

View File

@@ -1,35 +0,0 @@
import { describe, expect, it } from 'vitest';
import { formatDate, formatDateTime } from './date';
describe('formatDate', () => {
it('should return "2023-01-01" when passed new Date("2023-01-01T00:00:00.000Z")', () => {
const date = new Date('2023-01-01T00:00:00.000Z');
const actual = formatDate(date);
expect(actual).toBe('2023-01-01');
});
it('should return "2023-01-01" when passed new Date("2023-01-01T00:00:00")', () => {
const date = new Date('2023-01-01T00:00:00.000Z');
const actual = formatDate(date, 'YYYY-MM-DD');
expect(actual).toBe('2023-01-01');
});
it('should throw an error when passed an invalid date', () => {
const date = '2018-10-10-10-10-10';
expect(formatDate(date)).toBe('Invalid Date');
});
});
describe('formatDateTime', () => {
it('should return "2023-01-01" when passed new Date("2023-01-01T00:00:00.000Z")', () => {
const date = new Date('2023-01-01T00:00:00.000Z');
const actual = formatDateTime(date);
expect(actual).toBe('2023-01-01 08:00:00');
});
it('should throw an error when passed an invalid date', () => {
const date = '2018-10-10-10-10-10';
expect(formatDateTime(date)).toBe('Invalid Date');
});
});

View File

@@ -1,25 +0,0 @@
import dateFunc, { type ConfigType } from 'dayjs';
const DATE_TIME_TEMPLATE = 'YYYY-MM-DD HH:mm:ss';
const DATE_TEMPLATE = 'YYYY-MM-DD';
/**
* @zh_CN 格式化日期时间
* @param date 待格式化的日期时间
* @param format 格式化的方式
* @returns 格式化后的日期字符串默认YYYY-MM-DD HH:mm:ss
*/
function formatDate(date?: ConfigType, format = DATE_TEMPLATE): string {
return dateFunc(date).format(format);
}
/**
* @zh_CN 格式化日期时间
* @param date 待格式化的日期时间
* @returns 格式化后的日期字符串
*/
function formatDateTime(date?: ConfigType): string {
return formatDate(date, DATE_TIME_TEMPLATE);
}
export { formatDate, formatDateTime };

View File

@@ -1,5 +1,4 @@
export * from './color';
export * from './date';
export * from './diff';
export * from './hash';
export * from './inference';

View File

@@ -35,7 +35,6 @@
"publishConfig": {
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
}
}

View File

@@ -35,7 +35,6 @@
"publishConfig": {
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
}
}

View File

@@ -40,7 +40,6 @@
"publishConfig": {
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
}
}

View File

@@ -35,7 +35,6 @@
"publishConfig": {
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
}
}

View File

@@ -35,7 +35,6 @@
"publishConfig": {
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
}
}

View File

@@ -35,7 +35,6 @@
"publishConfig": {
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
}
}

View File

@@ -32,7 +32,6 @@
"publishConfig": {
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
}
}