xctc-utils 1.5.9 → 1.6.0
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/dist/time/index.d.ts +1 -1
- package/dist/time/index.js +4 -9
- package/package.json +1 -1
package/dist/time/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare function formatTimeStamp(num?: number, format?: string): string;
|
|
|
11
11
|
* @param str 字符串格式必须为: 2017/03/03 12:23:55 格式,避免兼容性,不能传 “ - ” 分割的时间字符串 2017-03-03
|
|
12
12
|
* @returns
|
|
13
13
|
*/
|
|
14
|
-
export declare function formatStrTime(str: string): any;
|
|
14
|
+
export declare function formatStrTime(str: string, format?: string): any;
|
|
15
15
|
/**
|
|
16
16
|
* 2018-12-28 15:00:00
|
|
17
17
|
* 2018/12/28 15:00:00
|
package/dist/time/index.js
CHANGED
|
@@ -70,17 +70,11 @@ function isExist(str, key) {
|
|
|
70
70
|
* @param str 字符串格式必须为: 2017/03/03 12:23:55 格式,避免兼容性,不能传 “ - ” 分割的时间字符串 2017-03-03
|
|
71
71
|
* @returns
|
|
72
72
|
*/
|
|
73
|
-
function formatStrTime(str) {
|
|
73
|
+
function formatStrTime(str, format) {
|
|
74
|
+
var _a;
|
|
74
75
|
if (!str)
|
|
75
76
|
return "";
|
|
76
|
-
|
|
77
|
-
var timestamp = "";
|
|
78
|
-
if (strDate) {
|
|
79
|
-
timestamp = strDate.getTime();
|
|
80
|
-
timestamp = timestamp / 1000;
|
|
81
|
-
return parseInt(timestamp);
|
|
82
|
-
}
|
|
83
|
-
return "";
|
|
77
|
+
return (_a = getDateData(str, format)) === null || _a === void 0 ? void 0 : _a.num;
|
|
84
78
|
}
|
|
85
79
|
exports.formatStrTime = formatStrTime;
|
|
86
80
|
// 获取当前时间的 年月日时分秒对象
|
|
@@ -121,6 +115,7 @@ function getDateData(value, format) {
|
|
|
121
115
|
year = value.substring(0, 4);
|
|
122
116
|
var str = "".concat(year);
|
|
123
117
|
var monthIndex = format.indexOf("MM");
|
|
118
|
+
console.log("monthIndex==", monthIndex);
|
|
124
119
|
if (monthIndex != -1) {
|
|
125
120
|
month = value.substring(monthIndex, monthIndex + 2) || "01";
|
|
126
121
|
str = "".concat(str, "/").concat(month);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xctc-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "localStorage存储\r ```\r sessionStorage存储\r ```\r crypto-js加密、解密\r ```\r 微信授权登录、微信分享\r ```\r 设备环境获取\r ```\r 是否是微信浏览器\r ```\r 时间戳转时间,字符串转时间戳",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|