@ztimson/utils 0.25.10 → 0.25.12

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.mjs CHANGED
@@ -1091,6 +1091,32 @@ async function sleepWhile(fn2, checkInterval = 100) {
1091
1091
  function timeUntil(date) {
1092
1092
  return (date instanceof Date ? date.getTime() : date) - (/* @__PURE__ */ new Date()).getTime();
1093
1093
  }
1094
+ function timezoneOffset(tz, date = /* @__PURE__ */ new Date()) {
1095
+ const dtf = new Intl.DateTimeFormat("en-US", {
1096
+ timeZone: tz,
1097
+ hour12: false,
1098
+ year: "numeric",
1099
+ month: "2-digit",
1100
+ day: "2-digit",
1101
+ hour: "2-digit",
1102
+ minute: "2-digit",
1103
+ second: "2-digit"
1104
+ });
1105
+ const parts = dtf.formatToParts(date);
1106
+ const get = (type) => {
1107
+ var _a;
1108
+ return Number((_a = parts.find((v) => v.type === type)) == null ? void 0 : _a.value);
1109
+ };
1110
+ const y = get("year");
1111
+ const mo = get("month");
1112
+ const d = get("day");
1113
+ const h = get("hour");
1114
+ const m = get("minute");
1115
+ const s = get("second");
1116
+ const asUTC = Date.UTC(y, mo - 1, d, h, m, s);
1117
+ const asLocal = date.getTime();
1118
+ return Math.round((asLocal - asUTC) / 6e4);
1119
+ }
1094
1120
  function downloadFile(blob, name) {
1095
1121
  if (!(blob instanceof Blob)) blob = new Blob(makeArray(blob));
1096
1122
  const url = URL.createObjectURL(blob);
@@ -1626,7 +1652,7 @@ function PES(str, ...args) {
1626
1652
  if (str[i]) combined.push(str[i]);
1627
1653
  if (args[i]) combined.push(args[i]);
1628
1654
  }
1629
- const [paths, methods] = combined.join("").split(":");
1655
+ const [paths, methods] = combined.join("/").split(":");
1630
1656
  return PathEvent.toString(paths, methods == null ? void 0 : methods.split(""));
1631
1657
  }
1632
1658
  class PathError extends Error {
@@ -1821,8 +1847,8 @@ class PathEventEmitter {
1821
1847
  this.prefix = prefix;
1822
1848
  }
1823
1849
  emit(event, ...args) {
1824
- const parsed = new PathEvent(`${this.prefix}/${new PathEvent(event).toString()}`);
1825
- this.listeners.filter((l) => PathEvent.has(l[0], `${this.prefix}/${event}`)).forEach(async (l) => l[1](parsed, ...args));
1850
+ const parsed = PE`${this.prefix}/${event}`;
1851
+ this.listeners.filter((l) => PathEvent.has(l[0], parsed)).forEach(async (l) => l[1](parsed, ...args));
1826
1852
  }
1827
1853
  off(listener) {
1828
1854
  this.listeners = this.listeners.filter((l) => l[1] != listener);
@@ -2165,6 +2191,7 @@ export {
2165
2191
  strSplice,
2166
2192
  timeUntil,
2167
2193
  timestampFilename,
2194
+ timezoneOffset,
2168
2195
  toCsv,
2169
2196
  uploadWithProgress,
2170
2197
  validateEmail,