@fast-china/utils 1.0.35 → 1.0.37
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 +297 -182
- 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.d.ts +10 -7
- package/es/date/index.mjs +1 -1
- package/es/date/index.mjs.map +1 -1
- package/lib/date/index.d.ts +10 -7
- 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,223 +13301,338 @@ 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
|
},
|
|
13366
13343
|
/**
|
|
13367
|
-
*
|
|
13368
|
-
* @returns
|
|
13344
|
+
* 获取简单的日期时间
|
|
13345
|
+
* @returns xxxx-xx-xx 00:00:00
|
|
13369
13346
|
*/
|
|
13370
|
-
|
|
13371
|
-
const end = /* @__PURE__ */ new Date();
|
|
13347
|
+
getSimpleTime() {
|
|
13372
13348
|
const start = /* @__PURE__ */ new Date();
|
|
13373
|
-
start.setMonth(start.getMonth() - 1);
|
|
13374
13349
|
start.setHours(0, 0, 0);
|
|
13375
|
-
|
|
13376
|
-
return [start, end];
|
|
13350
|
+
return start;
|
|
13377
13351
|
},
|
|
13378
13352
|
/**
|
|
13379
|
-
*
|
|
13380
|
-
* @
|
|
13353
|
+
* 获取默认时间
|
|
13354
|
+
* @param isFuture 是否为未来时间
|
|
13355
|
+
* @returns [00:00:00, 23:59:59]
|
|
13381
13356
|
*/
|
|
13382
|
-
|
|
13357
|
+
getDefaultTime(isFuture = false) {
|
|
13358
|
+
const end = /* @__PURE__ */ new Date();
|
|
13383
13359
|
const start = /* @__PURE__ */ new Date();
|
|
13360
|
+
if (isFuture) {
|
|
13361
|
+
end.setMonth(end.getMonth() + 1);
|
|
13362
|
+
} else {
|
|
13363
|
+
start.setMonth(start.getMonth() - 1);
|
|
13364
|
+
}
|
|
13384
13365
|
start.setHours(0, 0, 0);
|
|
13385
|
-
|
|
13366
|
+
end.setHours(23, 59, 59);
|
|
13367
|
+
return [start, end];
|
|
13386
13368
|
},
|
|
13387
13369
|
/**
|
|
13388
13370
|
* 获取简单的日期时间范围
|
|
13371
|
+
* @param isFuture 是否为未来时间
|
|
13389
13372
|
*/
|
|
13390
|
-
getSimpleShortcuts() {
|
|
13391
|
-
|
|
13392
|
-
|
|
13393
|
-
|
|
13394
|
-
|
|
13395
|
-
|
|
13396
|
-
|
|
13397
|
-
|
|
13398
|
-
|
|
13399
|
-
|
|
13400
|
-
|
|
13401
|
-
|
|
13402
|
-
|
|
13403
|
-
|
|
13404
|
-
|
|
13405
|
-
|
|
13406
|
-
|
|
13407
|
-
|
|
13408
|
-
|
|
13409
|
-
|
|
13410
|
-
|
|
13411
|
-
|
|
13412
|
-
|
|
13413
|
-
|
|
13414
|
-
|
|
13415
|
-
|
|
13416
|
-
|
|
13417
|
-
|
|
13418
|
-
|
|
13419
|
-
|
|
13420
|
-
|
|
13421
|
-
|
|
13422
|
-
|
|
13423
|
-
|
|
13424
|
-
|
|
13373
|
+
getSimpleShortcuts(isFuture = false) {
|
|
13374
|
+
if (isFuture) {
|
|
13375
|
+
return [
|
|
13376
|
+
{
|
|
13377
|
+
text: "今天",
|
|
13378
|
+
value: () => {
|
|
13379
|
+
const date2 = /* @__PURE__ */ new Date();
|
|
13380
|
+
date2.setHours(0, 0, 0);
|
|
13381
|
+
return date2;
|
|
13382
|
+
}
|
|
13383
|
+
},
|
|
13384
|
+
{
|
|
13385
|
+
text: "明天",
|
|
13386
|
+
value: () => {
|
|
13387
|
+
const date2 = /* @__PURE__ */ new Date();
|
|
13388
|
+
date2.setDate(date2.getDate() + 1);
|
|
13389
|
+
date2.setHours(0, 0, 0);
|
|
13390
|
+
return date2;
|
|
13391
|
+
}
|
|
13392
|
+
},
|
|
13393
|
+
{
|
|
13394
|
+
text: "一周后",
|
|
13395
|
+
value: () => {
|
|
13396
|
+
const date2 = /* @__PURE__ */ new Date();
|
|
13397
|
+
date2.setDate(date2.getDate() + 7);
|
|
13398
|
+
date2.setHours(0, 0, 0);
|
|
13399
|
+
return date2;
|
|
13400
|
+
}
|
|
13401
|
+
},
|
|
13402
|
+
{
|
|
13403
|
+
text: "一月后",
|
|
13404
|
+
value: () => {
|
|
13405
|
+
const date2 = /* @__PURE__ */ new Date();
|
|
13406
|
+
date2.setMonth(date2.getMonth() + 1);
|
|
13407
|
+
date2.setHours(0, 0, 0);
|
|
13408
|
+
return date2;
|
|
13409
|
+
}
|
|
13410
|
+
},
|
|
13411
|
+
{
|
|
13412
|
+
text: "一年后",
|
|
13413
|
+
value: () => {
|
|
13414
|
+
const date2 = /* @__PURE__ */ new Date();
|
|
13415
|
+
date2.setFullYear(date2.getFullYear() + 1);
|
|
13416
|
+
date2.setHours(0, 0, 0);
|
|
13417
|
+
return date2;
|
|
13418
|
+
}
|
|
13425
13419
|
}
|
|
13426
|
-
|
|
13427
|
-
|
|
13428
|
-
|
|
13429
|
-
|
|
13430
|
-
|
|
13431
|
-
|
|
13432
|
-
|
|
13433
|
-
|
|
13420
|
+
];
|
|
13421
|
+
} else {
|
|
13422
|
+
return [
|
|
13423
|
+
{
|
|
13424
|
+
text: "今天",
|
|
13425
|
+
value: () => {
|
|
13426
|
+
const date2 = /* @__PURE__ */ new Date();
|
|
13427
|
+
date2.setHours(0, 0, 0);
|
|
13428
|
+
return date2;
|
|
13429
|
+
}
|
|
13430
|
+
},
|
|
13431
|
+
{
|
|
13432
|
+
text: "昨天",
|
|
13433
|
+
value: () => {
|
|
13434
|
+
const date2 = /* @__PURE__ */ new Date();
|
|
13435
|
+
date2.setDate(date2.getDate() - 1);
|
|
13436
|
+
date2.setHours(0, 0, 0);
|
|
13437
|
+
return date2;
|
|
13438
|
+
}
|
|
13439
|
+
},
|
|
13440
|
+
{
|
|
13441
|
+
text: "一周前",
|
|
13442
|
+
value: () => {
|
|
13443
|
+
const date2 = /* @__PURE__ */ new Date();
|
|
13444
|
+
date2.setDate(date2.getDate() - 7);
|
|
13445
|
+
date2.setHours(0, 0, 0);
|
|
13446
|
+
return date2;
|
|
13447
|
+
}
|
|
13448
|
+
},
|
|
13449
|
+
{
|
|
13450
|
+
text: "一月前",
|
|
13451
|
+
value: () => {
|
|
13452
|
+
const date2 = /* @__PURE__ */ new Date();
|
|
13453
|
+
date2.setMonth(date2.getMonth() - 1);
|
|
13454
|
+
date2.setHours(0, 0, 0);
|
|
13455
|
+
return date2;
|
|
13456
|
+
}
|
|
13457
|
+
},
|
|
13458
|
+
{
|
|
13459
|
+
text: "一年前",
|
|
13460
|
+
value: () => {
|
|
13461
|
+
const date2 = /* @__PURE__ */ new Date();
|
|
13462
|
+
date2.setFullYear(date2.getFullYear() - 1);
|
|
13463
|
+
date2.setHours(0, 0, 0);
|
|
13464
|
+
return date2;
|
|
13465
|
+
}
|
|
13434
13466
|
}
|
|
13435
|
-
|
|
13436
|
-
|
|
13467
|
+
];
|
|
13468
|
+
}
|
|
13437
13469
|
},
|
|
13438
13470
|
/**
|
|
13439
13471
|
* 获取日期范围
|
|
13472
|
+
* @param isFuture 是否为未来时间
|
|
13440
13473
|
*/
|
|
13441
|
-
getShortcuts() {
|
|
13442
|
-
|
|
13443
|
-
|
|
13444
|
-
|
|
13445
|
-
|
|
13446
|
-
|
|
13447
|
-
|
|
13448
|
-
|
|
13449
|
-
|
|
13450
|
-
|
|
13451
|
-
|
|
13452
|
-
|
|
13453
|
-
|
|
13454
|
-
|
|
13455
|
-
|
|
13456
|
-
|
|
13457
|
-
|
|
13458
|
-
|
|
13459
|
-
|
|
13460
|
-
|
|
13461
|
-
|
|
13462
|
-
|
|
13463
|
-
|
|
13464
|
-
|
|
13465
|
-
|
|
13466
|
-
|
|
13467
|
-
|
|
13468
|
-
|
|
13469
|
-
|
|
13470
|
-
|
|
13471
|
-
|
|
13472
|
-
|
|
13473
|
-
|
|
13474
|
-
|
|
13475
|
-
|
|
13476
|
-
|
|
13477
|
-
|
|
13478
|
-
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
|
|
13483
|
-
|
|
13484
|
-
|
|
13485
|
-
|
|
13486
|
-
|
|
13487
|
-
|
|
13488
|
-
|
|
13489
|
-
|
|
13490
|
-
|
|
13491
|
-
|
|
13492
|
-
|
|
13493
|
-
|
|
13494
|
-
|
|
13495
|
-
|
|
13496
|
-
|
|
13497
|
-
|
|
13498
|
-
|
|
13499
|
-
|
|
13500
|
-
|
|
13501
|
-
|
|
13502
|
-
|
|
13503
|
-
|
|
13504
|
-
|
|
13505
|
-
|
|
13506
|
-
|
|
13474
|
+
getShortcuts(isFuture = false) {
|
|
13475
|
+
if (isFuture) {
|
|
13476
|
+
return [
|
|
13477
|
+
{
|
|
13478
|
+
text: "后1天",
|
|
13479
|
+
value: () => {
|
|
13480
|
+
const end = /* @__PURE__ */ new Date();
|
|
13481
|
+
const start = /* @__PURE__ */ new Date();
|
|
13482
|
+
end.setDate(end.getDate() + 1);
|
|
13483
|
+
start.setHours(0, 0, 0);
|
|
13484
|
+
end.setHours(23, 59, 59);
|
|
13485
|
+
return [start, end];
|
|
13486
|
+
}
|
|
13487
|
+
},
|
|
13488
|
+
{
|
|
13489
|
+
text: "后3天",
|
|
13490
|
+
value: () => {
|
|
13491
|
+
const end = /* @__PURE__ */ new Date();
|
|
13492
|
+
const start = /* @__PURE__ */ new Date();
|
|
13493
|
+
end.setDate(end.getDate() + 3);
|
|
13494
|
+
start.setHours(0, 0, 0);
|
|
13495
|
+
end.setHours(23, 59, 59);
|
|
13496
|
+
return [start, end];
|
|
13497
|
+
}
|
|
13498
|
+
},
|
|
13499
|
+
{
|
|
13500
|
+
text: "后1周",
|
|
13501
|
+
value: () => {
|
|
13502
|
+
const end = /* @__PURE__ */ new Date();
|
|
13503
|
+
const start = /* @__PURE__ */ new Date();
|
|
13504
|
+
end.setDate(end.getDate() + 7);
|
|
13505
|
+
start.setHours(0, 0, 0);
|
|
13506
|
+
end.setHours(23, 59, 59);
|
|
13507
|
+
return [start, end];
|
|
13508
|
+
}
|
|
13509
|
+
},
|
|
13510
|
+
{
|
|
13511
|
+
text: "后1月",
|
|
13512
|
+
value: () => {
|
|
13513
|
+
const end = /* @__PURE__ */ new Date();
|
|
13514
|
+
const start = /* @__PURE__ */ new Date();
|
|
13515
|
+
end.setMonth(end.getMonth() + 1);
|
|
13516
|
+
start.setHours(0, 0, 0);
|
|
13517
|
+
end.setHours(23, 59, 59);
|
|
13518
|
+
return [start, end];
|
|
13519
|
+
}
|
|
13520
|
+
},
|
|
13521
|
+
{
|
|
13522
|
+
text: "后3月",
|
|
13523
|
+
value: () => {
|
|
13524
|
+
const end = /* @__PURE__ */ new Date();
|
|
13525
|
+
const start = /* @__PURE__ */ new Date();
|
|
13526
|
+
end.setMonth(end.getMonth() + 3);
|
|
13527
|
+
start.setHours(0, 0, 0);
|
|
13528
|
+
end.setHours(23, 59, 59);
|
|
13529
|
+
return [start, end];
|
|
13530
|
+
}
|
|
13531
|
+
},
|
|
13532
|
+
{
|
|
13533
|
+
text: "后6月",
|
|
13534
|
+
value: () => {
|
|
13535
|
+
const end = /* @__PURE__ */ new Date();
|
|
13536
|
+
const start = /* @__PURE__ */ new Date();
|
|
13537
|
+
end.setMonth(end.getMonth() + 6);
|
|
13538
|
+
start.setHours(0, 0, 0);
|
|
13539
|
+
end.setHours(23, 59, 59);
|
|
13540
|
+
return [start, end];
|
|
13541
|
+
}
|
|
13542
|
+
},
|
|
13543
|
+
{
|
|
13544
|
+
text: "后1年",
|
|
13545
|
+
value: () => {
|
|
13546
|
+
const end = /* @__PURE__ */ new Date();
|
|
13547
|
+
const start = /* @__PURE__ */ new Date();
|
|
13548
|
+
end.setFullYear(end.getFullYear() + 1);
|
|
13549
|
+
start.setHours(0, 0, 0);
|
|
13550
|
+
end.setHours(23, 59, 59);
|
|
13551
|
+
return [start, end];
|
|
13552
|
+
}
|
|
13507
13553
|
}
|
|
13508
|
-
|
|
13509
|
-
|
|
13510
|
-
|
|
13511
|
-
|
|
13512
|
-
|
|
13513
|
-
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
|
|
13517
|
-
|
|
13554
|
+
];
|
|
13555
|
+
} else {
|
|
13556
|
+
return [
|
|
13557
|
+
{
|
|
13558
|
+
text: "近1天",
|
|
13559
|
+
value: () => {
|
|
13560
|
+
const end = /* @__PURE__ */ new Date();
|
|
13561
|
+
const start = /* @__PURE__ */ new Date();
|
|
13562
|
+
start.setDate(start.getDate() - 1);
|
|
13563
|
+
start.setHours(0, 0, 0);
|
|
13564
|
+
end.setHours(23, 59, 59);
|
|
13565
|
+
return [start, end];
|
|
13566
|
+
}
|
|
13567
|
+
},
|
|
13568
|
+
{
|
|
13569
|
+
text: "近3天",
|
|
13570
|
+
value: () => {
|
|
13571
|
+
const end = /* @__PURE__ */ new Date();
|
|
13572
|
+
const start = /* @__PURE__ */ new Date();
|
|
13573
|
+
start.setDate(start.getDate() - 3);
|
|
13574
|
+
start.setHours(0, 0, 0);
|
|
13575
|
+
end.setHours(23, 59, 59);
|
|
13576
|
+
return [start, end];
|
|
13577
|
+
}
|
|
13578
|
+
},
|
|
13579
|
+
{
|
|
13580
|
+
text: "近1周",
|
|
13581
|
+
value: () => {
|
|
13582
|
+
const end = /* @__PURE__ */ new Date();
|
|
13583
|
+
const start = /* @__PURE__ */ new Date();
|
|
13584
|
+
start.setDate(start.getDate() - 7);
|
|
13585
|
+
start.setHours(0, 0, 0);
|
|
13586
|
+
end.setHours(23, 59, 59);
|
|
13587
|
+
return [start, end];
|
|
13588
|
+
}
|
|
13589
|
+
},
|
|
13590
|
+
{
|
|
13591
|
+
text: "近1月",
|
|
13592
|
+
value: () => {
|
|
13593
|
+
const end = /* @__PURE__ */ new Date();
|
|
13594
|
+
const start = /* @__PURE__ */ new Date();
|
|
13595
|
+
start.setMonth(start.getMonth() - 1);
|
|
13596
|
+
start.setHours(0, 0, 0);
|
|
13597
|
+
end.setHours(23, 59, 59);
|
|
13598
|
+
return [start, end];
|
|
13599
|
+
}
|
|
13600
|
+
},
|
|
13601
|
+
{
|
|
13602
|
+
text: "近3月",
|
|
13603
|
+
value: () => {
|
|
13604
|
+
const end = /* @__PURE__ */ new Date();
|
|
13605
|
+
const start = /* @__PURE__ */ new Date();
|
|
13606
|
+
start.setMonth(start.getMonth() - 3);
|
|
13607
|
+
start.setHours(0, 0, 0);
|
|
13608
|
+
end.setHours(23, 59, 59);
|
|
13609
|
+
return [start, end];
|
|
13610
|
+
}
|
|
13611
|
+
},
|
|
13612
|
+
{
|
|
13613
|
+
text: "近6月",
|
|
13614
|
+
value: () => {
|
|
13615
|
+
const end = /* @__PURE__ */ new Date();
|
|
13616
|
+
const start = /* @__PURE__ */ new Date();
|
|
13617
|
+
start.setMonth(start.getMonth() - 6);
|
|
13618
|
+
start.setHours(0, 0, 0);
|
|
13619
|
+
end.setHours(23, 59, 59);
|
|
13620
|
+
return [start, end];
|
|
13621
|
+
}
|
|
13622
|
+
},
|
|
13623
|
+
{
|
|
13624
|
+
text: "近1年",
|
|
13625
|
+
value: () => {
|
|
13626
|
+
const end = /* @__PURE__ */ new Date();
|
|
13627
|
+
const start = /* @__PURE__ */ new Date();
|
|
13628
|
+
start.setFullYear(start.getFullYear() - 1);
|
|
13629
|
+
start.setHours(0, 0, 0);
|
|
13630
|
+
end.setHours(23, 59, 59);
|
|
13631
|
+
return [start, end];
|
|
13632
|
+
}
|
|
13518
13633
|
}
|
|
13519
|
-
|
|
13520
|
-
|
|
13634
|
+
];
|
|
13635
|
+
}
|
|
13521
13636
|
},
|
|
13522
13637
|
/**
|
|
13523
13638
|
* 判断传入的时间是否大于当前时间
|