@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 CHANGED
@@ -1446,64 +1446,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1446
1446
  const minutes = offset % 60;
1447
1447
  return (offset > 0 ? "-" : "") + `${hours}:${minutes.toString().padStart(2, "0")}`;
1448
1448
  }
1449
- function timezone(offset) {
1450
- const hours = offset / 60;
1451
- switch (hours) {
1452
- case -12:
1453
- return "IDLW";
1454
- case -11:
1455
- return "SST";
1456
- case -10:
1457
- return "HST";
1458
- case -9:
1459
- return "AKST";
1460
- case -8:
1461
- return "PST";
1462
- case -7:
1463
- return "MST";
1464
- case -6:
1465
- return "CST";
1466
- case -5:
1467
- return "EST";
1468
- case -4:
1469
- return "AST";
1470
- case -3:
1471
- return "ART";
1472
- case -2:
1473
- return "FNT";
1474
- case -1:
1475
- return "AZOT";
1476
- case 0:
1477
- return "UTC";
1478
- case 1:
1479
- return "CET";
1480
- case 2:
1481
- return "EET";
1482
- case 3:
1483
- return "MSK";
1484
- case 4:
1485
- return "SAMT";
1486
- case 5:
1487
- return "YEKT";
1488
- case 6:
1489
- return "OMST";
1490
- case 7:
1491
- return "KRAT";
1492
- case 8:
1493
- return "CST";
1494
- case 9:
1495
- return "JST";
1496
- case 10:
1497
- return "AEST";
1498
- case 11:
1499
- return "SBT";
1500
- case 12:
1501
- return "NZST";
1502
- default:
1503
- return "";
1504
- }
1449
+ function timezone(date2) {
1450
+ const formatter = new Intl.DateTimeFormat("en-US", { timeZoneName: "short" });
1451
+ const formattedDate = formatter.format(date2);
1452
+ return formattedDate.split(" ").pop() || "";
1505
1453
  }
1506
- 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.getTimezoneOffset()));
1454
+ 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));
1507
1455
  }
1508
1456
  function sleep(ms) {
1509
1457
  return new Promise((res) => setTimeout(res, ms));