@daysnap/utils 0.0.50 → 0.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/formatDate.d.ts +2 -1
- package/es/formatDate.js +4 -2
- package/es/formatDateStr.d.ts +4 -0
- package/es/formatDateStr.js +6 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/lib/formatDate.d.ts +2 -1
- package/lib/formatDate.js +4 -2
- package/lib/formatDateStr.d.ts +4 -0
- package/lib/formatDateStr.js +10 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +1 -1
package/es/formatDate.d.ts
CHANGED
package/es/formatDate.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { isString } from './isString';
|
|
2
|
+
import { formatDateStr } from './formatDateStr';
|
|
2
3
|
/**
|
|
3
4
|
* 格式化日期
|
|
5
|
+
* 默认的当前日期 yyyy-MM-dd hh:mm:ss
|
|
4
6
|
*/
|
|
5
|
-
export function formatDate(val, fmt = 'yyyy-MM-dd hh:mm:ss') {
|
|
7
|
+
export function formatDate(val = new Date(), fmt = 'yyyy-MM-dd hh:mm:ss') {
|
|
6
8
|
let v = val;
|
|
7
9
|
if (isString(v)) {
|
|
8
10
|
// fix iOS new Date() 不支持 2020-01-01 格式,需转换为 2020/01/01
|
|
9
|
-
v = v
|
|
11
|
+
v = formatDateStr(v);
|
|
10
12
|
}
|
|
11
13
|
const date = new Date(v);
|
|
12
14
|
const o = {
|
package/es/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export * from './filterName';
|
|
|
19
19
|
export * from './filterPhone';
|
|
20
20
|
export * from './formatAmount';
|
|
21
21
|
export * from './formatDate';
|
|
22
|
+
export * from './formatDateStr';
|
|
22
23
|
export * from './formatMessage';
|
|
23
24
|
export * from './formatPathParams';
|
|
24
25
|
export * from './getBlobByUrl';
|
package/es/index.js
CHANGED
|
@@ -20,6 +20,7 @@ export * from './filterName';
|
|
|
20
20
|
export * from './filterPhone';
|
|
21
21
|
export * from './formatAmount';
|
|
22
22
|
export * from './formatDate';
|
|
23
|
+
export * from './formatDateStr';
|
|
23
24
|
export * from './formatMessage';
|
|
24
25
|
export * from './formatPathParams';
|
|
25
26
|
export * from './getBlobByUrl';
|
package/lib/formatDate.d.ts
CHANGED
package/lib/formatDate.js
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.formatDate = void 0;
|
|
4
4
|
const isString_1 = require("./isString");
|
|
5
|
+
const formatDateStr_1 = require("./formatDateStr");
|
|
5
6
|
/**
|
|
6
7
|
* 格式化日期
|
|
8
|
+
* 默认的当前日期 yyyy-MM-dd hh:mm:ss
|
|
7
9
|
*/
|
|
8
|
-
function formatDate(val, fmt = 'yyyy-MM-dd hh:mm:ss') {
|
|
10
|
+
function formatDate(val = new Date(), fmt = 'yyyy-MM-dd hh:mm:ss') {
|
|
9
11
|
let v = val;
|
|
10
12
|
if ((0, isString_1.isString)(v)) {
|
|
11
13
|
// fix iOS new Date() 不支持 2020-01-01 格式,需转换为 2020/01/01
|
|
12
|
-
v =
|
|
14
|
+
v = (0, formatDateStr_1.formatDateStr)(v);
|
|
13
15
|
}
|
|
14
16
|
const date = new Date(v);
|
|
15
17
|
const o = {
|
package/lib/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export * from './filterName';
|
|
|
19
19
|
export * from './filterPhone';
|
|
20
20
|
export * from './formatAmount';
|
|
21
21
|
export * from './formatDate';
|
|
22
|
+
export * from './formatDateStr';
|
|
22
23
|
export * from './formatMessage';
|
|
23
24
|
export * from './formatPathParams';
|
|
24
25
|
export * from './getBlobByUrl';
|
package/lib/index.js
CHANGED
|
@@ -36,6 +36,7 @@ __exportStar(require("./filterName"), exports);
|
|
|
36
36
|
__exportStar(require("./filterPhone"), exports);
|
|
37
37
|
__exportStar(require("./formatAmount"), exports);
|
|
38
38
|
__exportStar(require("./formatDate"), exports);
|
|
39
|
+
__exportStar(require("./formatDateStr"), exports);
|
|
39
40
|
__exportStar(require("./formatMessage"), exports);
|
|
40
41
|
__exportStar(require("./formatPathParams"), exports);
|
|
41
42
|
__exportStar(require("./getBlobByUrl"), exports);
|