@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.
@@ -1,4 +1,5 @@
1
1
  /**
2
2
  * 格式化日期
3
+ * 默认的当前日期 yyyy-MM-dd hh:mm:ss
3
4
  */
4
- export declare function formatDate(val: string | Date | number, fmt?: string): string;
5
+ export declare function formatDate(val?: string | Date | number, fmt?: string): string;
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.replace(/-/g, '/');
11
+ v = formatDateStr(v);
10
12
  }
11
13
  const date = new Date(v);
12
14
  const o = {
@@ -0,0 +1,4 @@
1
+ /**
2
+ * str 转换成 date
3
+ */
4
+ export declare function formatDateStr(v: string): Date;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * str 转换成 date
3
+ */
4
+ export function formatDateStr(v) {
5
+ return new Date(v.replace(/-/g, '/'));
6
+ }
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';
@@ -1,4 +1,5 @@
1
1
  /**
2
2
  * 格式化日期
3
+ * 默认的当前日期 yyyy-MM-dd hh:mm:ss
3
4
  */
4
- export declare function formatDate(val: string | Date | number, fmt?: string): string;
5
+ export declare function formatDate(val?: string | Date | number, fmt?: string): string;
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 = v.replace(/-/g, '/');
14
+ v = (0, formatDateStr_1.formatDateStr)(v);
13
15
  }
14
16
  const date = new Date(v);
15
17
  const o = {
@@ -0,0 +1,4 @@
1
+ /**
2
+ * str 转换成 date
3
+ */
4
+ export declare function formatDateStr(v: string): Date;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatDateStr = void 0;
4
+ /**
5
+ * str 转换成 date
6
+ */
7
+ function formatDateStr(v) {
8
+ return new Date(v.replace(/-/g, '/'));
9
+ }
10
+ exports.formatDateStr = formatDateStr;
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daysnap/utils",
3
- "version": "0.0.50",
3
+ "version": "0.0.52",
4
4
  "description": "通用的工具库",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",