@cripty2001/utils 0.0.127 → 0.0.128

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.
@@ -171,7 +171,22 @@ function useRelTime(refresh = 1000) {
171
171
  const then = ts instanceof Date ? ts.getTime() : ts;
172
172
  const delta = then - now;
173
173
  const seconds = Math.round(delta / 1000);
174
- return rtf.format(seconds, "second");
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);
175
190
  }, [currTs, rtf]);
176
191
  return cb;
177
192
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cripty2001/utils",
3
- "version": "0.0.127",
3
+ "version": "0.0.128",
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": {