zhl-methods 1.1.7 → 1.1.8

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.
Files changed (2) hide show
  1. package/js/ScanUDI.js +23 -19
  2. package/package.json +1 -1
package/js/ScanUDI.js CHANGED
@@ -88,29 +88,33 @@ export default class ScanUDI {
88
88
  }
89
89
  setDateFormat(date, type, expand) {
90
90
  try {
91
- if (date.length === 8 && data.substr(data.length - 2) == "00") {
92
- if (type === "expiry") {
93
- date = dayjs(date).endOf("month");
91
+ if (date) {
92
+ if (date.length === 8 && data.substr(data.length - 2) == "00") {
93
+ if (type === "expiry") {
94
+ date = dayjs(date).endOf("month");
95
+ }
96
+ date = dayjs(date).startOf("month");
94
97
  }
95
- date = dayjs(date).startOf("month");
96
- }
97
- if (date.length === 6) {
98
- if (date.substring(0, 2) === expand.substring(0, 2)) {
99
- // 年月(6位) - 202507
100
- date = date + "01";
101
- } else {
102
- // 年后两位月日(6位) - 250708
103
- date = "20" + date;
98
+ if (date.length === 6) {
99
+ if (date.substring(0, 2) === expand.substring(0, 2)) {
100
+ // 年月(6) - 202507
101
+ date = date + "01";
102
+ } else {
103
+ // 年后两位月日(6位) - 250708
104
+ date = "20" + date;
105
+ }
104
106
  }
105
- }
106
- // 年后两位月(4) - 2507
107
- if (date.length === 4) {
108
- if (type === "expiry") {
109
- date = dayjs("20" + date).endOf("month");
107
+ // 年后两位月(4位) - 2507
108
+ if (date.length === 4) {
109
+ if (type === "expiry") {
110
+ date = dayjs("20" + date).endOf("month");
111
+ }
112
+ date = "20" + date + "01";
110
113
  }
111
- date = "20" + date + "01";
114
+ return dayjs(date).format("YYYY-MM-DD");
115
+ } else {
116
+ return "";
112
117
  }
113
- return dayjs(date).format("YYYY-MM-DD");
114
118
  } catch (error) {
115
119
  console.log(error, "setDateFormat error");
116
120
  return date;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zhl-methods",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "license": "ISC",
5
5
  "dependencies": {
6
6
  "dayjs": "^1.11.15",