quasar-ui-danx 0.4.89 → 0.4.90

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quasar-ui-danx",
3
- "version": "0.4.89",
3
+ "version": "0.4.90",
4
4
  "author": "Dan <dan@flytedesk.com>",
5
5
  "description": "DanX Vue / Quasar component library",
6
6
  "license": "MIT",
@@ -57,16 +57,16 @@ export function fLocalizedDateTime(dateTimeString: string, options = {}) {
57
57
  * @returns {string}
58
58
  */
59
59
  export function fDateTime(
60
- dateTime: string | DateTime | null = null,
61
- { format = "M/d/yy h:mma", empty = "- -" }: fDateOptions = {}
60
+ dateTime: string | DateTime | null = null,
61
+ { format = "M/d/yy h:mma", empty = "- -" }: fDateOptions = {}
62
62
  ) {
63
63
  const formatted = parseDateTime(dateTime)?.toFormat(format).toLowerCase();
64
64
  return formatted || empty;
65
65
  }
66
66
 
67
67
  export function fDateTimeMs(
68
- dateTime: string | DateTime | null = null,
69
- { empty = "- -" }: fDateOptions = {}
68
+ dateTime: string | DateTime | null = null,
69
+ { empty = "- -" }: fDateOptions = {}
70
70
  ) {
71
71
  const formatted = parseDateTime(dateTime)?.toFormat("M/d/yy H:mm:ss.SSS").toLowerCase();
72
72
  return formatted || empty;
@@ -201,6 +201,15 @@ export function fSecondsToDuration(seconds: number) {
201
201
  return `${hours ? hours + "h " : ""}${minutes ? minutes + "m " : ""}${secs}s`;
202
202
  }
203
203
 
204
+ /**
205
+ * Formats a number of milliseconds into a duration string in 00h 00m 00s 000ms format
206
+ */
207
+ export function fMillisecondsToDuration(milliseconds: number) {
208
+ const durStr = fSecondsToDuration(Math.floor(milliseconds / 1000));
209
+ return (durStr === "0s" ? "" : durStr) + ` ${Math.floor(milliseconds % 1000)}ms`;
210
+ }
211
+
212
+
204
213
  /**
205
214
  * Formats a duration between two date strings in 00h 00m 00s format
206
215
  */
@@ -274,8 +283,8 @@ export function fShortNumber(value: string | number, options?: { round: boolean
274
283
  if (short) {
275
284
  n = n / Math.pow(10, short.pow);
276
285
  return options?.round
277
- ? n + short.unit
278
- : n.toFixed(n > 100 ? 0 : 1) + short.unit;
286
+ ? n + short.unit
287
+ : n.toFixed(n > 100 ? 0 : 1) + short.unit;
279
288
  }
280
289
 
281
290
  return n;
@@ -329,9 +338,9 @@ export function centerTruncate(str: string, maxLength: number) {
329
338
  const frontCharCount = Math.floor((maxLength - 3) / 2);
330
339
  const backCharCount = maxLength - frontCharCount - 3;
331
340
  return (
332
- str.substring(0, frontCharCount) +
333
- "..." +
334
- str.substring(str.length - backCharCount)
341
+ str.substring(0, frontCharCount) +
342
+ "..." +
343
+ str.substring(str.length - backCharCount)
335
344
  );
336
345
  } else {
337
346
  return str;