xctc-utils 1.5.6 → 1.5.7

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.
@@ -22,7 +22,7 @@ export declare function formatStrTime(str: string): any;
22
22
  * @returns
23
23
  */
24
24
  export declare function getDateData(value: string | number, format?: string): {
25
- year: number;
25
+ year: string | number;
26
26
  month: string | number;
27
27
  day: string | number;
28
28
  hour: string | number;
@@ -31,7 +31,7 @@ export declare function getDateData(value: string | number, format?: string): {
31
31
  num: any;
32
32
  };
33
33
  export declare function findIdcardAge(idcard: string): {
34
- year: number;
34
+ year: string | number;
35
35
  month: string | number;
36
36
  day: string | number;
37
37
  hour: string | number;
@@ -95,73 +95,74 @@ exports.formatStrTime = formatStrTime;
95
95
  */
96
96
  function getDateData(value, format) {
97
97
  var now = new Date();
98
+ var year = "";
99
+ var month = "";
100
+ var day = "";
101
+ var hour = "";
102
+ var minute = "";
103
+ var second = "";
98
104
  if (typeof value == 'number') {
99
105
  now = new Date(value * 1000);
106
+ year = now.getFullYear();
107
+ month = now.getMonth() + 1;
108
+ month = month < 10 ? "0" + month : month;
109
+ day = now.getDate();
110
+ day = day < 10 ? "0" + day : day;
111
+ hour = now.getHours();
112
+ hour = hour < 10 ? "0" + hour : hour;
113
+ minute = now.getMinutes();
114
+ minute = minute < 10 ? "0" + minute : minute;
115
+ second = now.getSeconds();
116
+ second = second < 10 ? "0" + second : second;
100
117
  }
101
118
  if (typeof value == "string") {
102
119
  if (!format)
103
120
  format = "YYYY-MM-DD HH:mm:ss";
104
- var year_1 = value.substring(0, 4);
105
- var str = "".concat(year_1);
121
+ year = value.substring(0, 4);
122
+ var str = "".concat(year);
106
123
  var monthIndex = format.indexOf("MM");
107
- var month_1 = "";
108
124
  if (monthIndex != -1) {
109
- month_1 = value.substring(monthIndex, monthIndex + 3);
110
- str = "".concat(str, "/").concat(month_1);
125
+ month = value.substring(monthIndex, monthIndex + 3);
126
+ str = "".concat(str, "/").concat(month);
111
127
  }
112
128
  else {
113
129
  str = "".concat(str, "/01");
114
130
  }
115
131
  var dayIndex = format.indexOf("DD");
116
- var day_1 = "";
117
132
  if (dayIndex != -1) {
118
- day_1 = value.substring(dayIndex, dayIndex + 3);
119
- str = "".concat(str, "/").concat(day_1);
133
+ day = value.substring(dayIndex, dayIndex + 3);
134
+ str = "".concat(str, "/").concat(day);
120
135
  }
121
136
  else {
122
137
  str = "".concat(str, "/01");
123
138
  }
124
139
  var hourIndex = format.indexOf("HH");
125
- var hour_1 = "";
126
140
  if (hourIndex != -1) {
127
- hour_1 = value.substring(hourIndex, hourIndex + 3);
128
- str = "".concat(str, " ").concat(hour_1);
141
+ hour = value.substring(hourIndex, hourIndex + 3);
142
+ str = "".concat(str, " ").concat(hour);
129
143
  }
130
144
  else {
131
145
  str = "".concat(str, " 00");
132
146
  }
133
147
  var minuteIndex = format.indexOf("mm");
134
- var minute_1 = "";
135
148
  if (hourIndex != -1) {
136
- minute_1 = value.substring(minuteIndex, minuteIndex + 3);
137
- str = "".concat(str, ":").concat(minute_1);
149
+ minute = value.substring(minuteIndex, minuteIndex + 3);
150
+ str = "".concat(str, ":").concat(minute);
138
151
  }
139
152
  else {
140
153
  str = "".concat(str, ":00");
141
154
  }
142
155
  var secondIndex = format.indexOf("ss");
143
- var second_1 = "";
144
156
  if (hourIndex != -1) {
145
- second_1 = value.substring(secondIndex, secondIndex + 3);
146
- str = "".concat(str, ":").concat(second_1);
157
+ second = value.substring(secondIndex, secondIndex + 3);
158
+ str = "".concat(str, ":").concat(second);
147
159
  }
148
160
  else {
149
- str = "".concat(str, ":00");
161
+ str = "".concat(str, ":01");
150
162
  }
151
163
  now = new Date(str);
152
164
  }
153
- var year = now.getFullYear();
154
- var month = now.getMonth() + 1;
155
- month = month < 10 ? "0" + month : month;
156
- var day = now.getDate();
157
- day = day < 10 ? "0" + day : day;
158
- var hour = now.getHours();
159
- hour = hour < 10 ? "0" + hour : hour;
160
- var minute = now.getMinutes();
161
- minute = minute < 10 ? "0" + minute : minute;
162
- var second = now.getSeconds();
163
- second = second < 10 ? "0" + second : second;
164
- var nowNumber = new Date().getTime() / 1000;
165
+ var nowNumber = now.getTime() / 1000;
165
166
  nowNumber = parseInt(nowNumber);
166
167
  return {
167
168
  year: year,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xctc-utils",
3
- "version": "1.5.6",
3
+ "version": "1.5.7",
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",