danholibraryjs 1.11.0 → 2.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/dist/Classes/DanhoLogger.d.ts +23 -0
- package/dist/Classes/DanhoLogger.js +65 -0
- package/dist/Classes/Events/Event.d.ts +66 -66
- package/dist/Classes/Events/Event.js +114 -114
- package/dist/Classes/Events/EventCollection.d.ts +57 -57
- package/dist/Classes/Events/EventCollection.js +109 -109
- package/dist/Classes/Events/EventEmitter.d.ts +74 -74
- package/dist/Classes/Events/EventEmitter.js +97 -97
- package/dist/Classes/Events/index.d.ts +3 -3
- package/dist/Classes/Events/index.js +19 -19
- package/dist/Classes/Time/Date.d.ts +148 -147
- package/dist/Classes/Time/Date.js +241 -238
- package/dist/Classes/Time/Time.d.ts +66 -65
- package/dist/Classes/Time/Time.js +120 -117
- package/dist/Classes/Time/TimeProperties.d.ts +3 -3
- package/dist/Classes/Time/TimeProperties.js +2 -2
- package/dist/Classes/Time/TimeSpan.d.ts +123 -123
- package/dist/Classes/Time/TimeSpan.js +179 -179
- package/dist/Classes/Time/index.d.ts +4 -4
- package/dist/Classes/Time/index.js +20 -20
- package/dist/Classes/index.d.ts +4 -3
- package/dist/Classes/index.js +20 -19
- package/dist/Classes/store.d.ts +75 -75
- package/dist/Classes/store.js +84 -84
- package/dist/Extensions/Array/array.extension.d.ts +42 -0
- package/dist/Extensions/Array/array.extension.js +57 -0
- package/dist/Extensions/Array/crud.extension.d.ts +24 -0
- package/dist/Extensions/Array/crud.extension.js +28 -0
- package/dist/Extensions/Array/index.d.ts +20 -0
- package/dist/Extensions/Array/index.js +40 -0
- package/dist/Extensions/Array/loop.extension.d.ts +18 -0
- package/dist/Extensions/Array/loop.extension.js +23 -0
- package/dist/Extensions/Array/random.extension.d.ts +23 -0
- package/dist/Extensions/Array/random.extension.js +35 -0
- package/dist/Extensions/Array/sort.extension.d.ts +27 -0
- package/dist/Extensions/Array/sort.extension.js +31 -0
- package/dist/Extensions/Array/string.extension.d.ts +13 -0
- package/dist/Extensions/Array/string.extension.js +14 -0
- package/dist/Extensions/Array.d.ts +52 -52
- package/dist/Extensions/Array.js +51 -51
- package/dist/Extensions/Document.d.ts +27 -27
- package/dist/Extensions/Document.js +32 -32
- package/dist/Extensions/Function.d.ts +29 -14
- package/dist/Extensions/Function.js +23 -10
- package/dist/Extensions/Map.d.ts +54 -54
- package/dist/Extensions/Map.js +42 -42
- package/dist/Extensions/Number.d.ts +13 -0
- package/dist/Extensions/Number.js +40 -0
- package/dist/Extensions/Object/arrays.extension.d.ts +17 -0
- package/dist/Extensions/Object/arrays.extension.js +13 -0
- package/dist/Extensions/Object/booleans.extension.d.ts +18 -0
- package/dist/Extensions/Object/booleans.extension.js +37 -0
- package/dist/Extensions/Object/extracts.extension.d.ts +38 -0
- package/dist/Extensions/Object/extracts.extension.js +72 -0
- package/dist/Extensions/Object/index.d.ts +10 -49
- package/dist/Extensions/Object/index.js +36 -38
- package/dist/Extensions/Object/properties.d.ts +28 -28
- package/dist/Extensions/Object/properties.extension.d.ts +6 -0
- package/dist/Extensions/Object/properties.extension.js +4 -0
- package/dist/Extensions/Object/properties.js +19 -20
- package/dist/Extensions/String/case.extension.d.ts +12 -0
- package/dist/Extensions/String/case.extension.js +55 -0
- package/dist/Extensions/String/index.d.ts +4 -0
- package/dist/Extensions/String/index.js +30 -0
- package/dist/Extensions/String.d.ts +36 -36
- package/dist/Extensions/String.js +25 -25
- package/dist/Extensions/index.d.ts +6 -17
- package/dist/Extensions/index.js +22 -30
- package/dist/Functions/CopyToClipboard.d.ts +7 -7
- package/dist/Functions/CopyToClipboard.js +15 -15
- package/dist/Functions/GetCSSProperty.d.ts +15 -15
- package/dist/Functions/GetCSSProperty.js +26 -26
- package/dist/Functions/GetNestedProperty.d.ts +9 -9
- package/dist/Functions/GetNestedProperty.js +23 -23
- package/dist/Functions/HTMLEvent.d.ts +11 -11
- package/dist/Functions/HTMLEvent.js +14 -14
- package/dist/Functions/SetNavigationSelected.d.ts +9 -9
- package/dist/Functions/SetNavigationSelected.js +25 -25
- package/dist/Functions/index.d.ts +5 -5
- package/dist/Functions/index.js +21 -21
- package/dist/Interfaces/ElementOptions.d.ts +15 -15
- package/dist/Interfaces/ElementOptions.js +2 -2
- package/dist/Interfaces/IReplacement.d.ts +12 -12
- package/dist/Interfaces/IReplacement.js +2 -2
- package/dist/Interfaces/index.d.ts +2 -2
- package/dist/Interfaces/index.js +18 -18
- package/dist/Types/Able.d.ts +16 -0
- package/dist/Types/Able.js +2 -0
- package/dist/Types/Array.d.ts +6 -0
- package/dist/Types/Array.js +2 -0
- package/dist/Types/BetterTypes.d.ts +9 -9
- package/dist/Types/BetterTypes.js +2 -2
- package/dist/Types/C#.d.ts +8 -0
- package/dist/Types/C#.js +2 -0
- package/dist/Types/Date.d.ts +6 -6
- package/dist/Types/Date.js +2 -2
- package/dist/Types/Events.d.ts +10 -10
- package/dist/Types/Events.js +2 -2
- package/dist/Types/Function.d.ts +5 -0
- package/dist/Types/Function.js +2 -0
- package/dist/Types/Object.d.ts +4 -0
- package/dist/Types/Object.js +2 -0
- package/dist/Types/PropertiesWith.d.ts +34 -13
- package/dist/Types/PropertiesWith.js +2 -2
- package/dist/Types/String.d.ts +1 -0
- package/dist/Types/String.js +2 -0
- package/dist/Types/TransformTypes.d.ts +22 -16
- package/dist/Types/TransformTypes.js +2 -2
- package/dist/Types/index.d.ts +24 -65
- package/dist/Types/index.js +27 -21
- package/dist/Utils/ApiUtil/ApiTypes.d.ts +15 -15
- package/dist/Utils/ApiUtil/ApiTypes.js +15 -15
- package/dist/Utils/ApiUtil/RequestUtil.d.ts +19 -19
- package/dist/Utils/ApiUtil/RequestUtil.js +73 -73
- package/dist/Utils/ApiUtil/index.d.ts +20 -20
- package/dist/Utils/ApiUtil/index.js +33 -33
- package/dist/Utils/ApiUtils/ApiTypes.d.ts +15 -0
- package/dist/Utils/ApiUtils/ApiTypes.js +15 -0
- package/dist/Utils/ApiUtils/RequestUtil.d.ts +19 -0
- package/dist/Utils/ApiUtils/RequestUtil.js +73 -0
- package/dist/Utils/ApiUtils/index.d.ts +20 -0
- package/dist/Utils/ApiUtils/index.js +33 -0
- package/dist/Utils/ColorUtils.d.ts +11 -0
- package/dist/Utils/ColorUtils.js +93 -0
- package/dist/Utils/FormUtil.d.ts +6 -6
- package/dist/Utils/FormUtil.js +35 -35
- package/dist/Utils/FormUtils.d.ts +6 -0
- package/dist/Utils/FormUtils.js +35 -0
- package/dist/Utils/NumberUtils.d.ts +1 -0
- package/dist/Utils/NumberUtils.js +7 -0
- package/dist/Utils/PatcherUtils.d.ts +6 -0
- package/dist/Utils/PatcherUtils.js +80 -0
- package/dist/Utils/StringUtils.d.ts +3 -0
- package/dist/Utils/StringUtils.js +47 -0
- package/dist/Utils/TimeUtils/debounce.util.d.ts +22 -0
- package/dist/Utils/TimeUtils/debounce.util.js +78 -0
- package/dist/Utils/TimeUtils/functions.util.d.ts +4 -0
- package/dist/Utils/TimeUtils/functions.util.js +21 -0
- package/dist/Utils/TimeUtils/index.d.ts +15 -0
- package/dist/Utils/TimeUtils/index.js +34 -0
- package/dist/Utils/TimeUtils/throttle.util.d.ts +15 -0
- package/dist/Utils/TimeUtils/throttle.util.js +43 -0
- package/dist/Utils/index.d.ts +7 -2
- package/dist/Utils/index.js +23 -18
- package/dist/index.d.ts +5 -5
- package/dist/index.js +21 -21
- package/package.json +4 -2
- package/src/Classes/DanhoLogger.ts +78 -0
- package/src/Classes/Events/Event.ts +96 -96
- package/src/Classes/Events/EventCollection.ts +90 -90
- package/src/Classes/Events/EventEmitter.ts +68 -68
- package/src/Classes/Time/Date.ts +219 -216
- package/src/Classes/Time/Time.ts +109 -104
- package/src/Classes/Time/TimeSpan.ts +171 -171
- package/src/Classes/index.ts +1 -0
- package/src/Classes/store.ts +22 -22
- package/src/Extensions/Array/array.extension.ts +103 -0
- package/src/Extensions/Array/crud.extension.ts +46 -0
- package/src/Extensions/Array/index.ts +15 -0
- package/src/Extensions/Array/loop.extension.ts +38 -0
- package/src/Extensions/Array/random.extension.ts +56 -0
- package/src/Extensions/Array/sort.extension.ts +52 -0
- package/src/Extensions/Array/string.extension.ts +22 -0
- package/src/Extensions/Document.ts +39 -39
- package/src/Extensions/Function.ts +37 -10
- package/src/Extensions/Map.ts +56 -56
- package/src/Extensions/Number.ts +50 -0
- package/src/Extensions/Object/arrays.extension.ts +27 -0
- package/src/Extensions/Object/booleans.extension.ts +46 -0
- package/src/Extensions/Object/extracts.extension.ts +102 -0
- package/src/Extensions/Object/index.ts +9 -80
- package/src/Extensions/Object/properties.extension.ts +11 -0
- package/src/Extensions/Object/properties.ts +35 -36
- package/src/Extensions/String/case.extension.ts +95 -0
- package/src/Extensions/String/index.ts +5 -0
- package/src/Extensions/index.ts +2 -20
- package/src/Interfaces/ElementOptions.ts +7 -7
- package/src/Interfaces/IReplacement.ts +2 -2
- package/src/Types/Able.ts +22 -0
- package/src/Types/Array.ts +7 -0
- package/src/Types/C#.ts +9 -0
- package/src/Types/Date.ts +1 -1
- package/src/Types/Events.ts +12 -12
- package/src/Types/Function.ts +10 -0
- package/src/Types/Object.ts +4 -0
- package/src/Types/PropertiesWith.ts +35 -4
- package/src/Types/String.ts +1 -0
- package/src/Types/TransformTypes.ts +21 -13
- package/src/Types/index.ts +7 -69
- package/src/Utils/{ApiUtil → ApiUtils}/ApiTypes.ts +2 -1
- package/src/Utils/{ApiUtil → ApiUtils}/index.ts +1 -1
- package/src/Utils/ColorUtils.ts +102 -0
- package/src/Utils/{FormUtil.ts → FormUtils.ts} +2 -2
- package/src/Utils/NumberUtils.ts +3 -0
- package/src/Utils/PatcherUtils.ts +111 -0
- package/src/Utils/StringUtils.ts +44 -0
- package/src/Utils/TimeUtils/debounce.util.ts +85 -0
- package/src/Utils/TimeUtils/functions.util.ts +18 -0
- package/src/Utils/TimeUtils/index.ts +9 -0
- package/src/Utils/TimeUtils/throttle.util.ts +44 -0
- package/src/Utils/index.ts +8 -2
- package/src/Extensions/Array.ts +0 -95
- package/src/Extensions/String.ts +0 -54
- /package/src/Utils/{ApiUtil → ApiUtils}/RequestUtil.ts +0 -0
|
@@ -1,117 +1,120 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Time = exports.ms = exports.ValidTime = void 0;
|
|
4
|
-
exports.ValidTime = /^(\d+(?:\.|,)?\d*)(ms|s|m|h|d|w|M|y)$/;
|
|
5
|
-
/**
|
|
6
|
-
* Converts input into milliseconds
|
|
7
|
-
* @param input Input to convert to ms. 1s | 2m | 3h | 1M | 60000
|
|
8
|
-
* @returns Millisecond value of input
|
|
9
|
-
*/
|
|
10
|
-
function ms(input) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
['
|
|
25
|
-
['
|
|
26
|
-
['
|
|
27
|
-
['
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
static
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
static
|
|
113
|
-
return
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Time = exports.ms = exports.ValidTime = void 0;
|
|
4
|
+
exports.ValidTime = /^(\d+(?:\.|,)?\d*)(ms|s|m|h|d|w|M|y)$/;
|
|
5
|
+
/**
|
|
6
|
+
* Converts input into milliseconds. Supports multiple time units in one string by space separation. E.g. 1h 30m
|
|
7
|
+
* @param input Input to convert to ms. 1s | 2m | 3h | 1M | 60000
|
|
8
|
+
* @returns Millisecond value of input
|
|
9
|
+
*/
|
|
10
|
+
function ms(input) {
|
|
11
|
+
return input.toString().split(' ').reduce((result, unit) => result += msSingular(unit), 0);
|
|
12
|
+
}
|
|
13
|
+
exports.ms = ms;
|
|
14
|
+
function msSingular(input) {
|
|
15
|
+
if (typeof input === 'number')
|
|
16
|
+
return input;
|
|
17
|
+
const match = input.match(exports.ValidTime);
|
|
18
|
+
if (!match)
|
|
19
|
+
throw Error(`Invalid input string "${input}"`);
|
|
20
|
+
match.shift();
|
|
21
|
+
const [value, unit] = match;
|
|
22
|
+
// console.log({ value, unit, input, match });
|
|
23
|
+
const units = new Map([
|
|
24
|
+
['ms', Time.millisecond],
|
|
25
|
+
['s', Time.second],
|
|
26
|
+
['m', Time.minute],
|
|
27
|
+
['h', Time.hour],
|
|
28
|
+
['d', Time.day],
|
|
29
|
+
['w', Time.week],
|
|
30
|
+
['M', Time.month],
|
|
31
|
+
['y', Time.year]
|
|
32
|
+
]);
|
|
33
|
+
return parseInt(value) * units.get(unit);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Time utility class
|
|
37
|
+
* @borrows TimeDelay
|
|
38
|
+
* @borrows ms
|
|
39
|
+
*/
|
|
40
|
+
class Time {
|
|
41
|
+
/**
|
|
42
|
+
* Array of amount of days in the months. 0 indexed
|
|
43
|
+
*/
|
|
44
|
+
static get daysInMonth() {
|
|
45
|
+
return [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Amount of weeks per year
|
|
49
|
+
*/
|
|
50
|
+
static get weeksInYear() {
|
|
51
|
+
return Time.daysInYear * Time.day / Time.week;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Amount of days per year
|
|
55
|
+
*/
|
|
56
|
+
static get daysInYear() {
|
|
57
|
+
return Time.year / Time.day;
|
|
58
|
+
;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Returns function that converts value into double digit string
|
|
62
|
+
* @returns (value: number): string
|
|
63
|
+
*/
|
|
64
|
+
static DoubleDigit(value) {
|
|
65
|
+
return value.toString().length < 2 ? `0${value}` : value.toString();
|
|
66
|
+
}
|
|
67
|
+
static th(value, includeValue = false) {
|
|
68
|
+
const th = (() => {
|
|
69
|
+
switch (value) {
|
|
70
|
+
case 1: return 'st';
|
|
71
|
+
case 2: return 'nd';
|
|
72
|
+
case 3: return 'rd';
|
|
73
|
+
default: return 'th';
|
|
74
|
+
}
|
|
75
|
+
})();
|
|
76
|
+
return includeValue ? value + th : th;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Array of names of the months. 0 indexed
|
|
80
|
+
*/
|
|
81
|
+
static get MonthNames() {
|
|
82
|
+
return new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Array of names of the days of the week. 0 indexed
|
|
86
|
+
*/
|
|
87
|
+
static get DayNames() {
|
|
88
|
+
return new Array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
|
|
89
|
+
}
|
|
90
|
+
/** Millisecond in milliseconds (I know that sounds weird but the others make sense) */
|
|
91
|
+
static get millisecond() { return 1; }
|
|
92
|
+
/** Second in milliseconds */
|
|
93
|
+
static get second() { return Time.millisecond * 1000; }
|
|
94
|
+
/** Minute in milliseconds */
|
|
95
|
+
static get minute() { return Time.second * 60; }
|
|
96
|
+
/** Hour in milliseconds */
|
|
97
|
+
static get hour() { return Time.minute * 60; }
|
|
98
|
+
/** Day in milliseconds */
|
|
99
|
+
static get day() { return Time.hour * 24; }
|
|
100
|
+
/** Week in milliseconds */
|
|
101
|
+
static get week() { return Time.day * 7; }
|
|
102
|
+
/** Month in milliseconds */
|
|
103
|
+
static get month() {
|
|
104
|
+
return Time.avgMonth * Time.day;
|
|
105
|
+
}
|
|
106
|
+
/** Year in milliseconds */
|
|
107
|
+
static get year() {
|
|
108
|
+
const now = new Date();
|
|
109
|
+
return (365 + (now.getFullYear() % 4 == 0 ? 1 : 0)) * Time.day;
|
|
110
|
+
}
|
|
111
|
+
/** Average month in milliseconds */
|
|
112
|
+
static get avgMonth() {
|
|
113
|
+
return Math.round(this.daysInMonth.reduce((result, num) => result += num, 0) / 12);
|
|
114
|
+
}
|
|
115
|
+
static ms(input) {
|
|
116
|
+
return ms(input);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.Time = Time;
|
|
120
|
+
exports.default = Time;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
type TimeKeys = 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
|
|
2
|
-
export type TimeProperties<Plural extends boolean = false> = Record<Plural extends true ? `${TimeKeys}s` : TimeKeys, number>;
|
|
3
|
-
export default TimeProperties;
|
|
1
|
+
type TimeKeys = 'year' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
|
|
2
|
+
export type TimeProperties<Plural extends boolean = false> = Record<Plural extends true ? `${TimeKeys}s` : TimeKeys, number>;
|
|
3
|
+
export default TimeProperties;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
import { TransformType } from "../../Types";
|
|
2
|
-
import DanhoDate, { DanhoDateConstructor } from "./Date";
|
|
3
|
-
import TimeProperties from "./TimeProperties";
|
|
4
|
-
/**
|
|
5
|
-
* What properties to include when using TimeSpan.toString(format: TimeSpanFormat): string
|
|
6
|
-
*/
|
|
7
|
-
export type TimeSpanFormat = Partial<TransformType<TimeProperties<true>, number, boolean>>;
|
|
8
|
-
/**
|
|
9
|
-
* Timespan between 2 dates.
|
|
10
|
-
* @borrows TimeSpanValue
|
|
11
|
-
* @borrows Time
|
|
12
|
-
* @borrows TimeProperties
|
|
13
|
-
*/
|
|
14
|
-
export declare class TimeSpan implements TimeProperties<true> {
|
|
15
|
-
constructor(from: DanhoDateConstructor, to?: DanhoDateConstructor);
|
|
16
|
-
/**
|
|
17
|
-
* Which of the dates in constructor had the highest getTime()
|
|
18
|
-
*/
|
|
19
|
-
private _highest;
|
|
20
|
-
/**
|
|
21
|
-
* Which of the dates in constructor had the lowest getTime()
|
|
22
|
-
*/
|
|
23
|
-
private _lowest;
|
|
24
|
-
/**
|
|
25
|
-
* The time difference between highest and lowest
|
|
26
|
-
* @returns Time difference in ms between this._highest and this._lowest
|
|
27
|
-
*/
|
|
28
|
-
private _getTimeDifference;
|
|
29
|
-
/**
|
|
30
|
-
* Reduces ms into provided timeDifference
|
|
31
|
-
* @param ms Millisecond value to reduce
|
|
32
|
-
* @param timeDifference Time difference in ms that for each timeDifference in ms, add 1 to result
|
|
33
|
-
* @returns How many times timeDifference fits in ms
|
|
34
|
-
*/
|
|
35
|
-
private _reduceTime;
|
|
36
|
-
/**
|
|
37
|
-
* Total years between dates
|
|
38
|
-
*/
|
|
39
|
-
years: number;
|
|
40
|
-
/**
|
|
41
|
-
* Total months between dates
|
|
42
|
-
*/
|
|
43
|
-
months: number;
|
|
44
|
-
/**
|
|
45
|
-
* Total weeks between dates
|
|
46
|
-
*/
|
|
47
|
-
weeks: number;
|
|
48
|
-
/**
|
|
49
|
-
* Total days between dates
|
|
50
|
-
*/
|
|
51
|
-
days: number;
|
|
52
|
-
/**
|
|
53
|
-
* Total hours between dates
|
|
54
|
-
*/
|
|
55
|
-
hours: number;
|
|
56
|
-
/**
|
|
57
|
-
* Total minutes between dates
|
|
58
|
-
*/
|
|
59
|
-
minutes: number;
|
|
60
|
-
/**
|
|
61
|
-
* Total seconds between dates
|
|
62
|
-
*/
|
|
63
|
-
seconds: number;
|
|
64
|
-
/**
|
|
65
|
-
* Total milliseconds between dates
|
|
66
|
-
*/
|
|
67
|
-
milliseconds: number;
|
|
68
|
-
/**
|
|
69
|
-
* Get the total unit time between the two dates
|
|
70
|
-
* @param unit Time unit in milliseconds
|
|
71
|
-
* @returns How many times that unit fits in total ms between the two dates
|
|
72
|
-
*/
|
|
73
|
-
private _getTotalUnit;
|
|
74
|
-
/**
|
|
75
|
-
* Get the maximum amount of months between the two dates
|
|
76
|
-
* @returns Number of max amount of months that are between the two dates
|
|
77
|
-
*/
|
|
78
|
-
getTotalMonths(): number;
|
|
79
|
-
/**
|
|
80
|
-
* Get the maximum amount of weeks between the two dates
|
|
81
|
-
* @returns Number of max amount of weeks that are between the two dates
|
|
82
|
-
*/
|
|
83
|
-
getTotalWeeks(): number;
|
|
84
|
-
/**
|
|
85
|
-
* Get the maximum amount of days between the two dates
|
|
86
|
-
* @returns Number of max amount of days that are between the two dates
|
|
87
|
-
*/
|
|
88
|
-
getTotalDays(): number;
|
|
89
|
-
/**
|
|
90
|
-
* Get the maximum amount of hours between the two dates
|
|
91
|
-
* @returns Number of max amount of hours that are between the two dates
|
|
92
|
-
*/
|
|
93
|
-
getTotalHours(): number;
|
|
94
|
-
/**
|
|
95
|
-
* Get the maximum amount of minutes between the two dates
|
|
96
|
-
* @returns Number of max amount of minutes that are between the two dates
|
|
97
|
-
*/
|
|
98
|
-
getTotalMinutes(): number;
|
|
99
|
-
/**
|
|
100
|
-
* Get the maximum amount of seconds between the two dates
|
|
101
|
-
* @returns Number of max amount of seconds that are between the two dates
|
|
102
|
-
*/
|
|
103
|
-
getTotalSeconds(): number;
|
|
104
|
-
/**
|
|
105
|
-
* Get the maximum amount of milliseconds between the two dates
|
|
106
|
-
* @returns Number of max amount of milliseconds that are between the two dates
|
|
107
|
-
*/
|
|
108
|
-
getTotalMilliseconds(): number;
|
|
109
|
-
/**
|
|
110
|
-
* Start date of timespan
|
|
111
|
-
*/
|
|
112
|
-
from: DanhoDate;
|
|
113
|
-
/**
|
|
114
|
-
* End date of timespan
|
|
115
|
-
*/
|
|
116
|
-
to: DanhoDate;
|
|
117
|
-
/**
|
|
118
|
-
* Timespan is in the past
|
|
119
|
-
*/
|
|
120
|
-
pastTense: boolean;
|
|
121
|
-
toString(format?: TimeSpanFormat): string;
|
|
122
|
-
}
|
|
123
|
-
export default TimeSpan;
|
|
1
|
+
import { TransformType } from "../../Types";
|
|
2
|
+
import DanhoDate, { DanhoDateConstructor } from "./Date";
|
|
3
|
+
import TimeProperties from "./TimeProperties";
|
|
4
|
+
/**
|
|
5
|
+
* What properties to include when using TimeSpan.toString(format: TimeSpanFormat): string
|
|
6
|
+
*/
|
|
7
|
+
export type TimeSpanFormat = Partial<TransformType<TimeProperties<true>, number, boolean>>;
|
|
8
|
+
/**
|
|
9
|
+
* Timespan between 2 dates.
|
|
10
|
+
* @borrows TimeSpanValue
|
|
11
|
+
* @borrows Time
|
|
12
|
+
* @borrows TimeProperties
|
|
13
|
+
*/
|
|
14
|
+
export declare class TimeSpan implements TimeProperties<true> {
|
|
15
|
+
constructor(from: DanhoDateConstructor, to?: DanhoDateConstructor);
|
|
16
|
+
/**
|
|
17
|
+
* Which of the dates in constructor had the highest getTime()
|
|
18
|
+
*/
|
|
19
|
+
private _highest;
|
|
20
|
+
/**
|
|
21
|
+
* Which of the dates in constructor had the lowest getTime()
|
|
22
|
+
*/
|
|
23
|
+
private _lowest;
|
|
24
|
+
/**
|
|
25
|
+
* The time difference between highest and lowest
|
|
26
|
+
* @returns Time difference in ms between this._highest and this._lowest
|
|
27
|
+
*/
|
|
28
|
+
private _getTimeDifference;
|
|
29
|
+
/**
|
|
30
|
+
* Reduces ms into provided timeDifference
|
|
31
|
+
* @param ms Millisecond value to reduce
|
|
32
|
+
* @param timeDifference Time difference in ms that for each timeDifference in ms, add 1 to result
|
|
33
|
+
* @returns How many times timeDifference fits in ms
|
|
34
|
+
*/
|
|
35
|
+
private _reduceTime;
|
|
36
|
+
/**
|
|
37
|
+
* Total years between dates
|
|
38
|
+
*/
|
|
39
|
+
years: number;
|
|
40
|
+
/**
|
|
41
|
+
* Total months between dates
|
|
42
|
+
*/
|
|
43
|
+
months: number;
|
|
44
|
+
/**
|
|
45
|
+
* Total weeks between dates
|
|
46
|
+
*/
|
|
47
|
+
weeks: number;
|
|
48
|
+
/**
|
|
49
|
+
* Total days between dates
|
|
50
|
+
*/
|
|
51
|
+
days: number;
|
|
52
|
+
/**
|
|
53
|
+
* Total hours between dates
|
|
54
|
+
*/
|
|
55
|
+
hours: number;
|
|
56
|
+
/**
|
|
57
|
+
* Total minutes between dates
|
|
58
|
+
*/
|
|
59
|
+
minutes: number;
|
|
60
|
+
/**
|
|
61
|
+
* Total seconds between dates
|
|
62
|
+
*/
|
|
63
|
+
seconds: number;
|
|
64
|
+
/**
|
|
65
|
+
* Total milliseconds between dates
|
|
66
|
+
*/
|
|
67
|
+
milliseconds: number;
|
|
68
|
+
/**
|
|
69
|
+
* Get the total unit time between the two dates
|
|
70
|
+
* @param unit Time unit in milliseconds
|
|
71
|
+
* @returns How many times that unit fits in total ms between the two dates
|
|
72
|
+
*/
|
|
73
|
+
private _getTotalUnit;
|
|
74
|
+
/**
|
|
75
|
+
* Get the maximum amount of months between the two dates
|
|
76
|
+
* @returns Number of max amount of months that are between the two dates
|
|
77
|
+
*/
|
|
78
|
+
getTotalMonths(): number;
|
|
79
|
+
/**
|
|
80
|
+
* Get the maximum amount of weeks between the two dates
|
|
81
|
+
* @returns Number of max amount of weeks that are between the two dates
|
|
82
|
+
*/
|
|
83
|
+
getTotalWeeks(): number;
|
|
84
|
+
/**
|
|
85
|
+
* Get the maximum amount of days between the two dates
|
|
86
|
+
* @returns Number of max amount of days that are between the two dates
|
|
87
|
+
*/
|
|
88
|
+
getTotalDays(): number;
|
|
89
|
+
/**
|
|
90
|
+
* Get the maximum amount of hours between the two dates
|
|
91
|
+
* @returns Number of max amount of hours that are between the two dates
|
|
92
|
+
*/
|
|
93
|
+
getTotalHours(): number;
|
|
94
|
+
/**
|
|
95
|
+
* Get the maximum amount of minutes between the two dates
|
|
96
|
+
* @returns Number of max amount of minutes that are between the two dates
|
|
97
|
+
*/
|
|
98
|
+
getTotalMinutes(): number;
|
|
99
|
+
/**
|
|
100
|
+
* Get the maximum amount of seconds between the two dates
|
|
101
|
+
* @returns Number of max amount of seconds that are between the two dates
|
|
102
|
+
*/
|
|
103
|
+
getTotalSeconds(): number;
|
|
104
|
+
/**
|
|
105
|
+
* Get the maximum amount of milliseconds between the two dates
|
|
106
|
+
* @returns Number of max amount of milliseconds that are between the two dates
|
|
107
|
+
*/
|
|
108
|
+
getTotalMilliseconds(): number;
|
|
109
|
+
/**
|
|
110
|
+
* Start date of timespan
|
|
111
|
+
*/
|
|
112
|
+
from: DanhoDate;
|
|
113
|
+
/**
|
|
114
|
+
* End date of timespan
|
|
115
|
+
*/
|
|
116
|
+
to: DanhoDate;
|
|
117
|
+
/**
|
|
118
|
+
* Timespan is in the past
|
|
119
|
+
*/
|
|
120
|
+
pastTense: boolean;
|
|
121
|
+
toString(format?: TimeSpanFormat): string;
|
|
122
|
+
}
|
|
123
|
+
export default TimeSpan;
|