@fast-china/utils 1.0.35 → 1.0.36
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/index.global.js +25 -48
- package/dist/index.global.js.map +1 -1
- package/dist/index.global.min.js +1 -1
- package/dist/index.global.min.js.map +1 -1
- package/es/date/index.mjs +1 -1
- package/es/date/index.mjs.map +1 -1
- package/lib/date/index.js +1 -1
- package/lib/date/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.global.js
CHANGED
|
@@ -13301,65 +13301,42 @@ var FastUtils = (function(exports, vue) {
|
|
|
13301
13301
|
if (typeof date2 === "string") {
|
|
13302
13302
|
timestamp = new Date(date2).getTime();
|
|
13303
13303
|
} else if (typeof date2 === "number") {
|
|
13304
|
-
timestamp = date2;
|
|
13304
|
+
timestamp = date2.toString().length <= 10 ? date2 * 1e3 : date2;
|
|
13305
13305
|
} else {
|
|
13306
13306
|
timestamp = date2.getTime();
|
|
13307
13307
|
}
|
|
13308
|
-
if (timestamp < 1e12) {
|
|
13309
|
-
timestamp *= 1e3;
|
|
13310
|
-
}
|
|
13311
13308
|
const minute = 1e3 * 60;
|
|
13312
13309
|
const hour = minute * 60;
|
|
13313
13310
|
const day = hour * 24;
|
|
13314
|
-
const month = day * 30;
|
|
13315
13311
|
const curTime = (/* @__PURE__ */ new Date()).getTime();
|
|
13316
13312
|
const diffValue = curTime - timestamp;
|
|
13317
|
-
const
|
|
13318
|
-
const
|
|
13319
|
-
const dayC = diffValue / day;
|
|
13320
|
-
const
|
|
13321
|
-
const
|
|
13322
|
-
|
|
13323
|
-
|
|
13324
|
-
|
|
13325
|
-
|
|
13326
|
-
|
|
13327
|
-
const
|
|
13328
|
-
|
|
13329
|
-
|
|
13330
|
-
|
|
13331
|
-
|
|
13332
|
-
|
|
13333
|
-
|
|
13334
|
-
|
|
13335
|
-
|
|
13336
|
-
|
|
13337
|
-
|
|
13338
|
-
} else if (dayC1 >= 1) {
|
|
13339
|
-
return `${Math.floor(dayC1)}天后`;
|
|
13340
|
-
} else if (hourC1 >= 1) {
|
|
13341
|
-
return `${Math.floor(hourC1)}小时后`;
|
|
13342
|
-
} else if (minC1 >= 1) {
|
|
13343
|
-
return `${Math.floor(minC1)}分钟后`;
|
|
13344
|
-
}
|
|
13345
|
-
return "刚刚";
|
|
13346
|
-
}
|
|
13347
|
-
if (monthC > 12) {
|
|
13348
|
-
return `${Math.floor(monthC / 12)}年前`;
|
|
13349
|
-
} else if (monthC >= 6) {
|
|
13350
|
-
return "半年前";
|
|
13351
|
-
} else if (monthC >= 1) {
|
|
13352
|
-
return `${Math.floor(monthC)}月前`;
|
|
13353
|
-
} else if (weekC > 2) {
|
|
13354
|
-
return "半月前";
|
|
13355
|
-
} else if (weekC >= 1) {
|
|
13356
|
-
return `${Math.floor(weekC)}周前`;
|
|
13313
|
+
const minC = Math.abs(diffValue) / minute;
|
|
13314
|
+
const hourC = Math.abs(diffValue) / hour;
|
|
13315
|
+
const dayC = Math.abs(diffValue) / day;
|
|
13316
|
+
const curDate = new Date(curTime);
|
|
13317
|
+
const targetDate = new Date(timestamp);
|
|
13318
|
+
const yearDiff = curDate.getFullYear() - targetDate.getFullYear();
|
|
13319
|
+
const monthDiff = curDate.getMonth() - targetDate.getMonth();
|
|
13320
|
+
const totalMonthDiff = yearDiff * 12 + monthDiff;
|
|
13321
|
+
const suffix = diffValue < 0 ? "后" : "前";
|
|
13322
|
+
if (Math.abs(totalMonthDiff) >= 12) {
|
|
13323
|
+
const years = Math.floor(Math.abs(totalMonthDiff) / 12);
|
|
13324
|
+
return `${years}年${suffix}`;
|
|
13325
|
+
} else if (Math.abs(totalMonthDiff) >= 6) {
|
|
13326
|
+
return `半年${suffix}`;
|
|
13327
|
+
} else if (Math.abs(totalMonthDiff) >= 1) {
|
|
13328
|
+
return `${Math.abs(totalMonthDiff)}月${suffix}`;
|
|
13329
|
+
} else if (dayC >= 15) {
|
|
13330
|
+
return `半月${suffix}`;
|
|
13331
|
+
} else if (dayC >= 7) {
|
|
13332
|
+
const weeks = Math.floor(dayC / 7);
|
|
13333
|
+
return `${weeks}周${suffix}`;
|
|
13357
13334
|
} else if (dayC >= 1) {
|
|
13358
|
-
return `${Math.floor(dayC)}
|
|
13335
|
+
return `${Math.floor(dayC)}天${suffix}`;
|
|
13359
13336
|
} else if (hourC >= 1) {
|
|
13360
|
-
return `${Math.floor(hourC)}
|
|
13337
|
+
return `${Math.floor(hourC)}小时${suffix}`;
|
|
13361
13338
|
} else if (minC >= 1) {
|
|
13362
|
-
return `${Math.floor(minC)}
|
|
13339
|
+
return `${Math.floor(minC)}分钟${suffix}`;
|
|
13363
13340
|
}
|
|
13364
13341
|
return "刚刚";
|
|
13365
13342
|
},
|