@ztimson/utils 0.22.9 → 0.22.11
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 +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1406,8 +1406,8 @@ var __publicField = (obj, key, value2) => __defNormalProp(obj, typeof key !== "s
|
|
|
1406
1406
|
}
|
|
1407
1407
|
function adjustTz(date, offset) {
|
|
1408
1408
|
const currentOffset = date.getTimezoneOffset();
|
|
1409
|
-
|
|
1410
|
-
return new Date(date.getTime() +
|
|
1409
|
+
const adjustedOffset = offset * 60;
|
|
1410
|
+
return new Date(date.getTime() + (currentOffset - adjustedOffset) * 6e4);
|
|
1411
1411
|
}
|
|
1412
1412
|
function formatDate(date, format = "YYYY-MM-DD H:mm", tz) {
|
|
1413
1413
|
if (typeof date == "number" || typeof date == "string") date = new Date(date);
|
|
@@ -1486,7 +1486,7 @@ var __publicField = (obj, key, value2) => __defNormalProp(obj, typeof key !== "s
|
|
|
1486
1486
|
function timezone(date2) {
|
|
1487
1487
|
return new Intl.DateTimeFormat("en-US", { timeZoneName: "short" }).format(date2).split(" ").pop() || "";
|
|
1488
1488
|
}
|
|
1489
|
-
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,
|
|
1489
|
+
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, 3)).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().padEnd(3, "0")).replaceAll("SS", date.getMilliseconds().toString().slice(0, 1).padEnd(2, "0")).replaceAll("S", date.getMilliseconds().toString()[0]).replaceAll("A", date.getHours() >= 12 ? "PM" : "AM").replaceAll("a", date.getHours() >= 12 ? "pm" : "am").replaceAll("ZZ", tzOffset(isNaN(tz) ? date.getTimezoneOffset() : tz).replace(":", "")).replaceAll("Z", tzOffset(isNaN(tz) ? date.getTimezoneOffset() : tz)).replaceAll("z", typeof tz == "string" ? tz : timezone(date));
|
|
1490
1490
|
}
|
|
1491
1491
|
function instantInterval(fn, interval) {
|
|
1492
1492
|
fn();
|