@ztimson/utils 0.22.6 → 0.22.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.
- package/dist/index.cjs +5 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +5 -57
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1442,64 +1442,12 @@ function formatDate(date, format = "YYYY-MM-DD H:mm ") {
|
|
|
1442
1442
|
const minutes = offset % 60;
|
|
1443
1443
|
return (offset > 0 ? "-" : "") + `${hours}:${minutes.toString().padStart(2, "0")}`;
|
|
1444
1444
|
}
|
|
1445
|
-
function timezone(
|
|
1446
|
-
const
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
return "IDLW";
|
|
1450
|
-
case -11:
|
|
1451
|
-
return "SST";
|
|
1452
|
-
case -10:
|
|
1453
|
-
return "HST";
|
|
1454
|
-
case -9:
|
|
1455
|
-
return "AKST";
|
|
1456
|
-
case -8:
|
|
1457
|
-
return "PST";
|
|
1458
|
-
case -7:
|
|
1459
|
-
return "MST";
|
|
1460
|
-
case -6:
|
|
1461
|
-
return "CST";
|
|
1462
|
-
case -5:
|
|
1463
|
-
return "EST";
|
|
1464
|
-
case -4:
|
|
1465
|
-
return "AST";
|
|
1466
|
-
case -3:
|
|
1467
|
-
return "ART";
|
|
1468
|
-
case -2:
|
|
1469
|
-
return "FNT";
|
|
1470
|
-
case -1:
|
|
1471
|
-
return "AZOT";
|
|
1472
|
-
case 0:
|
|
1473
|
-
return "UTC";
|
|
1474
|
-
case 1:
|
|
1475
|
-
return "CET";
|
|
1476
|
-
case 2:
|
|
1477
|
-
return "EET";
|
|
1478
|
-
case 3:
|
|
1479
|
-
return "MSK";
|
|
1480
|
-
case 4:
|
|
1481
|
-
return "SAMT";
|
|
1482
|
-
case 5:
|
|
1483
|
-
return "YEKT";
|
|
1484
|
-
case 6:
|
|
1485
|
-
return "OMST";
|
|
1486
|
-
case 7:
|
|
1487
|
-
return "KRAT";
|
|
1488
|
-
case 8:
|
|
1489
|
-
return "CST";
|
|
1490
|
-
case 9:
|
|
1491
|
-
return "JST";
|
|
1492
|
-
case 10:
|
|
1493
|
-
return "AEST";
|
|
1494
|
-
case 11:
|
|
1495
|
-
return "SBT";
|
|
1496
|
-
case 12:
|
|
1497
|
-
return "NZST";
|
|
1498
|
-
default:
|
|
1499
|
-
return "";
|
|
1500
|
-
}
|
|
1445
|
+
function timezone(date2) {
|
|
1446
|
+
const formatter = new Intl.DateTimeFormat("en-US", { timeZoneName: "short" });
|
|
1447
|
+
const formattedDate = formatter.format(date2);
|
|
1448
|
+
return formattedDate.split(" ").pop() || "";
|
|
1501
1449
|
}
|
|
1502
|
-
return format.replaceAll("YYYY", date.getFullYear().toString()).replaceAll("YY", date.getFullYear().toString().slice(2)).replaceAll("MMMM", month(date.getMonth())).replaceAll("MMM", month(date.getMonth()).slice(0, 2)).replaceAll("MM", (date.getMonth() + 1).toString().padStart(2, "0")).replaceAll("M", (date.getMonth() + 1).toString()).replaceAll("DDD", doy(date).toString()).replaceAll("DD", date.getDate().toString().padStart(2, "0")).replaceAll("Do", suffix(date.getDate())).replaceAll("D", date.getDate().toString()).replaceAll("dddd", day(date.getDay())).replaceAll("ddd", day(date.getDay()).slice(0, 2)).replaceAll("dd", date.getDate().toString().padStart(2, "0")).replaceAll("d", date.getDay().toString()).replaceAll("HH", date.getHours().toString().padStart(2, "0")).replaceAll("H", date.getHours().toString()).replaceAll("hh", (date.getHours() > 12 ? date.getHours() - 12 : date.getHours()).toString().padStart(2, "0")).replaceAll("h", (date.getHours() > 12 ? date.getHours() - 12 : date.getHours()).toString()).replaceAll("mm", date.getMinutes().toString().padStart(2, "0")).replaceAll("m", date.getMinutes().toString()).replaceAll("ss", date.getSeconds().toString().padStart(2, "0")).replaceAll("s", date.getSeconds().toString()).replaceAll("SSS", date.getMilliseconds().toString()).replaceAll("SS", date.getMilliseconds().toString().slice(0, 1)).replaceAll("S", date.getMilliseconds().toString()[0]).replaceAll("A", date.getHours() >= 12 ? "PM" : "AM").replaceAll("a", date.getHours() >= 12 ? "pm" : "am").replaceAll("ZZ", tzOffset(date.getTimezoneOffset()).replace(":", "")).replaceAll("Z", tzOffset(date.getTimezoneOffset())).replaceAll("z", timezone(date
|
|
1450
|
+
return format.replaceAll("YYYY", date.getFullYear().toString()).replaceAll("YY", date.getFullYear().toString().slice(2)).replaceAll("MMMM", month(date.getMonth())).replaceAll("MMM", month(date.getMonth()).slice(0, 2)).replaceAll("MM", (date.getMonth() + 1).toString().padStart(2, "0")).replaceAll("M", (date.getMonth() + 1).toString()).replaceAll("DDD", doy(date).toString()).replaceAll("DD", date.getDate().toString().padStart(2, "0")).replaceAll("Do", suffix(date.getDate())).replaceAll("D", date.getDate().toString()).replaceAll("dddd", day(date.getDay())).replaceAll("ddd", day(date.getDay()).slice(0, 2)).replaceAll("dd", date.getDate().toString().padStart(2, "0")).replaceAll("d", date.getDay().toString()).replaceAll("HH", date.getHours().toString().padStart(2, "0")).replaceAll("H", date.getHours().toString()).replaceAll("hh", (date.getHours() > 12 ? date.getHours() - 12 : date.getHours()).toString().padStart(2, "0")).replaceAll("h", (date.getHours() > 12 ? date.getHours() - 12 : date.getHours()).toString()).replaceAll("mm", date.getMinutes().toString().padStart(2, "0")).replaceAll("m", date.getMinutes().toString()).replaceAll("ss", date.getSeconds().toString().padStart(2, "0")).replaceAll("s", date.getSeconds().toString()).replaceAll("SSS", date.getMilliseconds().toString()).replaceAll("SS", date.getMilliseconds().toString().slice(0, 1)).replaceAll("S", date.getMilliseconds().toString()[0]).replaceAll("A", date.getHours() >= 12 ? "PM" : "AM").replaceAll("a", date.getHours() >= 12 ? "pm" : "am").replaceAll("ZZ", tzOffset(date.getTimezoneOffset()).replace(":", "")).replaceAll("Z", tzOffset(date.getTimezoneOffset())).replaceAll("z", timezone(date));
|
|
1503
1451
|
}
|
|
1504
1452
|
function sleep(ms) {
|
|
1505
1453
|
return new Promise((res) => setTimeout(res, ms));
|