xctc-utils 1.5.7 → 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 +19 -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,42 +122,47 @@ 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 {
|
|
129
|
+
month = "01";
|
|
129
130
|
str = "".concat(str, "/01");
|
|
130
131
|
}
|
|
131
132
|
var dayIndex = format.indexOf("DD");
|
|
132
133
|
if (dayIndex != -1) {
|
|
133
|
-
day = value.substring(dayIndex, dayIndex +
|
|
134
|
+
day = value.substring(dayIndex, dayIndex + 2) || "01";
|
|
134
135
|
str = "".concat(str, "/").concat(day);
|
|
135
136
|
}
|
|
136
137
|
else {
|
|
138
|
+
day = "01";
|
|
137
139
|
str = "".concat(str, "/01");
|
|
138
140
|
}
|
|
139
141
|
var hourIndex = format.indexOf("HH");
|
|
140
142
|
if (hourIndex != -1) {
|
|
141
|
-
hour = value.substring(hourIndex, hourIndex +
|
|
143
|
+
hour = value.substring(hourIndex, hourIndex + 2) || "00";
|
|
142
144
|
str = "".concat(str, " ").concat(hour);
|
|
143
145
|
}
|
|
144
146
|
else {
|
|
147
|
+
hour = "00";
|
|
145
148
|
str = "".concat(str, " 00");
|
|
146
149
|
}
|
|
147
150
|
var minuteIndex = format.indexOf("mm");
|
|
148
|
-
if (
|
|
149
|
-
minute = value.substring(minuteIndex, minuteIndex +
|
|
151
|
+
if (minuteIndex != -1) {
|
|
152
|
+
minute = value.substring(minuteIndex, minuteIndex + 2) || "00";
|
|
150
153
|
str = "".concat(str, ":").concat(minute);
|
|
151
154
|
}
|
|
152
155
|
else {
|
|
156
|
+
minute = "00";
|
|
153
157
|
str = "".concat(str, ":00");
|
|
154
158
|
}
|
|
155
159
|
var secondIndex = format.indexOf("ss");
|
|
156
|
-
if (
|
|
157
|
-
second = value.substring(secondIndex, secondIndex +
|
|
160
|
+
if (secondIndex != -1) {
|
|
161
|
+
second = value.substring(secondIndex, secondIndex + 2) || "00";
|
|
158
162
|
str = "".concat(str, ":").concat(second);
|
|
159
163
|
}
|
|
160
164
|
else {
|
|
165
|
+
second = "01";
|
|
161
166
|
str = "".concat(str, ":01");
|
|
162
167
|
}
|
|
163
168
|
now = new Date(str);
|
|
@@ -175,9 +180,14 @@ function getDateData(value, format) {
|
|
|
175
180
|
};
|
|
176
181
|
}
|
|
177
182
|
exports.getDateData = getDateData;
|
|
183
|
+
/**
|
|
184
|
+
*
|
|
185
|
+
* @param idcard 身份证号码
|
|
186
|
+
* @returns
|
|
187
|
+
*/
|
|
178
188
|
function findIdcardAge(idcard) {
|
|
179
|
-
if (!idcard) {
|
|
180
|
-
return;
|
|
189
|
+
if (!idcard || idcard.length < 15) {
|
|
190
|
+
return console.error("传入正确的身份证号码");
|
|
181
191
|
}
|
|
182
192
|
// 提取身份证号中的出生日期部分
|
|
183
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",
|