xctc-utils 1.5.8 → 1.5.9
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 +7 -2
- package/dist/time/index.js +14 -9
- package/package.json +1 -1
package/dist/time/index.d.ts
CHANGED
|
@@ -30,7 +30,12 @@ export declare function getDateData(value: string | number, format?: string): {
|
|
|
30
30
|
second: string | number;
|
|
31
31
|
num: any;
|
|
32
32
|
};
|
|
33
|
-
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @param idcard 身份证号码
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
export declare function findIdcardAge(idcard: string): void | {
|
|
34
39
|
year: string | number;
|
|
35
40
|
month: string | number;
|
|
36
41
|
day: string | number;
|
|
@@ -38,4 +43,4 @@ export declare function findIdcardAge(idcard: string): {
|
|
|
38
43
|
minute: string | number;
|
|
39
44
|
second: string | number;
|
|
40
45
|
num: any;
|
|
41
|
-
}
|
|
46
|
+
};
|
package/dist/time/index.js
CHANGED
|
@@ -122,7 +122,7 @@ function getDateData(value, format) {
|
|
|
122
122
|
var str = "".concat(year);
|
|
123
123
|
var monthIndex = format.indexOf("MM");
|
|
124
124
|
if (monthIndex != -1) {
|
|
125
|
-
month = value.substring(monthIndex, monthIndex +
|
|
125
|
+
month = value.substring(monthIndex, monthIndex + 2) || "01";
|
|
126
126
|
str = "".concat(str, "/").concat(month);
|
|
127
127
|
}
|
|
128
128
|
else {
|
|
@@ -131,7 +131,7 @@ function getDateData(value, format) {
|
|
|
131
131
|
}
|
|
132
132
|
var dayIndex = format.indexOf("DD");
|
|
133
133
|
if (dayIndex != -1) {
|
|
134
|
-
day = value.substring(dayIndex, dayIndex +
|
|
134
|
+
day = value.substring(dayIndex, dayIndex + 2) || "01";
|
|
135
135
|
str = "".concat(str, "/").concat(day);
|
|
136
136
|
}
|
|
137
137
|
else {
|
|
@@ -140,7 +140,7 @@ function getDateData(value, format) {
|
|
|
140
140
|
}
|
|
141
141
|
var hourIndex = format.indexOf("HH");
|
|
142
142
|
if (hourIndex != -1) {
|
|
143
|
-
hour = value.substring(hourIndex, hourIndex +
|
|
143
|
+
hour = value.substring(hourIndex, hourIndex + 2) || "00";
|
|
144
144
|
str = "".concat(str, " ").concat(hour);
|
|
145
145
|
}
|
|
146
146
|
else {
|
|
@@ -148,8 +148,8 @@ function getDateData(value, format) {
|
|
|
148
148
|
str = "".concat(str, " 00");
|
|
149
149
|
}
|
|
150
150
|
var minuteIndex = format.indexOf("mm");
|
|
151
|
-
if (
|
|
152
|
-
minute = value.substring(minuteIndex, minuteIndex +
|
|
151
|
+
if (minuteIndex != -1) {
|
|
152
|
+
minute = value.substring(minuteIndex, minuteIndex + 2) || "00";
|
|
153
153
|
str = "".concat(str, ":").concat(minute);
|
|
154
154
|
}
|
|
155
155
|
else {
|
|
@@ -157,8 +157,8 @@ function getDateData(value, format) {
|
|
|
157
157
|
str = "".concat(str, ":00");
|
|
158
158
|
}
|
|
159
159
|
var secondIndex = format.indexOf("ss");
|
|
160
|
-
if (
|
|
161
|
-
second = value.substring(secondIndex, secondIndex +
|
|
160
|
+
if (secondIndex != -1) {
|
|
161
|
+
second = value.substring(secondIndex, secondIndex + 2) || "00";
|
|
162
162
|
str = "".concat(str, ":").concat(second);
|
|
163
163
|
}
|
|
164
164
|
else {
|
|
@@ -180,9 +180,14 @@ function getDateData(value, format) {
|
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
182
|
exports.getDateData = getDateData;
|
|
183
|
+
/**
|
|
184
|
+
*
|
|
185
|
+
* @param idcard 身份证号码
|
|
186
|
+
* @returns
|
|
187
|
+
*/
|
|
183
188
|
function findIdcardAge(idcard) {
|
|
184
|
-
if (!idcard) {
|
|
185
|
-
return;
|
|
189
|
+
if (!idcard || idcard.length < 15) {
|
|
190
|
+
return console.error("传入正确的身份证号码");
|
|
186
191
|
}
|
|
187
192
|
// 提取身份证号中的出生日期部分
|
|
188
193
|
var birthday = idcard.substring(6, 14);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xctc-utils",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.9",
|
|
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",
|