@tsdotnet/date-time 1.0.28 → 1.0.33
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 -21
- package/README.md +11 -11
- package/dist/CalendarDate.d.ts +12 -0
- package/dist/Calendars/Gregorian.d.ts +37 -37
- package/dist/ClockTime.d.ts +20 -20
- package/dist/ClockTime.js +67 -67
- package/dist/ClockTime.js.map +1 -1
- package/dist/ClockTimeValue.d.ts +14 -0
- package/dist/DateTime.d.ts +154 -154
- package/dist/DateTime.js +305 -305
- package/dist/DateTime.js.map +1 -1
- package/dist/DateTimeKind.d.ts +15 -0
- package/dist/JsDateConvertible.d.ts +10 -0
- package/dist/TimeMeasurement.d.ts +15 -0
- package/dist/TimeQuantity.d.ts +50 -50
- package/dist/TimeQuantity.js +95 -95
- package/dist/TimeQuantity.js.map +1 -1
- package/dist/TimeSpan.d.ts +73 -73
- package/dist/TimeSpan.js +111 -111
- package/dist/TimeSpan.js.map +1 -1
- package/dist/TimeStamp.d.ts +25 -25
- package/dist/TimeStamp.js +45 -45
- package/dist/TimeStamp.js.map +1 -1
- package/dist/TimeStampValue.d.ts +13 -0
- package/dist/TimeUnit.d.ts +47 -47
- package/dist/TimeUnit.js +99 -99
- package/dist/TimeUnit.js.map +1 -1
- package/dist/TimeUnitValue.d.ts +19 -19
- package/dist/TimeUnitValue.js +46 -46
- package/dist/TimeUnitValue.js.map +1 -1
- package/dist/date-time.d.ts +20 -20
- package/dist/date-time.js +28 -24
- package/dist/date-time.js.map +1 -1
- package/dist/howMany.d.ts +39 -0
- package/dist/howMany.js +53 -0
- package/dist/howMany.js.map +1 -0
- package/dist-esm/ClockTime.js +62 -62
- package/dist-esm/ClockTime.js.map +1 -1
- package/dist-esm/DateTime.js +301 -301
- package/dist-esm/DateTime.js.map +1 -1
- package/dist-esm/TimeQuantity.js +91 -91
- package/dist-esm/TimeQuantity.js.map +1 -1
- package/dist-esm/TimeSpan.js +106 -106
- package/dist-esm/TimeSpan.js.map +1 -1
- package/dist-esm/TimeStamp.js +40 -40
- package/dist-esm/TimeStamp.js.map +1 -1
- package/dist-esm/TimeUnit.js +96 -96
- package/dist-esm/TimeUnit.js.map +1 -1
- package/dist-esm/TimeUnitValue.js +42 -42
- package/dist-esm/date-time.js +15 -13
- package/dist-esm/date-time.js.map +1 -1
- package/dist-esm/howMany.js +50 -0
- package/dist-esm/howMany.js.map +1 -0
- package/package.json +81 -62
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @author electricessence / https://github.com/electricessence/
|
|
3
|
+
* @license MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export default interface TimeMeasurement
|
|
8
|
+
{
|
|
9
|
+
ticks: number;
|
|
10
|
+
milliseconds: number;
|
|
11
|
+
seconds: number;
|
|
12
|
+
minutes: number;
|
|
13
|
+
hours: number;
|
|
14
|
+
days: number;
|
|
15
|
+
}
|
package/dist/TimeQuantity.d.ts
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* @author electricessence / https://github.com/electricessence/
|
|
3
|
-
* @license MIT
|
|
4
|
-
*/
|
|
5
|
-
import ResettableLazy from '@tsdotnet/lazy/dist/ResettableLazy';
|
|
6
|
-
import TimeMeasurement from './TimeMeasurement';
|
|
7
|
-
import TimeUnit from './TimeUnit';
|
|
8
|
-
/**
|
|
9
|
-
* This class provides a simple means for storing and calculating time quantities.
|
|
10
|
-
*/
|
|
11
|
-
export default class TimeQuantity {
|
|
12
|
-
protected _quantity: number;
|
|
13
|
-
constructor(_quantity?: number);
|
|
14
|
-
/**
|
|
15
|
-
* Combine total values by time unit.
|
|
16
|
-
* @param {Partial<TimeMeasurement>} values
|
|
17
|
-
* @return {number}
|
|
18
|
-
*/
|
|
19
|
-
static getTotalMillisecondsFrom(values: Partial<TimeMeasurement>): number;
|
|
20
|
-
/**
|
|
21
|
-
* +1, 0, or -1 depending on the time direction.
|
|
22
|
-
* @returns {number}
|
|
23
|
-
*/
|
|
24
|
-
get direction(): number;
|
|
25
|
-
protected _total: ResettableLazy<Readonly<TimeMeasurement>>;
|
|
26
|
-
/**
|
|
27
|
-
* Returns an object with all units exposed as totals.
|
|
28
|
-
* @returns {TimeMeasurement}
|
|
29
|
-
*/
|
|
30
|
-
get total(): Readonly<TimeMeasurement>;
|
|
31
|
-
getTotalMilliseconds(): number;
|
|
32
|
-
/**
|
|
33
|
-
* Compares this instance against any other time quantity instance and return true if the amount of time is the same.
|
|
34
|
-
* @param other
|
|
35
|
-
* @returns {boolean}
|
|
36
|
-
*/
|
|
37
|
-
equals(other: TimeQuantity): boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Compares this instance against any other time quantity instance.
|
|
40
|
-
* @param other
|
|
41
|
-
* @returns {number}
|
|
42
|
-
*/
|
|
43
|
-
compareTo(other: TimeQuantity): number;
|
|
44
|
-
/**
|
|
45
|
-
* Returns the total amount of time measured in the requested TimeUnit.
|
|
46
|
-
* @param units
|
|
47
|
-
* @returns {number}
|
|
48
|
-
*/
|
|
49
|
-
getTotal(units: TimeUnit.UnitType): number;
|
|
50
|
-
}
|
|
1
|
+
/*!
|
|
2
|
+
* @author electricessence / https://github.com/electricessence/
|
|
3
|
+
* @license MIT
|
|
4
|
+
*/
|
|
5
|
+
import ResettableLazy from '@tsdotnet/lazy/dist/ResettableLazy';
|
|
6
|
+
import TimeMeasurement from './TimeMeasurement';
|
|
7
|
+
import TimeUnit from './TimeUnit';
|
|
8
|
+
/**
|
|
9
|
+
* This class provides a simple means for storing and calculating time quantities.
|
|
10
|
+
*/
|
|
11
|
+
export default class TimeQuantity {
|
|
12
|
+
protected _quantity: number;
|
|
13
|
+
constructor(_quantity?: number);
|
|
14
|
+
/**
|
|
15
|
+
* Combine total values by time unit.
|
|
16
|
+
* @param {Partial<TimeMeasurement>} values
|
|
17
|
+
* @return {number}
|
|
18
|
+
*/
|
|
19
|
+
static getTotalMillisecondsFrom(values: Partial<TimeMeasurement>): number;
|
|
20
|
+
/**
|
|
21
|
+
* +1, 0, or -1 depending on the time direction.
|
|
22
|
+
* @returns {number}
|
|
23
|
+
*/
|
|
24
|
+
get direction(): number;
|
|
25
|
+
protected _total: ResettableLazy<Readonly<TimeMeasurement>>;
|
|
26
|
+
/**
|
|
27
|
+
* Returns an object with all units exposed as totals.
|
|
28
|
+
* @returns {TimeMeasurement}
|
|
29
|
+
*/
|
|
30
|
+
get total(): Readonly<TimeMeasurement>;
|
|
31
|
+
getTotalMilliseconds(): number;
|
|
32
|
+
/**
|
|
33
|
+
* Compares this instance against any other time quantity instance and return true if the amount of time is the same.
|
|
34
|
+
* @param other
|
|
35
|
+
* @returns {boolean}
|
|
36
|
+
*/
|
|
37
|
+
equals(other: TimeQuantity): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Compares this instance against any other time quantity instance.
|
|
40
|
+
* @param other
|
|
41
|
+
* @returns {number}
|
|
42
|
+
*/
|
|
43
|
+
compareTo(other: TimeQuantity): number;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the total amount of time measured in the requested TimeUnit.
|
|
46
|
+
* @param units
|
|
47
|
+
* @returns {number}
|
|
48
|
+
*/
|
|
49
|
+
getTotal(units: TimeUnit.UnitType): number;
|
|
50
|
+
}
|
package/dist/TimeQuantity.js
CHANGED
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* @author electricessence / https://github.com/electricessence/
|
|
4
|
-
* @license MIT
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const tslib_1 = require("tslib");
|
|
8
|
-
const areEqual_1 =
|
|
9
|
-
const compare_1 =
|
|
10
|
-
const ArgumentNullException_1 =
|
|
11
|
-
const ResettableLazy_1 =
|
|
12
|
-
const TimeUnit_1 =
|
|
13
|
-
/**
|
|
14
|
-
* This class provides a simple means for storing and calculating time quantities.
|
|
15
|
-
*/
|
|
16
|
-
class TimeQuantity {
|
|
17
|
-
constructor(_quantity = 0) {
|
|
18
|
-
this._quantity = _quantity;
|
|
19
|
-
this._total = ResettableLazy_1.default.create(() => {
|
|
20
|
-
const ms = this.getTotalMilliseconds();
|
|
21
|
-
return Object.freeze({
|
|
22
|
-
ticks: ms * 10000 /* millisecond */,
|
|
23
|
-
milliseconds: ms,
|
|
24
|
-
seconds: ms / 1000 /* second */,
|
|
25
|
-
minutes: ms / 60000 /* minute */,
|
|
26
|
-
hours: ms / 3600000 /* hour */,
|
|
27
|
-
days: ms / 86400000 /* day */
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Combine total values by time unit.
|
|
33
|
-
* @param {Partial<TimeMeasurement>} values
|
|
34
|
-
* @return {number}
|
|
35
|
-
*/
|
|
36
|
-
static getTotalMillisecondsFrom(values) {
|
|
37
|
-
if (!values)
|
|
38
|
-
return 0;
|
|
39
|
-
return (values.days || 0) * 86400000 /* day */ +
|
|
40
|
-
(values.hours || 0) * 3600000 /* hour */ +
|
|
41
|
-
(values.minutes || 0) * 60000 /* minute */ +
|
|
42
|
-
(values.seconds || 0) * 1000 /* second */ +
|
|
43
|
-
(values.milliseconds || 0) +
|
|
44
|
-
(values.ticks || 0) / 10000 /* millisecond */;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* +1, 0, or -1 depending on the time direction.
|
|
48
|
-
* @returns {number}
|
|
49
|
-
*/
|
|
50
|
-
get direction() {
|
|
51
|
-
return (0, compare_1.default)(this.getTotalMilliseconds(), 0);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Returns an object with all units exposed as totals.
|
|
55
|
-
* @returns {TimeMeasurement}
|
|
56
|
-
*/
|
|
57
|
-
get total() {
|
|
58
|
-
return this._total.value;
|
|
59
|
-
}
|
|
60
|
-
// Provides an overridable mechanism for extending this class.
|
|
61
|
-
getTotalMilliseconds() {
|
|
62
|
-
return this._quantity;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Compares this instance against any other time quantity instance and return true if the amount of time is the same.
|
|
66
|
-
* @param other
|
|
67
|
-
* @returns {boolean}
|
|
68
|
-
*/
|
|
69
|
-
equals(other) {
|
|
70
|
-
if (!other || !other.total)
|
|
71
|
-
return false;
|
|
72
|
-
return (0, areEqual_1.default)(this.getTotalMilliseconds(), other.total.milliseconds);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Compares this instance against any other time quantity instance.
|
|
76
|
-
* @param other
|
|
77
|
-
* @returns {number}
|
|
78
|
-
*/
|
|
79
|
-
compareTo(other) {
|
|
80
|
-
if (!other)
|
|
81
|
-
throw new ArgumentNullException_1.default('other');
|
|
82
|
-
if (!other.total)
|
|
83
|
-
throw new ArgumentNullException_1.default('other.total');
|
|
84
|
-
return (0, compare_1.default)(this.getTotalMilliseconds(), other && other.total && other.total.milliseconds);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Returns the total amount of time measured in the requested TimeUnit.
|
|
88
|
-
* @param units
|
|
89
|
-
* @returns {number}
|
|
90
|
-
*/
|
|
91
|
-
getTotal(units) {
|
|
92
|
-
return TimeUnit_1.default.fromMilliseconds(this.getTotalMilliseconds(), units);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
exports.default = TimeQuantity;
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* @author electricessence / https://github.com/electricessence/
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const tslib_1 = require("tslib");
|
|
8
|
+
const areEqual_1 = tslib_1.__importDefault(require("@tsdotnet/compare/dist/areEqual"));
|
|
9
|
+
const compare_1 = tslib_1.__importDefault(require("@tsdotnet/compare/dist/compare"));
|
|
10
|
+
const ArgumentNullException_1 = tslib_1.__importDefault(require("@tsdotnet/exceptions/dist/ArgumentNullException"));
|
|
11
|
+
const ResettableLazy_1 = tslib_1.__importDefault(require("@tsdotnet/lazy/dist/ResettableLazy"));
|
|
12
|
+
const TimeUnit_1 = tslib_1.__importDefault(require("./TimeUnit"));
|
|
13
|
+
/**
|
|
14
|
+
* This class provides a simple means for storing and calculating time quantities.
|
|
15
|
+
*/
|
|
16
|
+
class TimeQuantity {
|
|
17
|
+
constructor(_quantity = 0) {
|
|
18
|
+
this._quantity = _quantity;
|
|
19
|
+
this._total = ResettableLazy_1.default.create(() => {
|
|
20
|
+
const ms = this.getTotalMilliseconds();
|
|
21
|
+
return Object.freeze({
|
|
22
|
+
ticks: ms * 10000 /* ticks.per.millisecond */,
|
|
23
|
+
milliseconds: ms,
|
|
24
|
+
seconds: ms / 1000 /* milliseconds.per.second */,
|
|
25
|
+
minutes: ms / 60000 /* milliseconds.per.minute */,
|
|
26
|
+
hours: ms / 3600000 /* milliseconds.per.hour */,
|
|
27
|
+
days: ms / 86400000 /* milliseconds.per.day */
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Combine total values by time unit.
|
|
33
|
+
* @param {Partial<TimeMeasurement>} values
|
|
34
|
+
* @return {number}
|
|
35
|
+
*/
|
|
36
|
+
static getTotalMillisecondsFrom(values) {
|
|
37
|
+
if (!values)
|
|
38
|
+
return 0;
|
|
39
|
+
return (values.days || 0) * 86400000 /* milliseconds.per.day */ +
|
|
40
|
+
(values.hours || 0) * 3600000 /* milliseconds.per.hour */ +
|
|
41
|
+
(values.minutes || 0) * 60000 /* milliseconds.per.minute */ +
|
|
42
|
+
(values.seconds || 0) * 1000 /* milliseconds.per.second */ +
|
|
43
|
+
(values.milliseconds || 0) +
|
|
44
|
+
(values.ticks || 0) / 10000 /* ticks.per.millisecond */;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* +1, 0, or -1 depending on the time direction.
|
|
48
|
+
* @returns {number}
|
|
49
|
+
*/
|
|
50
|
+
get direction() {
|
|
51
|
+
return (0, compare_1.default)(this.getTotalMilliseconds(), 0);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Returns an object with all units exposed as totals.
|
|
55
|
+
* @returns {TimeMeasurement}
|
|
56
|
+
*/
|
|
57
|
+
get total() {
|
|
58
|
+
return this._total.value;
|
|
59
|
+
}
|
|
60
|
+
// Provides an overridable mechanism for extending this class.
|
|
61
|
+
getTotalMilliseconds() {
|
|
62
|
+
return this._quantity;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Compares this instance against any other time quantity instance and return true if the amount of time is the same.
|
|
66
|
+
* @param other
|
|
67
|
+
* @returns {boolean}
|
|
68
|
+
*/
|
|
69
|
+
equals(other) {
|
|
70
|
+
if (!other || !other.total)
|
|
71
|
+
return false;
|
|
72
|
+
return (0, areEqual_1.default)(this.getTotalMilliseconds(), other.total.milliseconds);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Compares this instance against any other time quantity instance.
|
|
76
|
+
* @param other
|
|
77
|
+
* @returns {number}
|
|
78
|
+
*/
|
|
79
|
+
compareTo(other) {
|
|
80
|
+
if (!other)
|
|
81
|
+
throw new ArgumentNullException_1.default('other');
|
|
82
|
+
if (!other.total)
|
|
83
|
+
throw new ArgumentNullException_1.default('other.total');
|
|
84
|
+
return (0, compare_1.default)(this.getTotalMilliseconds(), other && other.total && other.total.milliseconds);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Returns the total amount of time measured in the requested TimeUnit.
|
|
88
|
+
* @param units
|
|
89
|
+
* @returns {number}
|
|
90
|
+
*/
|
|
91
|
+
getTotal(units) {
|
|
92
|
+
return TimeUnit_1.default.fromMilliseconds(this.getTotalMilliseconds(), units);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.default = TimeQuantity;
|
|
96
96
|
//# sourceMappingURL=TimeQuantity.js.map
|
package/dist/TimeQuantity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeQuantity.js","sourceRoot":"","sources":["../src/TimeQuantity.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"TimeQuantity.js","sourceRoot":"","sources":["../src/TimeQuantity.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uFAAuD;AACvD,qFAAqD;AACrD,oHAAoF;AACpF,gGAAgE;AAGhE,kEAAkC;AAElC;;GAEG;AACH,MAAqB,YAAY;IAEhC,YAAuB,YAAoB,CAAC;QAArB,cAAS,GAAT,SAAS,CAAY;QAE3C,IAAI,CAAC,MAAM,GAAG,wBAAc,CAAC,MAAM,CAAC,GAAG,EAAE;YACxC,MAAM,EAAE,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAEvC,OAAO,MAAM,CAAC,MAAM,CAAC;gBACpB,KAAK,EAAE,EAAE,oCAAsB;gBAC/B,YAAY,EAAE,EAAE;gBAChB,OAAO,EAAE,EAAE,qCAAwB;gBACnC,OAAO,EAAE,EAAE,sCAAwB;gBACnC,KAAK,EAAE,EAAE,sCAAsB;gBAC/B,IAAI,EAAE,EAAE,sCAAqB;aAC7B,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,wBAAwB,CAAE,MAAgC;QAEhE,IAAG,CAAC,MAAM;YAAE,OAAO,CAAC,CAAC;QACrB,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,sCAAqB;YAC7C,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC,sCAAsB;YACzC,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC,sCAAwB;YAC7C,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC,qCAAwB;YAC7C,CAAC,MAAM,CAAC,YAAY,IAAI,CAAC,CAAC;YAC1B,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC,oCAAsB,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACH,IAAI,SAAS;QAEZ,OAAO,IAAA,iBAAO,EAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;IAID;;;OAGG;IACH,IAAI,KAAK;QAER,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IAC1B,CAAC;IAED,8DAA8D;IAC9D,oBAAoB;QAEnB,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAE,KAAmB;QAE1B,IAAG,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QACxC,OAAO,IAAA,kBAAQ,EAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACxE,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAE,KAAmB;QAE7B,IAAG,CAAC,KAAK;YAAE,MAAM,IAAI,+BAAqB,CAAC,OAAO,CAAC,CAAC;QACpD,IAAG,CAAC,KAAK,CAAC,KAAK;YAAE,MAAM,IAAI,+BAAqB,CAAC,aAAa,CAAC,CAAC;QAChE,OAAO,IAAA,iBAAO,EAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,KAAK,IAAI,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC/F,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAE,KAAwB;QAEjC,OAAO,kBAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;CACD;AA5FD,+BA4FC"}
|
package/dist/TimeSpan.d.ts
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* @author electricessence / https://github.com/electricessence/
|
|
3
|
-
* Originally based upon .NET source but with many additions and improvements.
|
|
4
|
-
* @license MIT
|
|
5
|
-
*/
|
|
6
|
-
import ClockTime from './ClockTime';
|
|
7
|
-
import TimeMeasurement from './TimeMeasurement';
|
|
8
|
-
import TimeQuantity from './TimeQuantity';
|
|
9
|
-
import TimeUnit from './TimeUnit';
|
|
10
|
-
/**
|
|
11
|
-
* TimeSpan expands on TimeQuantity to provide an class that is similar to .NET's TimeSpan including many useful static methods.
|
|
12
|
-
*/
|
|
13
|
-
export declare class TimeSpan extends TimeQuantity implements TimeMeasurement {
|
|
14
|
-
/**
|
|
15
|
-
* The total number of ticks that represent this amount of time.
|
|
16
|
-
*/
|
|
17
|
-
readonly ticks: number;
|
|
18
|
-
/**
|
|
19
|
-
* The total number of ticks that milliseconds this amount of time.
|
|
20
|
-
*/
|
|
21
|
-
readonly milliseconds: number;
|
|
22
|
-
/**
|
|
23
|
-
* The total number of ticks that seconds this amount of time.
|
|
24
|
-
*/
|
|
25
|
-
readonly seconds: number;
|
|
26
|
-
/**
|
|
27
|
-
* The total number of ticks that minutes this amount of time.
|
|
28
|
-
*/
|
|
29
|
-
readonly minutes: number;
|
|
30
|
-
/**
|
|
31
|
-
* The total number of ticks that hours this amount of time.
|
|
32
|
-
*/
|
|
33
|
-
readonly hours: number;
|
|
34
|
-
/**
|
|
35
|
-
* The total number of ticks that days this amount of time.
|
|
36
|
-
*/
|
|
37
|
-
readonly days: number;
|
|
38
|
-
protected constructor(value: number, units?: TimeUnit.UnitType);
|
|
39
|
-
static get zero(): TimeSpan;
|
|
40
|
-
/**
|
|
41
|
-
* Provides an standard interface for acquiring the total time.
|
|
42
|
-
* @returns {TimeSpan}
|
|
43
|
-
*/
|
|
44
|
-
get total(): TimeSpan;
|
|
45
|
-
private _time;
|
|
46
|
-
/**
|
|
47
|
-
* The value of this TimeSpan reduced to the clock and calendar.
|
|
48
|
-
* @return {ClockTime}
|
|
49
|
-
*/
|
|
50
|
-
get time(): ClockTime;
|
|
51
|
-
static from(values: Partial<TimeMeasurement>): TimeSpan;
|
|
52
|
-
static from(value: number, units: TimeUnit.UnitType): TimeSpan;
|
|
53
|
-
static fromDays(value: number): TimeSpan;
|
|
54
|
-
static fromHours(value: number): TimeSpan;
|
|
55
|
-
static fromMinutes(value: number): TimeSpan;
|
|
56
|
-
static fromSeconds(value: number): TimeSpan;
|
|
57
|
-
static fromMilliseconds(value: number): TimeSpan;
|
|
58
|
-
static fromTicks(value: number): TimeSpan;
|
|
59
|
-
/**
|
|
60
|
-
* Sum the value of this TimeSpan with another time quantity.
|
|
61
|
-
* @param {TimeQuantity | Partial<TimeMeasurement>} other
|
|
62
|
-
* @return {TimeSpan}
|
|
63
|
-
*/
|
|
64
|
-
add(other: TimeSpan | TimeQuantity | Partial<TimeMeasurement>): TimeSpan;
|
|
65
|
-
/**
|
|
66
|
-
* Sum the value of this TimeSpan with another unit value.
|
|
67
|
-
* @param {number} value
|
|
68
|
-
* @param {TimeUnit.UnitType} units
|
|
69
|
-
* @return {TimeSpan}
|
|
70
|
-
*/
|
|
71
|
-
addUnit(value: number, units?: TimeUnit.UnitType): TimeSpan;
|
|
72
|
-
}
|
|
73
|
-
export default TimeSpan;
|
|
1
|
+
/*!
|
|
2
|
+
* @author electricessence / https://github.com/electricessence/
|
|
3
|
+
* Originally based upon .NET source but with many additions and improvements.
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
import ClockTime from './ClockTime';
|
|
7
|
+
import TimeMeasurement from './TimeMeasurement';
|
|
8
|
+
import TimeQuantity from './TimeQuantity';
|
|
9
|
+
import TimeUnit from './TimeUnit';
|
|
10
|
+
/**
|
|
11
|
+
* TimeSpan expands on TimeQuantity to provide an class that is similar to .NET's TimeSpan including many useful static methods.
|
|
12
|
+
*/
|
|
13
|
+
export declare class TimeSpan extends TimeQuantity implements TimeMeasurement {
|
|
14
|
+
/**
|
|
15
|
+
* The total number of ticks that represent this amount of time.
|
|
16
|
+
*/
|
|
17
|
+
readonly ticks: number;
|
|
18
|
+
/**
|
|
19
|
+
* The total number of ticks that milliseconds this amount of time.
|
|
20
|
+
*/
|
|
21
|
+
readonly milliseconds: number;
|
|
22
|
+
/**
|
|
23
|
+
* The total number of ticks that seconds this amount of time.
|
|
24
|
+
*/
|
|
25
|
+
readonly seconds: number;
|
|
26
|
+
/**
|
|
27
|
+
* The total number of ticks that minutes this amount of time.
|
|
28
|
+
*/
|
|
29
|
+
readonly minutes: number;
|
|
30
|
+
/**
|
|
31
|
+
* The total number of ticks that hours this amount of time.
|
|
32
|
+
*/
|
|
33
|
+
readonly hours: number;
|
|
34
|
+
/**
|
|
35
|
+
* The total number of ticks that days this amount of time.
|
|
36
|
+
*/
|
|
37
|
+
readonly days: number;
|
|
38
|
+
protected constructor(value: number, units?: TimeUnit.UnitType);
|
|
39
|
+
static get zero(): TimeSpan;
|
|
40
|
+
/**
|
|
41
|
+
* Provides an standard interface for acquiring the total time.
|
|
42
|
+
* @returns {TimeSpan}
|
|
43
|
+
*/
|
|
44
|
+
get total(): TimeSpan;
|
|
45
|
+
private _time;
|
|
46
|
+
/**
|
|
47
|
+
* The value of this TimeSpan reduced to the clock and calendar.
|
|
48
|
+
* @return {ClockTime}
|
|
49
|
+
*/
|
|
50
|
+
get time(): ClockTime;
|
|
51
|
+
static from(values: Partial<TimeMeasurement>): TimeSpan;
|
|
52
|
+
static from(value: number, units: TimeUnit.UnitType): TimeSpan;
|
|
53
|
+
static fromDays(value: number): TimeSpan;
|
|
54
|
+
static fromHours(value: number): TimeSpan;
|
|
55
|
+
static fromMinutes(value: number): TimeSpan;
|
|
56
|
+
static fromSeconds(value: number): TimeSpan;
|
|
57
|
+
static fromMilliseconds(value: number): TimeSpan;
|
|
58
|
+
static fromTicks(value: number): TimeSpan;
|
|
59
|
+
/**
|
|
60
|
+
* Sum the value of this TimeSpan with another time quantity.
|
|
61
|
+
* @param {TimeQuantity | Partial<TimeMeasurement>} other
|
|
62
|
+
* @return {TimeSpan}
|
|
63
|
+
*/
|
|
64
|
+
add(other: TimeSpan | TimeQuantity | Partial<TimeMeasurement>): TimeSpan;
|
|
65
|
+
/**
|
|
66
|
+
* Sum the value of this TimeSpan with another unit value.
|
|
67
|
+
* @param {number} value
|
|
68
|
+
* @param {TimeUnit.UnitType} units
|
|
69
|
+
* @return {TimeSpan}
|
|
70
|
+
*/
|
|
71
|
+
addUnit(value: number, units?: TimeUnit.UnitType): TimeSpan;
|
|
72
|
+
}
|
|
73
|
+
export default TimeSpan;
|