@pawells/typescript-common 1.0.0
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/LICENSE +21 -0
- package/README.md +148 -0
- package/build/array/array-chunk.d.ts +10 -0
- package/build/array/array-chunk.d.ts.map +1 -0
- package/build/array/array-chunk.js +19 -0
- package/build/array/array-chunk.js.map +1 -0
- package/build/array/array-compact.d.ts +18 -0
- package/build/array/array-compact.d.ts.map +1 -0
- package/build/array/array-compact.js +22 -0
- package/build/array/array-compact.js.map +1 -0
- package/build/array/array-contains.d.ts +9 -0
- package/build/array/array-contains.d.ts.map +1 -0
- package/build/array/array-contains.js +13 -0
- package/build/array/array-contains.js.map +1 -0
- package/build/array/array-count-by.d.ts +21 -0
- package/build/array/array-count-by.d.ts.map +1 -0
- package/build/array/array-count-by.js +29 -0
- package/build/array/array-count-by.js.map +1 -0
- package/build/array/array-difference.d.ts +25 -0
- package/build/array/array-difference.d.ts.map +1 -0
- package/build/array/array-difference.js +34 -0
- package/build/array/array-difference.js.map +1 -0
- package/build/array/array-element.d.ts +7 -0
- package/build/array/array-element.d.ts.map +1 -0
- package/build/array/array-element.js +2 -0
- package/build/array/array-element.js.map +1 -0
- package/build/array/array-filter.d.ts +37 -0
- package/build/array/array-filter.d.ts.map +1 -0
- package/build/array/array-filter.js +78 -0
- package/build/array/array-filter.js.map +1 -0
- package/build/array/array-flatten.d.ts +16 -0
- package/build/array/array-flatten.d.ts.map +1 -0
- package/build/array/array-flatten.js +20 -0
- package/build/array/array-flatten.js.map +1 -0
- package/build/array/array-group-by.d.ts +13 -0
- package/build/array/array-group-by.d.ts.map +1 -0
- package/build/array/array-group-by.js +24 -0
- package/build/array/array-group-by.js.map +1 -0
- package/build/array/array-intersection.d.ts +25 -0
- package/build/array/array-intersection.d.ts.map +1 -0
- package/build/array/array-intersection.js +39 -0
- package/build/array/array-intersection.js.map +1 -0
- package/build/array/array-partition.d.ts +19 -0
- package/build/array/array-partition.d.ts.map +1 -0
- package/build/array/array-partition.js +32 -0
- package/build/array/array-partition.js.map +1 -0
- package/build/array/array-range.d.ts +18 -0
- package/build/array/array-range.d.ts.map +1 -0
- package/build/array/array-range.js +30 -0
- package/build/array/array-range.js.map +1 -0
- package/build/array/array-sample.d.ts +29 -0
- package/build/array/array-sample.d.ts.map +1 -0
- package/build/array/array-sample.js +19 -0
- package/build/array/array-sample.js.map +1 -0
- package/build/array/array-shuffle.d.ts +8 -0
- package/build/array/array-shuffle.d.ts.map +1 -0
- package/build/array/array-shuffle.js +19 -0
- package/build/array/array-shuffle.js.map +1 -0
- package/build/array/array-sort-by.d.ts +20 -0
- package/build/array/array-sort-by.d.ts.map +1 -0
- package/build/array/array-sort-by.js +31 -0
- package/build/array/array-sort-by.js.map +1 -0
- package/build/array/array-zip.d.ts +22 -0
- package/build/array/array-zip.d.ts.map +1 -0
- package/build/array/array-zip.js +25 -0
- package/build/array/array-zip.js.map +1 -0
- package/build/array/array.test.d.ts +2 -0
- package/build/array/array.test.d.ts.map +1 -0
- package/build/array/array.test.js +347 -0
- package/build/array/array.test.js.map +1 -0
- package/build/array/index.d.ts +27 -0
- package/build/array/index.d.ts.map +1 -0
- package/build/array/index.js +25 -0
- package/build/array/index.js.map +1 -0
- package/build/array/types.d.ts +32 -0
- package/build/array/types.d.ts.map +1 -0
- package/build/array/types.js +2 -0
- package/build/array/types.js.map +1 -0
- package/build/array/unique.d.ts +8 -0
- package/build/array/unique.d.ts.map +1 -0
- package/build/array/unique.js +13 -0
- package/build/array/unique.js.map +1 -0
- package/build/enum/enum-entries.d.ts +11 -0
- package/build/enum/enum-entries.d.ts.map +1 -0
- package/build/enum/enum-entries.js +14 -0
- package/build/enum/enum-entries.js.map +1 -0
- package/build/enum/enum-key-by-value.d.ts +13 -0
- package/build/enum/enum-key-by-value.d.ts.map +1 -0
- package/build/enum/enum-key-by-value.js +21 -0
- package/build/enum/enum-key-by-value.js.map +1 -0
- package/build/enum/enum-keys.d.ts +10 -0
- package/build/enum/enum-keys.d.ts.map +1 -0
- package/build/enum/enum-keys.js +14 -0
- package/build/enum/enum-keys.js.map +1 -0
- package/build/enum/enum-safe-value.d.ts +14 -0
- package/build/enum/enum-safe-value.d.ts.map +1 -0
- package/build/enum/enum-safe-value.js +16 -0
- package/build/enum/enum-safe-value.js.map +1 -0
- package/build/enum/enum-values.d.ts +19 -0
- package/build/enum/enum-values.d.ts.map +1 -0
- package/build/enum/enum-values.js +25 -0
- package/build/enum/enum-values.js.map +1 -0
- package/build/enum/enum.test.d.ts +2 -0
- package/build/enum/enum.test.d.ts.map +1 -0
- package/build/enum/enum.test.js +122 -0
- package/build/enum/enum.test.js.map +1 -0
- package/build/enum/index.d.ts +17 -0
- package/build/enum/index.d.ts.map +1 -0
- package/build/enum/index.js +17 -0
- package/build/enum/index.js.map +1 -0
- package/build/enum/types.d.ts +9 -0
- package/build/enum/types.d.ts.map +1 -0
- package/build/enum/types.js +2 -0
- package/build/enum/types.js.map +1 -0
- package/build/enum/validate-enum-value.d.ts +13 -0
- package/build/enum/validate-enum-value.d.ts.map +1 -0
- package/build/enum/validate-enum-value.js +18 -0
- package/build/enum/validate-enum-value.js.map +1 -0
- package/build/function/compose.d.ts +37 -0
- package/build/function/compose.d.ts.map +1 -0
- package/build/function/compose.js +7 -0
- package/build/function/compose.js.map +1 -0
- package/build/function/debounce.d.ts +25 -0
- package/build/function/debounce.d.ts.map +1 -0
- package/build/function/debounce.js +37 -0
- package/build/function/debounce.js.map +1 -0
- package/build/function/function.test.d.ts +2 -0
- package/build/function/function.test.d.ts.map +1 -0
- package/build/function/function.test.js +158 -0
- package/build/function/function.test.js.map +1 -0
- package/build/function/index.d.ts +17 -0
- package/build/function/index.d.ts.map +1 -0
- package/build/function/index.js +16 -0
- package/build/function/index.js.map +1 -0
- package/build/function/memoize.d.ts +23 -0
- package/build/function/memoize.d.ts.map +1 -0
- package/build/function/memoize.js +34 -0
- package/build/function/memoize.js.map +1 -0
- package/build/function/once.d.ts +17 -0
- package/build/function/once.d.ts.map +1 -0
- package/build/function/once.js +27 -0
- package/build/function/once.js.map +1 -0
- package/build/function/sleep.d.ts +20 -0
- package/build/function/sleep.d.ts.map +1 -0
- package/build/function/sleep.js +22 -0
- package/build/function/sleep.js.map +1 -0
- package/build/function/throttle.d.ts +17 -0
- package/build/function/throttle.d.ts.map +1 -0
- package/build/function/throttle.js +37 -0
- package/build/function/throttle.js.map +1 -0
- package/build/function/types.d.ts +5 -0
- package/build/function/types.d.ts.map +1 -0
- package/build/function/types.js +2 -0
- package/build/function/types.js.map +1 -0
- package/build/index.d.ts +32 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +51 -0
- package/build/index.js.map +1 -0
- package/build/object/assert-object.d.ts +8 -0
- package/build/object/assert-object.d.ts.map +1 -0
- package/build/object/assert-object.js +10 -0
- package/build/object/assert-object.js.map +1 -0
- package/build/object/clone.d.ts +39 -0
- package/build/object/clone.d.ts.map +1 -0
- package/build/object/clone.js +85 -0
- package/build/object/clone.js.map +1 -0
- package/build/object/equals.d.ts +44 -0
- package/build/object/equals.d.ts.map +1 -0
- package/build/object/equals.js +104 -0
- package/build/object/equals.js.map +1 -0
- package/build/object/filter-cached.d.ts +9 -0
- package/build/object/filter-cached.d.ts.map +1 -0
- package/build/object/filter-cached.js +108 -0
- package/build/object/filter-cached.js.map +1 -0
- package/build/object/filter.d.ts +85 -0
- package/build/object/filter.d.ts.map +1 -0
- package/build/object/filter.js +248 -0
- package/build/object/filter.js.map +1 -0
- package/build/object/has-circular-reference.d.ts +8 -0
- package/build/object/has-circular-reference.d.ts.map +1 -0
- package/build/object/has-circular-reference.js +40 -0
- package/build/object/has-circular-reference.js.map +1 -0
- package/build/object/hash.d.ts +20 -0
- package/build/object/hash.d.ts.map +1 -0
- package/build/object/hash.js +39 -0
- package/build/object/hash.js.map +1 -0
- package/build/object/index.d.ts +32 -0
- package/build/object/index.d.ts.map +1 -0
- package/build/object/index.js +30 -0
- package/build/object/index.js.map +1 -0
- package/build/object/key-value-pairs.d.ts +21 -0
- package/build/object/key-value-pairs.d.ts.map +1 -0
- package/build/object/key-value-pairs.js +28 -0
- package/build/object/key-value-pairs.js.map +1 -0
- package/build/object/map-cached.d.ts +9 -0
- package/build/object/map-cached.d.ts.map +1 -0
- package/build/object/map-cached.js +97 -0
- package/build/object/map-cached.js.map +1 -0
- package/build/object/map.d.ts +29 -0
- package/build/object/map.d.ts.map +1 -0
- package/build/object/map.js +40 -0
- package/build/object/map.js.map +1 -0
- package/build/object/merge.d.ts +14 -0
- package/build/object/merge.d.ts.map +1 -0
- package/build/object/merge.js +41 -0
- package/build/object/merge.js.map +1 -0
- package/build/object/object-diff.d.ts +40 -0
- package/build/object/object-diff.d.ts.map +1 -0
- package/build/object/object-diff.js +45 -0
- package/build/object/object-diff.js.map +1 -0
- package/build/object/object-flatten.d.ts +22 -0
- package/build/object/object-flatten.d.ts.map +1 -0
- package/build/object/object-flatten.js +38 -0
- package/build/object/object-flatten.js.map +1 -0
- package/build/object/object-invert.d.ts +20 -0
- package/build/object/object-invert.d.ts.map +1 -0
- package/build/object/object-invert.js +26 -0
- package/build/object/object-invert.js.map +1 -0
- package/build/object/object.test.d.ts +2 -0
- package/build/object/object.test.d.ts.map +1 -0
- package/build/object/object.test.js +432 -0
- package/build/object/object.test.js.map +1 -0
- package/build/object/omit.d.ts +8 -0
- package/build/object/omit.d.ts.map +1 -0
- package/build/object/omit.js +17 -0
- package/build/object/omit.js.map +1 -0
- package/build/object/pick.d.ts +50 -0
- package/build/object/pick.d.ts.map +1 -0
- package/build/object/pick.js +60 -0
- package/build/object/pick.js.map +1 -0
- package/build/object/property-paths.d.ts +115 -0
- package/build/object/property-paths.d.ts.map +1 -0
- package/build/object/property-paths.js +170 -0
- package/build/object/property-paths.js.map +1 -0
- package/build/object/security-utils.d.ts +59 -0
- package/build/object/security-utils.d.ts.map +1 -0
- package/build/object/security-utils.js +165 -0
- package/build/object/security-utils.js.map +1 -0
- package/build/object/sort-keys.d.ts +26 -0
- package/build/object/sort-keys.d.ts.map +1 -0
- package/build/object/sort-keys.js +52 -0
- package/build/object/sort-keys.js.map +1 -0
- package/build/object/types.d.ts +152 -0
- package/build/object/types.d.ts.map +1 -0
- package/build/object/types.js +6 -0
- package/build/object/types.js.map +1 -0
- package/build/string/case-conversion.d.ts +50 -0
- package/build/string/case-conversion.d.ts.map +1 -0
- package/build/string/case-conversion.js +94 -0
- package/build/string/case-conversion.js.map +1 -0
- package/build/string/formatting.d.ts +108 -0
- package/build/string/formatting.d.ts.map +1 -0
- package/build/string/formatting.js +171 -0
- package/build/string/formatting.js.map +1 -0
- package/build/string/index.d.ts +15 -0
- package/build/string/index.d.ts.map +1 -0
- package/build/string/index.js +14 -0
- package/build/string/index.js.map +1 -0
- package/build/string/string.test.d.ts +2 -0
- package/build/string/string.test.d.ts.map +1 -0
- package/build/string/string.test.js +321 -0
- package/build/string/string.test.js.map +1 -0
- package/build/string/transformation.d.ts +18 -0
- package/build/string/transformation.d.ts.map +1 -0
- package/build/string/transformation.js +32 -0
- package/build/string/transformation.js.map +1 -0
- package/build/string/types.d.ts +44 -0
- package/build/string/types.d.ts.map +1 -0
- package/build/string/types.js +2 -0
- package/build/string/types.js.map +1 -0
- package/build/string/validation.d.ts +18 -0
- package/build/string/validation.d.ts.map +1 -0
- package/build/string/validation.js +26 -0
- package/build/string/validation.js.map +1 -0
- package/build/time/elapsed-time/constants.d.ts +10 -0
- package/build/time/elapsed-time/constants.d.ts.map +1 -0
- package/build/time/elapsed-time/constants.js +96 -0
- package/build/time/elapsed-time/constants.js.map +1 -0
- package/build/time/elapsed-time/elapsed-time.d.ts +412 -0
- package/build/time/elapsed-time/elapsed-time.d.ts.map +1 -0
- package/build/time/elapsed-time/elapsed-time.js +652 -0
- package/build/time/elapsed-time/elapsed-time.js.map +1 -0
- package/build/time/elapsed-time/types.d.ts +150 -0
- package/build/time/elapsed-time/types.d.ts.map +1 -0
- package/build/time/elapsed-time/types.js +2 -0
- package/build/time/elapsed-time/types.js.map +1 -0
- package/build/time/elapsed-time/utils.d.ts +18 -0
- package/build/time/elapsed-time/utils.d.ts.map +1 -0
- package/build/time/elapsed-time/utils.js +24 -0
- package/build/time/elapsed-time/utils.js.map +1 -0
- package/build/time/index.d.ts +18 -0
- package/build/time/index.d.ts.map +1 -0
- package/build/time/index.js +17 -0
- package/build/time/index.js.map +1 -0
- package/build/time/stopwatch/entry-types.d.ts +13 -0
- package/build/time/stopwatch/entry-types.d.ts.map +1 -0
- package/build/time/stopwatch/entry-types.js +2 -0
- package/build/time/stopwatch/entry-types.js.map +1 -0
- package/build/time/stopwatch/entry.d.ts +80 -0
- package/build/time/stopwatch/entry.d.ts.map +1 -0
- package/build/time/stopwatch/entry.js +105 -0
- package/build/time/stopwatch/entry.js.map +1 -0
- package/build/time/stopwatch/stopwatch.d.ts +232 -0
- package/build/time/stopwatch/stopwatch.d.ts.map +1 -0
- package/build/time/stopwatch/stopwatch.js +315 -0
- package/build/time/stopwatch/stopwatch.js.map +1 -0
- package/build/time/time.test.d.ts +2 -0
- package/build/time/time.test.d.ts.map +1 -0
- package/build/time/time.test.js +211 -0
- package/build/time/time.test.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,652 @@
|
|
|
1
|
+
import { DEFAULT_UNIT_LABELS, FORMATS } from './constants.js';
|
|
2
|
+
import { ApplyDefaultOptions } from './utils.js';
|
|
3
|
+
// Time conversion constants
|
|
4
|
+
const MS_PER_SECOND = 1000;
|
|
5
|
+
const SECONDS_PER_MINUTE = 60;
|
|
6
|
+
const MINUTES_PER_HOUR = 60;
|
|
7
|
+
const HOURS_PER_DAY = 24;
|
|
8
|
+
const DAYS_PER_WEEK = 7;
|
|
9
|
+
const PRECISION_DECIMAL_PLACES = 3;
|
|
10
|
+
/**
|
|
11
|
+
* Represents a duration of time with formatting and calculation capabilities.
|
|
12
|
+
*/
|
|
13
|
+
export class ElapsedTime {
|
|
14
|
+
/** Whether the elapsed time represents a negative duration */
|
|
15
|
+
_IsNegative = false;
|
|
16
|
+
/** The total duration in milliseconds (always positive, sign stored in isNegative) */
|
|
17
|
+
_TotalMilliseconds = 0;
|
|
18
|
+
// Cached calculations for better performance - computed on-demand
|
|
19
|
+
/** Cached total seconds value */
|
|
20
|
+
_TotalSeconds = 0;
|
|
21
|
+
/** Cached total minutes value */
|
|
22
|
+
_TotalMinutes = 0;
|
|
23
|
+
/** Cached total hours value */
|
|
24
|
+
_TotalHours = 0;
|
|
25
|
+
/** Cached total days value */
|
|
26
|
+
_TotalDays = 0;
|
|
27
|
+
/** Cached seconds component (excluding complete minutes) */
|
|
28
|
+
_Seconds = 0;
|
|
29
|
+
/** Cached minutes component (excluding complete hours) */
|
|
30
|
+
_Minutes = 0;
|
|
31
|
+
/** Cached hours component (excluding complete days) */
|
|
32
|
+
_Hours = 0;
|
|
33
|
+
/** Cached days component (excluding complete weeks) */
|
|
34
|
+
_Days = 0;
|
|
35
|
+
/** Cached weeks component */
|
|
36
|
+
_Weeks = 0;
|
|
37
|
+
/** Cached milliseconds component (excluding complete seconds) */
|
|
38
|
+
_Milliseconds = 0;
|
|
39
|
+
/** Flag to track whether cached values have been calculated */
|
|
40
|
+
_ValuesCalculated = false;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new ElapsedTime instance.
|
|
43
|
+
* @param milliseconds The total number of milliseconds.
|
|
44
|
+
*/
|
|
45
|
+
constructor(milliseconds) {
|
|
46
|
+
this._TotalMilliseconds = Math.abs(milliseconds);
|
|
47
|
+
this._IsNegative = milliseconds < 0;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Calculate all time unit values for efficient access.
|
|
51
|
+
* This method performs the core time decomposition calculations and caches
|
|
52
|
+
* the results to avoid redundant computation on subsequent property access.
|
|
53
|
+
*
|
|
54
|
+
* The calculation process:
|
|
55
|
+
* 1. Converts total milliseconds to larger units (seconds, minutes, hours, days)
|
|
56
|
+
* 2. Calculates component values using modulo operations
|
|
57
|
+
* 3. Caches all results with the _valuesCalculated flag
|
|
58
|
+
*
|
|
59
|
+
* @private
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* // Internal usage - called automatically when accessing time properties
|
|
64
|
+
* const elapsed = new ElapsedTime(93784000); // 26h 3m 4s
|
|
65
|
+
* // First access triggers calculation
|
|
66
|
+
* console.log(elapsed.Hours); // 2 (26 % 24)
|
|
67
|
+
* console.log(elapsed.TotalHours); // 26
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
_CalculateTimeValues() {
|
|
71
|
+
if (this._ValuesCalculated)
|
|
72
|
+
return;
|
|
73
|
+
this._TotalSeconds = Math.floor(this._TotalMilliseconds / MS_PER_SECOND);
|
|
74
|
+
this._TotalMinutes = Math.floor(this._TotalSeconds / SECONDS_PER_MINUTE);
|
|
75
|
+
this._TotalHours = Math.floor(this._TotalMinutes / MINUTES_PER_HOUR);
|
|
76
|
+
this._TotalDays = Math.floor(this._TotalHours / HOURS_PER_DAY);
|
|
77
|
+
this._Weeks = Math.floor(this._TotalDays / DAYS_PER_WEEK);
|
|
78
|
+
this._Days = this._TotalDays % DAYS_PER_WEEK;
|
|
79
|
+
this._Hours = this._TotalHours % HOURS_PER_DAY;
|
|
80
|
+
this._Minutes = this._TotalMinutes % MINUTES_PER_HOUR;
|
|
81
|
+
this._Seconds = this._TotalSeconds % SECONDS_PER_MINUTE;
|
|
82
|
+
this._Milliseconds = this._TotalMilliseconds % MS_PER_SECOND;
|
|
83
|
+
this._ValuesCalculated = true;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Gets the number of weeks in the elapsed time.
|
|
87
|
+
*/
|
|
88
|
+
get Weeks() {
|
|
89
|
+
this._CalculateTimeValues();
|
|
90
|
+
return this._Weeks;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Gets the number of days in the elapsed time (excluding complete weeks).
|
|
94
|
+
*/
|
|
95
|
+
get Days() {
|
|
96
|
+
this._CalculateTimeValues();
|
|
97
|
+
return this._Days;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Gets the total number of days in the elapsed time.
|
|
101
|
+
*/
|
|
102
|
+
get TotalDays() {
|
|
103
|
+
this._CalculateTimeValues();
|
|
104
|
+
return this._TotalDays;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Gets the number of hours in the elapsed time (excluding complete days).
|
|
108
|
+
*/
|
|
109
|
+
get Hours() {
|
|
110
|
+
this._CalculateTimeValues();
|
|
111
|
+
return this._Hours;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Gets the hours component as a padded string.
|
|
115
|
+
* @param length The minimum length to pad to (default: 2).
|
|
116
|
+
* @returns The zero-padded string.
|
|
117
|
+
*/
|
|
118
|
+
HoursPadded(length = 2) {
|
|
119
|
+
return this.Hours.toString().padStart(length, '0');
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Gets the total number of hours in the elapsed time.
|
|
123
|
+
*/
|
|
124
|
+
get TotalHours() {
|
|
125
|
+
this._CalculateTimeValues();
|
|
126
|
+
return this._TotalHours;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Gets the total hours as a padded string.
|
|
130
|
+
* @param length The minimum length to pad to (default: 2).
|
|
131
|
+
* @returns The zero-padded string.
|
|
132
|
+
*/
|
|
133
|
+
TotalHoursPadded(length = 2) {
|
|
134
|
+
return this.TotalHours.toString().padStart(length, '0');
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Gets the number of minutes in the elapsed time (excluding complete hours).
|
|
138
|
+
*/
|
|
139
|
+
get Minutes() {
|
|
140
|
+
this._CalculateTimeValues();
|
|
141
|
+
return this._Minutes;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Gets the minutes component as a padded string.
|
|
145
|
+
* @param length The minimum length to pad to (default: 2).
|
|
146
|
+
* @returns The zero-padded string.
|
|
147
|
+
*/
|
|
148
|
+
MinutesPadded(length = 2) {
|
|
149
|
+
return this.Minutes.toString().padStart(length, '0');
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Gets the total number of minutes in the elapsed time.
|
|
153
|
+
*/
|
|
154
|
+
get TotalMinutes() {
|
|
155
|
+
this._CalculateTimeValues();
|
|
156
|
+
return this._TotalMinutes;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Gets the total minutes as a padded string.
|
|
160
|
+
* @param length The minimum length to pad to (default: 2).
|
|
161
|
+
* @returns The zero-padded string.
|
|
162
|
+
*/
|
|
163
|
+
TotalMinutesPadded(length = 2) {
|
|
164
|
+
return this.TotalMinutes.toString().padStart(length, '0');
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Gets the number of seconds in the elapsed time (excluding complete minutes).
|
|
168
|
+
*/
|
|
169
|
+
get Seconds() {
|
|
170
|
+
this._CalculateTimeValues();
|
|
171
|
+
return this._Seconds;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Gets the seconds component as a padded string.
|
|
175
|
+
* @param length The minimum length to pad to (default: 2).
|
|
176
|
+
* @returns The zero-padded string.
|
|
177
|
+
*/
|
|
178
|
+
SecondsPadded(length = 2) {
|
|
179
|
+
return this.Seconds.toString().padStart(length, '0');
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Gets the total number of seconds in the elapsed time.
|
|
183
|
+
*/
|
|
184
|
+
get TotalSeconds() {
|
|
185
|
+
this._CalculateTimeValues();
|
|
186
|
+
return this._TotalSeconds;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Gets the total seconds as a padded string.
|
|
190
|
+
* @param length The minimum length to pad to (default: 2).
|
|
191
|
+
* @returns The zero-padded string.
|
|
192
|
+
*/
|
|
193
|
+
TotalSecondsPadded(length = 2) {
|
|
194
|
+
return this.TotalSeconds.toString().padStart(length, '0');
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Gets the number of milliseconds in the elapsed time (excluding complete seconds).
|
|
198
|
+
*/
|
|
199
|
+
get Milliseconds() {
|
|
200
|
+
this._CalculateTimeValues();
|
|
201
|
+
return this._Milliseconds;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Gets the milliseconds component as a padded string.
|
|
205
|
+
* @param length The minimum length to pad to (default: 3).
|
|
206
|
+
* @returns The zero-padded string.
|
|
207
|
+
*/
|
|
208
|
+
MillisecondsPadded(length = PRECISION_DECIMAL_PLACES) {
|
|
209
|
+
return this.Milliseconds.toString().padStart(length, '0');
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Checks if the elapsed time represents a negative duration.
|
|
213
|
+
*/
|
|
214
|
+
get IsNegative() {
|
|
215
|
+
return this._IsNegative;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Gets the total number of milliseconds in the elapsed time.
|
|
219
|
+
*/
|
|
220
|
+
get TotalMilliseconds() {
|
|
221
|
+
return this._TotalMilliseconds;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Sets the total number of milliseconds in the elapsed time.
|
|
225
|
+
*/
|
|
226
|
+
set TotalMilliseconds(value) {
|
|
227
|
+
this._IsNegative = value < 0;
|
|
228
|
+
this._TotalMilliseconds = Math.abs(value);
|
|
229
|
+
this._ValuesCalculated = false;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Get the total milliseconds as a padded string.
|
|
233
|
+
*
|
|
234
|
+
* @param length - The minimum length to pad to (default: 3)
|
|
235
|
+
* @returns The total milliseconds as a zero-padded string
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```typescript
|
|
239
|
+
* const elapsed = new ElapsedTime(5750);
|
|
240
|
+
* console.log(elapsed.TotalMillisecondsPadded()); // "5750"
|
|
241
|
+
* console.log(elapsed.TotalMillisecondsPadded(6)); // "005750"
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
TotalMillisecondsPadded(length = PRECISION_DECIMAL_PLACES) {
|
|
245
|
+
return this.TotalMilliseconds.toString().padStart(length, '0');
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Create a new ElapsedTime instance from start and stop timestamps.
|
|
249
|
+
* Convenience method for calculating elapsed time between two points in time.
|
|
250
|
+
*
|
|
251
|
+
* @param start - The start time in milliseconds (typically from Date.now() or performance.now())
|
|
252
|
+
* @param stop - The stop time in milliseconds
|
|
253
|
+
* @returns A new ElapsedTime instance representing the duration between start and stop
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* const start = Date.now();
|
|
258
|
+
* // ... some operation that takes time ...
|
|
259
|
+
* const end = Date.now();
|
|
260
|
+
* const duration = ElapsedTime.From(start, end);
|
|
261
|
+
* console.log(duration.Format('CONCISE')); // "1s 250ms"
|
|
262
|
+
* ```
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* ```typescript
|
|
266
|
+
* // Using with performance.now() for high precision
|
|
267
|
+
* const start = performance.now();
|
|
268
|
+
* await someAsyncOperation();
|
|
269
|
+
* const end = performance.now();
|
|
270
|
+
* const duration = ElapsedTime.From(start, end);
|
|
271
|
+
* console.log(duration.Format('MEDIUM')); // "1 sec 250 ms"
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
static From(start, stop) {
|
|
275
|
+
return new ElapsedTime(stop - start);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Format a duration of time using static method convenience.
|
|
279
|
+
* Creates a temporary ElapsedTime instance and formats it in one operation.
|
|
280
|
+
*
|
|
281
|
+
* @param milliseconds - The total number of milliseconds to format
|
|
282
|
+
* @param format - The format string or predefined format name (default: 'CONCISE')
|
|
283
|
+
* @param options - Formatting options of type ITimeElapsedFormatOptions for customization
|
|
284
|
+
* @returns The formatted time string
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```typescript
|
|
288
|
+
* // Quick formatting without creating an instance
|
|
289
|
+
* console.log(ElapsedTime.Format(3661000)); // "1h 1m 1s"
|
|
290
|
+
* console.log(ElapsedTime.Format(3661000, 'LONG')); // "1 hour 1 minute 1 second"
|
|
291
|
+
*
|
|
292
|
+
* // With custom options
|
|
293
|
+
* const options = { maxUnits: 2, showZeroValues: false };
|
|
294
|
+
* console.log(ElapsedTime.Format(3661000, 'MEDIUM', options)); // "1 hour 1 min"
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
static Format(milliseconds, format = 'concise', options = {}) {
|
|
298
|
+
const elapsedTime = new ElapsedTime(milliseconds);
|
|
299
|
+
return elapsedTime.Format(format, options);
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Format the elapsed time according to the specified format and options.
|
|
303
|
+
* This is the primary formatting method that handles all predefined formats
|
|
304
|
+
* and custom formatting configurations.
|
|
305
|
+
*
|
|
306
|
+
* Available predefined formats:
|
|
307
|
+
* - **CONCISE**: "1h 30m 45s" - Ultra-compact with single-letter units
|
|
308
|
+
* - **SHORT**: "1hr 30min 45sec" - Abbreviated but readable units
|
|
309
|
+
* - **MEDIUM**: "1 hour 30 min 45 sec" - Balanced readability and length
|
|
310
|
+
* - **LONG**: "1 hour 30 minutes 45 seconds" - Full words with proper pluralization
|
|
311
|
+
* - **MOST_SIGNIFICANT**: Shows only the 2 most significant units
|
|
312
|
+
* - **TIME**: "1:30" - Clock-style hours:minutes format
|
|
313
|
+
* - **TIME_WITH_SECONDS**: "1:30:45" - Extended clock format with seconds
|
|
314
|
+
*
|
|
315
|
+
* @param format - The format string or predefined format name (default: 'CONCISE')
|
|
316
|
+
* @param options - Formatting options of type ITimeElapsedFormatOptions for fine-tuned control
|
|
317
|
+
* @returns The formatted time string
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```typescript
|
|
321
|
+
* const elapsed = new ElapsedTime(5425000); // 1h 30m 25s
|
|
322
|
+
*
|
|
323
|
+
* // Predefined formats
|
|
324
|
+
* elapsed.Format('CONCISE'); // "1h 30m 25s"
|
|
325
|
+
* elapsed.Format('SHORT'); // "1hr 30min 25sec"
|
|
326
|
+
* elapsed.Format('MEDIUM'); // "1 hour 30 min 25 sec"
|
|
327
|
+
* elapsed.Format('LONG'); // "1 hour 30 minutes 25 seconds"
|
|
328
|
+
* elapsed.Format('TIME'); // "1:30"
|
|
329
|
+
* elapsed.Format('TIME_WITH_SECONDS'); // "1:30:25"
|
|
330
|
+
* ```
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* ```typescript
|
|
334
|
+
* // Custom formatting with options
|
|
335
|
+
* const elapsed = new ElapsedTime(-5425000); // Negative duration
|
|
336
|
+
*
|
|
337
|
+
* const options = {
|
|
338
|
+
* negativeValueFormat: 'Parenthesis',
|
|
339
|
+
* maxUnits: 2,
|
|
340
|
+
* showZeroValues: false
|
|
341
|
+
* };
|
|
342
|
+
*
|
|
343
|
+
* elapsed.Format('MEDIUM', options); // "(1 hour 30 min)"
|
|
344
|
+
* ```
|
|
345
|
+
*
|
|
346
|
+
* @example
|
|
347
|
+
* ```typescript
|
|
348
|
+
* // Custom labels
|
|
349
|
+
* const elapsed = new ElapsedTime(5425000);
|
|
350
|
+
*
|
|
351
|
+
* const customOptions = {
|
|
352
|
+
* unitLabels: {
|
|
353
|
+
* hour: 'hrs',
|
|
354
|
+
* minute: 'mins',
|
|
355
|
+
* second: 'secs'
|
|
356
|
+
* }
|
|
357
|
+
* };
|
|
358
|
+
*
|
|
359
|
+
* elapsed.Format('CUSTOM', customOptions); // "1 hrs 30 mins 25 secs"
|
|
360
|
+
* ```
|
|
361
|
+
*/
|
|
362
|
+
Format(format = 'concise', options = {}) {
|
|
363
|
+
// Ensure all time values are calculated
|
|
364
|
+
this._CalculateTimeValues();
|
|
365
|
+
let resolvedOptions = { ...options };
|
|
366
|
+
// Handle predefined formats
|
|
367
|
+
if (typeof format === 'string') {
|
|
368
|
+
let normalizedFormat = format.toLowerCase().replace(/_/g, '');
|
|
369
|
+
if (normalizedFormat === 'mostsignificant')
|
|
370
|
+
normalizedFormat = 'mostSignificant';
|
|
371
|
+
if (normalizedFormat === 'timewithseconds')
|
|
372
|
+
normalizedFormat = 'timeWithSeconds';
|
|
373
|
+
if (normalizedFormat in FORMATS) {
|
|
374
|
+
resolvedOptions = { ...FORMATS[normalizedFormat], ...options };
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
const appliedOptions = ApplyDefaultOptions(resolvedOptions);
|
|
378
|
+
// Special case for LONG format which needs special handling
|
|
379
|
+
if (typeof format === 'string' && format.toLowerCase() === 'long') {
|
|
380
|
+
return this._FormatLong(appliedOptions);
|
|
381
|
+
}
|
|
382
|
+
return this._FormatUsingTokens(appliedOptions);
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Special formatter for LONG format with proper pluralization.
|
|
386
|
+
* Handles the unique requirements of the LONG format which uses
|
|
387
|
+
* full English words with grammatically correct singular/plural forms.
|
|
388
|
+
*
|
|
389
|
+
* @param options - Formatting options with LONG-specific settings
|
|
390
|
+
* @returns Formatted string with proper pluralization (e.g., "1 hour 30 minutes")
|
|
391
|
+
* @private
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```typescript
|
|
395
|
+
* // Internal usage - called automatically for LONG format
|
|
396
|
+
* const elapsed = new ElapsedTime(3661000); // 1 hour, 1 minute, 1 second
|
|
397
|
+
* elapsed.Format('LONG'); // "1 hour 1 minute 1 second" (all singular)
|
|
398
|
+
*
|
|
399
|
+
* const elapsed2 = new ElapsedTime(7322000); // 2 hours, 2 minutes, 2 seconds
|
|
400
|
+
* elapsed2.Format('LONG'); // "2 hours 2 minutes 2 seconds" (all plural)
|
|
401
|
+
* ```
|
|
402
|
+
*/
|
|
403
|
+
_FormatLong(options) {
|
|
404
|
+
const parts = [];
|
|
405
|
+
// Process each time unit in order of significance
|
|
406
|
+
if (this._Weeks > 0 || options.showZeroValues) {
|
|
407
|
+
parts.push(`${this._Weeks} ${this._Weeks === 1 ? 'week' : 'weeks'}`);
|
|
408
|
+
}
|
|
409
|
+
if (this._Days > 0 || options.showZeroValues) {
|
|
410
|
+
parts.push(`${this._Days} ${this._Days === 1 ? 'day' : 'days'}`);
|
|
411
|
+
}
|
|
412
|
+
if (this._Hours > 0 || options.showZeroValues) {
|
|
413
|
+
parts.push(`${this._Hours} ${this._Hours === 1 ? 'hour' : 'hours'}`);
|
|
414
|
+
}
|
|
415
|
+
if (this._Minutes > 0 || options.showZeroValues) {
|
|
416
|
+
parts.push(`${this._Minutes} ${this._Minutes === 1 ? 'minute' : 'minutes'}`);
|
|
417
|
+
}
|
|
418
|
+
if (this._Seconds > 0 || options.showZeroValues) {
|
|
419
|
+
parts.push(`${this._Seconds} ${this._Seconds === 1 ? 'second' : 'seconds'}`);
|
|
420
|
+
}
|
|
421
|
+
if (this._Milliseconds > 0 || options.showZeroValues) {
|
|
422
|
+
parts.push(`${this._Milliseconds} ${this._Milliseconds === 1 ? 'millisecond' : 'milliseconds'}`);
|
|
423
|
+
}
|
|
424
|
+
// Handle case where no parts were added
|
|
425
|
+
if (parts.length === 0) {
|
|
426
|
+
parts.push('0 seconds');
|
|
427
|
+
}
|
|
428
|
+
// Apply maxUnits if specified
|
|
429
|
+
if (options.maxUnits && parts.length > options.maxUnits) {
|
|
430
|
+
parts.length = options.maxUnits;
|
|
431
|
+
}
|
|
432
|
+
const formatted = parts.join(' ');
|
|
433
|
+
// Apply negative formatting
|
|
434
|
+
if (this.IsNegative) {
|
|
435
|
+
return ElapsedTime._ApplyNegativeFormatting(formatted, options);
|
|
436
|
+
}
|
|
437
|
+
return formatted;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Format the elapsed time using the token-based formatting system.
|
|
441
|
+
* This is the main formatting engine that handles all predefined formats
|
|
442
|
+
* except LONG (which has special pluralization requirements).
|
|
443
|
+
*
|
|
444
|
+
* The method:
|
|
445
|
+
* 1. Creates an array of time units with their values
|
|
446
|
+
* 2. Filters and limits units based on options
|
|
447
|
+
* 3. Determines formatting approach (TIME vs standard formats)
|
|
448
|
+
* 4. Applies appropriate formatting and returns the result
|
|
449
|
+
*
|
|
450
|
+
* @param options - Complete formatting options with defaults applied
|
|
451
|
+
* @returns Formatted time string according to the specified format
|
|
452
|
+
* @private
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* ```typescript
|
|
456
|
+
* // Internal usage - handles formats like CONCISE, SHORT, MEDIUM, TIME, etc.
|
|
457
|
+
* // Called automatically by Format() method for most format types
|
|
458
|
+
* ```
|
|
459
|
+
*/
|
|
460
|
+
_FormatUsingTokens(options) {
|
|
461
|
+
// Define all available time units
|
|
462
|
+
const units = [
|
|
463
|
+
{ unit: 'week', value: this.Weeks },
|
|
464
|
+
{ unit: 'day', value: this.Days },
|
|
465
|
+
{ unit: 'hour', value: this.Hours },
|
|
466
|
+
{ unit: 'minute', value: this.Minutes },
|
|
467
|
+
{ unit: 'second', value: this.Seconds },
|
|
468
|
+
{ unit: 'millisecond', value: this.Milliseconds },
|
|
469
|
+
];
|
|
470
|
+
// Filter and limit units based on options
|
|
471
|
+
const filteredUnits = ElapsedTime._FilterAndLimitUnits(units, options);
|
|
472
|
+
const unitLabels = options.unitLabels ?? DEFAULT_UNIT_LABELS.medium;
|
|
473
|
+
// Determine the formatting approach based on unit labels
|
|
474
|
+
let formatted;
|
|
475
|
+
// Check for time formats with colons (TIME, TIME_WITH_SECONDS)
|
|
476
|
+
const isTimeFormat = ElapsedTime._ValidateTimeFormat(unitLabels);
|
|
477
|
+
if (isTimeFormat) {
|
|
478
|
+
formatted = ElapsedTime._FormatTimeUnits(filteredUnits, unitLabels);
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
// Handle different format types
|
|
482
|
+
formatted = ElapsedTime._FormatStandardUnits(filteredUnits, unitLabels);
|
|
483
|
+
}
|
|
484
|
+
return this.IsNegative ? ElapsedTime._ApplyNegativeFormatting(formatted, options) : formatted;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Format time units for TIME and TIME_WITH_SECONDS formats
|
|
488
|
+
* These formats use special formatting with colons for displaying time (e.g., "1:30:45")
|
|
489
|
+
* @param units - Array of time units with their values
|
|
490
|
+
* @param unitLabels - Object containing label definitions for each time unit
|
|
491
|
+
* @returns Formatted time string with colons (e.g., "1:30:45")
|
|
492
|
+
* @private
|
|
493
|
+
*/
|
|
494
|
+
static _FormatTimeUnits(units, unitLabels) {
|
|
495
|
+
return units.map(({ unit, value: _value }) => {
|
|
496
|
+
const labelFunc = unitLabels[unit];
|
|
497
|
+
if (!labelFunc)
|
|
498
|
+
return '';
|
|
499
|
+
return typeof labelFunc === 'function' ? labelFunc(_value) : '';
|
|
500
|
+
}).join('');
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Format units for standard (non-time) formats
|
|
504
|
+
* Handles different formatting styles including CONCISE, SHORT, MEDIUM, LONG, and custom formats
|
|
505
|
+
* @param units - Array of time units with their values
|
|
506
|
+
* @param unitLabels - Object containing label definitions for each time unit
|
|
507
|
+
* @returns Formatted time string according to the specified format style
|
|
508
|
+
* @private
|
|
509
|
+
*/
|
|
510
|
+
static _FormatStandardUnits(units, unitLabels) {
|
|
511
|
+
// Handle LONG format with pluralization
|
|
512
|
+
if (Object.values(unitLabels).some((label) => typeof label === 'function')) {
|
|
513
|
+
return units.map(({ unit, value }) => {
|
|
514
|
+
const labelFunc = unitLabels[unit];
|
|
515
|
+
if (!labelFunc)
|
|
516
|
+
return '';
|
|
517
|
+
const label = typeof labelFunc === 'function' ? labelFunc(value) : labelFunc;
|
|
518
|
+
return `${value} ${label}`;
|
|
519
|
+
}).join(' ');
|
|
520
|
+
}
|
|
521
|
+
// For CONCISE and SHORT formats (e.g., "1h 30m" or "1hr 30min")
|
|
522
|
+
if (unitLabels === DEFAULT_UNIT_LABELS.concise || unitLabels === DEFAULT_UNIT_LABELS.short) {
|
|
523
|
+
return units.map(({ unit, value }) => `${value}${unitLabels[unit]}`).join(' ');
|
|
524
|
+
}
|
|
525
|
+
// For MEDIUM format (e.g., "1 hour 30 min")
|
|
526
|
+
if (unitLabels === DEFAULT_UNIT_LABELS.medium) {
|
|
527
|
+
return units.map(({ unit, value }) => `${value} ${unitLabels[unit]}`).join(' ');
|
|
528
|
+
}
|
|
529
|
+
// Custom labels (including those with commas)
|
|
530
|
+
return units.map(({ unit, value }) => {
|
|
531
|
+
const label = unitLabels[unit];
|
|
532
|
+
if (typeof label === 'undefined')
|
|
533
|
+
return '';
|
|
534
|
+
// For labels with built-in spaces or punctuation at the start
|
|
535
|
+
if (typeof label === 'string' && (label.startsWith(' ') || label.startsWith(','))) {
|
|
536
|
+
return `${value}${label}`;
|
|
537
|
+
}
|
|
538
|
+
// Handle special case for custom labels with commas - used in tests
|
|
539
|
+
if (typeof label === 'string' && label.trim().endsWith(',')) {
|
|
540
|
+
return `${value} ${label}`;
|
|
541
|
+
}
|
|
542
|
+
return `${value} ${label}`;
|
|
543
|
+
}).join('').trim(); // Join without spaces and trim any trailing spaces
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Determine if the unit labels represent a time format with colons.
|
|
547
|
+
* Analyzes the unit label configuration to detect TIME and TIME_WITH_SECONDS
|
|
548
|
+
* formats which require special colon-separated formatting.
|
|
549
|
+
*
|
|
550
|
+
* @param unitLabels - The unit labels to analyze
|
|
551
|
+
* @returns True if this is a colon-based time format, false for standard formats
|
|
552
|
+
* @private
|
|
553
|
+
*
|
|
554
|
+
* @example
|
|
555
|
+
* ```typescript
|
|
556
|
+
* // Internal usage - distinguishes between:
|
|
557
|
+
* // TIME format: "1:30" (colon-separated)
|
|
558
|
+
* // CONCISE format: "1h 30m" (space-separated with labels)
|
|
559
|
+
* ```
|
|
560
|
+
*/
|
|
561
|
+
static _ValidateTimeFormat(unitLabels) {
|
|
562
|
+
return Boolean(unitLabels.hour && typeof unitLabels.hour === 'function' && unitLabels.minute && typeof unitLabels.minute === 'function' && (String(unitLabels.hour).includes(':') || String(unitLabels.minute).includes('padStart')));
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Filter and limit time units based on formatting options.
|
|
566
|
+
* Applies showZeroValues and maxUnits options to determine which
|
|
567
|
+
* time components should be included in the final formatted output.
|
|
568
|
+
*
|
|
569
|
+
* @param units - All available time units with their calculated values
|
|
570
|
+
* @param options - Formatting options containing filtering rules
|
|
571
|
+
* @returns Filtered and limited array of time units for formatting
|
|
572
|
+
* @private
|
|
573
|
+
*
|
|
574
|
+
* @example
|
|
575
|
+
* ```typescript
|
|
576
|
+
* // Internal usage - handles cases like:
|
|
577
|
+
* // showZeroValues: false -> filters out units with value 0
|
|
578
|
+
* // maxUnits: 2 -> keeps only the first 2 significant units
|
|
579
|
+
* // All zero values -> ensures at least "0 seconds" is shown
|
|
580
|
+
* ```
|
|
581
|
+
*/
|
|
582
|
+
static _FilterAndLimitUnits(units, options) {
|
|
583
|
+
// Filter out zero values if not showing them
|
|
584
|
+
let filteredUnits = options.showZeroValues ? units : units.filter((item) => item.value > 0);
|
|
585
|
+
// Handle the case where all values are zero
|
|
586
|
+
if (filteredUnits.length === 0) {
|
|
587
|
+
// Show at least seconds as zero
|
|
588
|
+
filteredUnits = [{ unit: 'second', value: 0 }];
|
|
589
|
+
}
|
|
590
|
+
// Limit the number of units if specified
|
|
591
|
+
if (typeof options.maxUnits !== 'undefined' && filteredUnits.length > options.maxUnits) {
|
|
592
|
+
filteredUnits.length = options.maxUnits;
|
|
593
|
+
}
|
|
594
|
+
return filteredUnits;
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Apply negative value formatting based on user preferences.
|
|
598
|
+
* Wraps or modifies the formatted time string to indicate negative durations
|
|
599
|
+
* according to the specified negativeValueFormat option.
|
|
600
|
+
*
|
|
601
|
+
* @param output - The pre-formatted time string (positive representation)
|
|
602
|
+
* @param options - Formatting options containing negative value format preference
|
|
603
|
+
* @returns The formatted string with negative formatting applied if needed
|
|
604
|
+
* @private
|
|
605
|
+
*
|
|
606
|
+
* @example
|
|
607
|
+
* ```typescript
|
|
608
|
+
* // Internal usage - transforms positive format to negative representation:
|
|
609
|
+
* // NegativeSign: "1h 30m" -> "-1h 30m"
|
|
610
|
+
* // Parenthesis: "1h 30m" -> "(1h 30m)"
|
|
611
|
+
* // Brackets: "1h 30m" -> "[1h 30m]"
|
|
612
|
+
* // Empty: "1h 30m" -> "1h 30m" (no change)
|
|
613
|
+
* ```
|
|
614
|
+
*/
|
|
615
|
+
static _ApplyNegativeFormatting(output, options) {
|
|
616
|
+
switch (options.negativeValueFormat) {
|
|
617
|
+
case 'NegativeSign':
|
|
618
|
+
return `-${output}`;
|
|
619
|
+
case 'Parenthesis':
|
|
620
|
+
return `(${output})`;
|
|
621
|
+
case 'Brackets':
|
|
622
|
+
return `[${output}]`;
|
|
623
|
+
case 'Empty':
|
|
624
|
+
default:
|
|
625
|
+
return output;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Formats elapsed time using the specified configuration.
|
|
631
|
+
* This is a simplified formatting function that uses IFormatConfig for basic formatting options.
|
|
632
|
+
*
|
|
633
|
+
* @param milliseconds - The total number of milliseconds to format
|
|
634
|
+
* @param options - Formatting configuration options
|
|
635
|
+
* @returns The formatted time string
|
|
636
|
+
*
|
|
637
|
+
* @example
|
|
638
|
+
* ```typescript
|
|
639
|
+
* import { FormatElapsedTime } from './elapsed-time';
|
|
640
|
+
*
|
|
641
|
+
* console.log(FormatElapsedTime(3661000)); // "1h 1m 1s"
|
|
642
|
+
* console.log(FormatElapsedTime(3661000, { maxUnits: 1 })); // "1h"
|
|
643
|
+
* ```
|
|
644
|
+
*/
|
|
645
|
+
export function FormatElapsedTime(milliseconds, options) {
|
|
646
|
+
const elapsedTime = new ElapsedTime(milliseconds);
|
|
647
|
+
return elapsedTime.Format('concise', {
|
|
648
|
+
maxUnits: options?.maxUnits,
|
|
649
|
+
unitLabels: options?.unitLabels,
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
//# sourceMappingURL=elapsed-time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elapsed-time.js","sourceRoot":"","sources":["../../../src/time/elapsed-time/elapsed-time.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,4BAA4B;AAC5B,MAAM,aAAa,GAAG,IAAI,CAAC;AAC3B,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAEnC;;GAEG;AACH,MAAM,OAAO,WAAW;IACvB,8DAA8D;IACtD,WAAW,GAAY,KAAK,CAAC;IAErC,sFAAsF;IAC9E,kBAAkB,GAAW,CAAC,CAAC;IAEvC,kEAAkE;IAClE,iCAAiC;IACzB,aAAa,GAAW,CAAC,CAAC;IAElC,iCAAiC;IACzB,aAAa,GAAW,CAAC,CAAC;IAElC,+BAA+B;IACvB,WAAW,GAAW,CAAC,CAAC;IAEhC,8BAA8B;IACtB,UAAU,GAAW,CAAC,CAAC;IAE/B,4DAA4D;IACpD,QAAQ,GAAW,CAAC,CAAC;IAE7B,0DAA0D;IAClD,QAAQ,GAAW,CAAC,CAAC;IAE7B,uDAAuD;IAC/C,MAAM,GAAW,CAAC,CAAC;IAE3B,uDAAuD;IAC/C,KAAK,GAAW,CAAC,CAAC;IAE1B,6BAA6B;IACrB,MAAM,GAAW,CAAC,CAAC;IAE3B,iEAAiE;IACzD,aAAa,GAAW,CAAC,CAAC;IAElC,+DAA+D;IACvD,iBAAiB,GAAY,KAAK,CAAC;IAE3C;;;OAGG;IACH,YAAY,YAAoB;QAC/B,IAAI,CAAC,kBAAkB,GAAG,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