@cripty2001/utils 0.0.128 → 0.0.130

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.
@@ -166,27 +166,24 @@ function useAsync(f, data, debouce = 200) {
166
166
  function useRelTime(refresh = 1000) {
167
167
  const currTs = useCurrentTimestamp(refresh);
168
168
  const rtf = (0, react_1.useRef)(new Intl.RelativeTimeFormat(navigator.language, { numeric: "auto" })).current;
169
+ const getFormat = (seconds) => {
170
+ console.log("getformat", seconds);
171
+ if (seconds < 60)
172
+ return "second";
173
+ if (seconds < 3600)
174
+ return "minute";
175
+ if (seconds < 86400)
176
+ return "hour";
177
+ if (seconds < 604800)
178
+ return "day";
179
+ return "week";
180
+ };
169
181
  const cb = (0, react_1.useCallback)((ts) => {
170
182
  const now = currTs;
171
183
  const then = ts instanceof Date ? ts.getTime() : ts;
172
184
  const delta = then - now;
173
185
  const seconds = Math.round(delta / 1000);
174
- const format = (() => {
175
- if (seconds < 60)
176
- return "second";
177
- if (seconds < 3600)
178
- return "minute";
179
- if (seconds < 86400)
180
- return "hour";
181
- if (seconds < 604800)
182
- return "day";
183
- if (seconds < 2592000)
184
- return "week";
185
- if (seconds < 31536000)
186
- return "month";
187
- return "year";
188
- })();
189
- return rtf.format(seconds, format);
186
+ return rtf.format(seconds, getFormat(seconds));
190
187
  }, [currTs, rtf]);
191
188
  return cb;
192
189
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cripty2001/utils",
3
- "version": "0.0.128",
3
+ "version": "0.0.130",
4
4
  "description": "Internal Set of utils. If you need them use them, otherwise go to the next package ;)",
5
5
  "homepage": "https://github.com/cripty2001/utils#readme",
6
6
  "bugs": {