@tsdotnet/date-time 1.0.23 → 1.0.27

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.
Files changed (44) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +11 -11
  3. package/dist/Calendars/Gregorian.d.ts +37 -37
  4. package/dist/ClockTime.d.ts +20 -20
  5. package/dist/ClockTime.js +67 -67
  6. package/dist/ClockTime.js.map +1 -1
  7. package/dist/DateTime.d.ts +154 -154
  8. package/dist/DateTime.js +305 -305
  9. package/dist/DateTime.js.map +1 -1
  10. package/dist/TimeQuantity.d.ts +50 -50
  11. package/dist/TimeQuantity.js +95 -95
  12. package/dist/TimeQuantity.js.map +1 -1
  13. package/dist/TimeSpan.d.ts +73 -73
  14. package/dist/TimeSpan.js +111 -111
  15. package/dist/TimeSpan.js.map +1 -1
  16. package/dist/TimeStamp.d.ts +25 -25
  17. package/dist/TimeStamp.js +45 -45
  18. package/dist/TimeStamp.js.map +1 -1
  19. package/dist/TimeUnit.d.ts +47 -47
  20. package/dist/TimeUnit.js +99 -99
  21. package/dist/TimeUnitValue.d.ts +19 -19
  22. package/dist/TimeUnitValue.js +46 -46
  23. package/dist/TimeUnitValue.js.map +1 -1
  24. package/dist/date-time.d.ts +20 -14
  25. package/dist/date-time.js +24 -24
  26. package/dist/date-time.js.map +1 -1
  27. package/dist-esm/ClockTime.js +62 -62
  28. package/dist-esm/ClockTime.js.map +1 -1
  29. package/dist-esm/DateTime.js +301 -301
  30. package/dist-esm/TimeQuantity.js +91 -91
  31. package/dist-esm/TimeSpan.js +106 -106
  32. package/dist-esm/TimeStamp.js +40 -40
  33. package/dist-esm/TimeUnit.js +96 -96
  34. package/dist-esm/TimeUnitValue.js +42 -42
  35. package/dist-esm/date-time.js +13 -13
  36. package/dist-esm/date-time.js.map +1 -1
  37. package/package.json +62 -62
  38. package/dist/CalendarDate.d.ts +0 -12
  39. package/dist/ClockTimeValue.d.ts +0 -14
  40. package/dist/DateTimeKind.d.ts +0 -15
  41. package/dist/JsDateConvertable.d.ts +0 -10
  42. package/dist/TimeMeasurement.d.ts +0 -15
  43. package/dist/TimeStampValue.d.ts +0 -13
  44. package/dist/howMany.d.ts +0 -59
package/dist/TimeSpan.js CHANGED
@@ -1,112 +1,112 @@
1
- "use strict";
2
- /*!
3
- * @author electricessence / https://github.com/electricessence/
4
- * Originally based upon .NET source but with many additions and improvements.
5
- * @license MIT
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.TimeSpan = void 0;
9
- const tslib_1 = require("tslib");
10
- const lazy_1 = tslib_1.__importDefault(require("@tsdotnet/lazy"));
11
- const type_1 = tslib_1.__importDefault(require("@tsdotnet/type"));
12
- const ClockTime_1 = tslib_1.__importDefault(require("./ClockTime"));
13
- const TimeQuantity_1 = tslib_1.__importDefault(require("./TimeQuantity"));
14
- const TimeUnit_1 = tslib_1.__importDefault(require("./TimeUnit"));
15
- /**
16
- * TimeSpan expands on TimeQuantity to provide an class that is similar to .NET's TimeSpan including many useful static methods.
17
- */
18
- class TimeSpan extends TimeQuantity_1.default {
19
- // In .NET the default type is Ticks, but for JavaScript, we will use Milliseconds.
20
- constructor(value, units = TimeUnit_1.default.UnitType.Milliseconds) {
21
- if (isNaN(value))
22
- throw Error('Cannot construct a TimeSpan from NaN value.');
23
- const ms = TimeUnit_1.default.toMilliseconds(value, units);
24
- super(ms);
25
- this.ticks = ms * 10000 /* millisecond */;
26
- this.milliseconds = ms;
27
- this.seconds = ms / 1000 /* second */;
28
- this.minutes = ms / 60000 /* minute */;
29
- this.hours = ms / 3600000 /* hour */;
30
- this.days = ms / 86400000 /* day */;
31
- this._time = lazy_1.default.create(() => new ClockTime_1.default(this.getTotalMilliseconds()));
32
- Object.freeze(this);
33
- }
34
- static get zero() {
35
- return timeSpanZero || (timeSpanZero = new TimeSpan(0));
36
- }
37
- /**
38
- * Provides an standard interface for acquiring the total time.
39
- * @returns {TimeSpan}
40
- */
41
- get total() {
42
- return this;
43
- }
44
- // Instead of the confusing getTotal versus unit name, expose a 'ClockTime' value which reports the individual components.
45
- /**
46
- * The value of this TimeSpan reduced to the clock and calendar.
47
- * @return {ClockTime}
48
- */
49
- get time() {
50
- return this._time.value;
51
- }
52
- static from(value, units) {
53
- if (!value)
54
- return TimeSpan.zero;
55
- if (typeof value === 'number') {
56
- if (units === undefined)
57
- throw new Error('A numerical value requires a TimeUnit.');
58
- return new TimeSpan(value, units);
59
- }
60
- const ms = TimeQuantity_1.default.getTotalMillisecondsFrom(value);
61
- return ms ? new TimeSpan(ms) : TimeSpan.zero;
62
- }
63
- static fromDays(value) {
64
- return value ? new TimeSpan(value, TimeUnit_1.default.UnitType.Days) : TimeSpan.zero;
65
- }
66
- static fromHours(value) {
67
- return value ? new TimeSpan(value, TimeUnit_1.default.UnitType.Hours) : TimeSpan.zero;
68
- }
69
- static fromMinutes(value) {
70
- return value ? new TimeSpan(value, TimeUnit_1.default.UnitType.Minutes) : TimeSpan.zero;
71
- }
72
- static fromSeconds(value) {
73
- return value ? new TimeSpan(value, TimeUnit_1.default.UnitType.Seconds) : TimeSpan.zero;
74
- }
75
- static fromMilliseconds(value) {
76
- return value ? new TimeSpan(value) : TimeSpan.zero;
77
- }
78
- static fromTicks(value) {
79
- return value ? new TimeSpan(value, TimeUnit_1.default.UnitType.Ticks) : TimeSpan.zero;
80
- }
81
- /**
82
- * Sum the value of this TimeSpan with another time quantity.
83
- * @param {TimeQuantity | Partial<TimeMeasurement>} other
84
- * @return {TimeSpan}
85
- */
86
- add(other) {
87
- if (!other)
88
- return this;
89
- if (type_1.default.isNumber(other))
90
- throw new Error('Use .addUnit(value:number, units:TimeUnit) to add a numerical value amount. Default units are milliseconds.\n' +
91
- '.add only supports quantifiable time values (TimeQuantity).');
92
- const otherMs = other instanceof TimeQuantity_1.default
93
- ? other.total.milliseconds
94
- : TimeQuantity_1.default.getTotalMillisecondsFrom(other);
95
- return new TimeSpan(this.getTotalMilliseconds() + otherMs);
96
- }
97
- /**
98
- * Sum the value of this TimeSpan with another unit value.
99
- * @param {number} value
100
- * @param {TimeUnit.UnitType} units
101
- * @return {TimeSpan}
102
- */
103
- addUnit(value, units = TimeUnit_1.default.UnitType.Milliseconds) {
104
- return value
105
- ? new TimeSpan(this.getTotalMilliseconds() + TimeUnit_1.default.toMilliseconds(value, units))
106
- : this;
107
- }
108
- }
109
- exports.TimeSpan = TimeSpan;
110
- let timeSpanZero;
111
- exports.default = TimeSpan;
1
+ "use strict";
2
+ /*!
3
+ * @author electricessence / https://github.com/electricessence/
4
+ * Originally based upon .NET source but with many additions and improvements.
5
+ * @license MIT
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.TimeSpan = void 0;
9
+ const tslib_1 = require("tslib");
10
+ const lazy_1 = (0, tslib_1.__importDefault)(require("@tsdotnet/lazy"));
11
+ const type_1 = (0, tslib_1.__importDefault)(require("@tsdotnet/type"));
12
+ const ClockTime_1 = (0, tslib_1.__importDefault)(require("./ClockTime"));
13
+ const TimeQuantity_1 = (0, tslib_1.__importDefault)(require("./TimeQuantity"));
14
+ const TimeUnit_1 = (0, tslib_1.__importDefault)(require("./TimeUnit"));
15
+ /**
16
+ * TimeSpan expands on TimeQuantity to provide an class that is similar to .NET's TimeSpan including many useful static methods.
17
+ */
18
+ class TimeSpan extends TimeQuantity_1.default {
19
+ // In .NET the default type is Ticks, but for JavaScript, we will use Milliseconds.
20
+ constructor(value, units = TimeUnit_1.default.UnitType.Milliseconds) {
21
+ if (isNaN(value))
22
+ throw Error('Cannot construct a TimeSpan from NaN value.');
23
+ const ms = TimeUnit_1.default.toMilliseconds(value, units);
24
+ super(ms);
25
+ this.ticks = ms * 10000 /* millisecond */;
26
+ this.milliseconds = ms;
27
+ this.seconds = ms / 1000 /* second */;
28
+ this.minutes = ms / 60000 /* minute */;
29
+ this.hours = ms / 3600000 /* hour */;
30
+ this.days = ms / 86400000 /* day */;
31
+ this._time = lazy_1.default.create(() => new ClockTime_1.default(this.getTotalMilliseconds()));
32
+ Object.freeze(this);
33
+ }
34
+ static get zero() {
35
+ return timeSpanZero || (timeSpanZero = new TimeSpan(0));
36
+ }
37
+ /**
38
+ * Provides an standard interface for acquiring the total time.
39
+ * @returns {TimeSpan}
40
+ */
41
+ get total() {
42
+ return this;
43
+ }
44
+ // Instead of the confusing getTotal versus unit name, expose a 'ClockTime' value which reports the individual components.
45
+ /**
46
+ * The value of this TimeSpan reduced to the clock and calendar.
47
+ * @return {ClockTime}
48
+ */
49
+ get time() {
50
+ return this._time.value;
51
+ }
52
+ static from(value, units) {
53
+ if (!value)
54
+ return TimeSpan.zero;
55
+ if (typeof value === 'number') {
56
+ if (units === undefined)
57
+ throw new Error('A numerical value requires a TimeUnit.');
58
+ return new TimeSpan(value, units);
59
+ }
60
+ const ms = TimeQuantity_1.default.getTotalMillisecondsFrom(value);
61
+ return ms ? new TimeSpan(ms) : TimeSpan.zero;
62
+ }
63
+ static fromDays(value) {
64
+ return value ? new TimeSpan(value, TimeUnit_1.default.UnitType.Days) : TimeSpan.zero;
65
+ }
66
+ static fromHours(value) {
67
+ return value ? new TimeSpan(value, TimeUnit_1.default.UnitType.Hours) : TimeSpan.zero;
68
+ }
69
+ static fromMinutes(value) {
70
+ return value ? new TimeSpan(value, TimeUnit_1.default.UnitType.Minutes) : TimeSpan.zero;
71
+ }
72
+ static fromSeconds(value) {
73
+ return value ? new TimeSpan(value, TimeUnit_1.default.UnitType.Seconds) : TimeSpan.zero;
74
+ }
75
+ static fromMilliseconds(value) {
76
+ return value ? new TimeSpan(value) : TimeSpan.zero;
77
+ }
78
+ static fromTicks(value) {
79
+ return value ? new TimeSpan(value, TimeUnit_1.default.UnitType.Ticks) : TimeSpan.zero;
80
+ }
81
+ /**
82
+ * Sum the value of this TimeSpan with another time quantity.
83
+ * @param {TimeQuantity | Partial<TimeMeasurement>} other
84
+ * @return {TimeSpan}
85
+ */
86
+ add(other) {
87
+ if (!other)
88
+ return this;
89
+ if (type_1.default.isNumber(other))
90
+ throw new Error('Use .addUnit(value:number, units:TimeUnit) to add a numerical value amount. Default units are milliseconds.\n' +
91
+ '.add only supports quantifiable time values (TimeQuantity).');
92
+ const otherMs = other instanceof TimeQuantity_1.default
93
+ ? other.total.milliseconds
94
+ : TimeQuantity_1.default.getTotalMillisecondsFrom(other);
95
+ return new TimeSpan(this.getTotalMilliseconds() + otherMs);
96
+ }
97
+ /**
98
+ * Sum the value of this TimeSpan with another unit value.
99
+ * @param {number} value
100
+ * @param {TimeUnit.UnitType} units
101
+ * @return {TimeSpan}
102
+ */
103
+ addUnit(value, units = TimeUnit_1.default.UnitType.Milliseconds) {
104
+ return value
105
+ ? new TimeSpan(this.getTotalMilliseconds() + TimeUnit_1.default.toMilliseconds(value, units))
106
+ : this;
107
+ }
108
+ }
109
+ exports.TimeSpan = TimeSpan;
110
+ let timeSpanZero;
111
+ exports.default = TimeSpan;
112
112
  //# sourceMappingURL=TimeSpan.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TimeSpan.js","sourceRoot":"","sources":["../src/TimeSpan.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAEH,kEAAkC;AAClC,kEAAkC;AAClC,oEAAoC;AAGpC,0EAA0C;AAC1C,kEAAkC;AAElC;;GAEG;AACH,MAAa,QACZ,SAAQ,sBAAY;IAiCpB,mFAAmF;IACnF,YAAuB,KAAa,EAAE,QAA2B,kBAAQ,CAAC,QAAQ,CAAC,YAAY;QAE9F,IAAG,KAAK,CAAC,KAAK,CAAC;YAAE,MAAM,KAAK,CAAC,6CAA6C,CAAC,CAAC;QAC5E,MAAM,EAAE,GAAG,kBAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACjD,KAAK,CAAC,EAAE,CAAC,CAAC;QAEV,IAAI,CAAC,KAAK,GAAG,EAAE,0BAAsB,CAAC;QACtC,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,EAAE,oBAAwB,CAAC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,CAAC,KAAK,CAAC;YACtB,MAAM,IAAI,KAAK,CACd,gHAAgH;gBAChH,6DAA6D,CAAC,CAAC;QAEjE,MAAM,OAAO,GAAG,KAAK,YAAY,sBAAY;YAC5C,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY;YAC1B,CAAC,CAAC,sBAAY,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC;QAEhD,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,oBAAoB,EAAE,GAAG,OAAO,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAE,KAAa,EAAE,QAA2B,kBAAQ,CAAC,QAAQ,CAAC,YAAY;QAEhF,OAAO,KAAK;YACX,CAAC,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,oBAAoB,EAAE,GAAG,kBAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACnF,CAAC,CAAC,IAAI,CAAC;IACT,CAAC;CACD;AA9JD,4BA8JC;AAGD,IAAI,YAAsB,CAAC;AAE3B,kBAAe,QAAQ,CAAC"}
@@ -1,25 +1,25 @@
1
- /*!
2
- * @author electricessence / https://github.com/electricessence/
3
- * @license MIT
4
- */
5
- import Gregorian from './Calendars/Gregorian';
6
- import JsDateConvertible from './JsDateConvertable';
7
- import { TimeStampValue } from './TimeStampValue';
8
- /**
9
- * An alternative to Date or DateTime. Is a model representing the exact date and time.
10
- */
11
- export declare class TimeStamp implements Required<TimeStampValue>, JsDateConvertible {
12
- readonly year: number;
13
- readonly month: Gregorian.Month;
14
- readonly day: number;
15
- readonly hour: number;
16
- readonly minute: number;
17
- readonly second: number;
18
- readonly millisecond: number;
19
- readonly tick: number;
20
- constructor(year: number, month: Gregorian.Month, day?: number, hour?: number, minute?: number, second?: number, millisecond?: number, tick?: number);
21
- static from(d: Date | JsDateConvertible): TimeStamp;
22
- static now(): TimeStamp;
23
- toJsDate(): Date;
24
- }
25
- export default TimeStamp;
1
+ /*!
2
+ * @author electricessence / https://github.com/electricessence/
3
+ * @license MIT
4
+ */
5
+ import Gregorian from './Calendars/Gregorian';
6
+ import JsDateConvertible from './JsDateConvertible';
7
+ import TimeStampValue from './TimeStampValue';
8
+ /**
9
+ * An alternative to Date or DateTime. Is a model representing the exact date and time.
10
+ */
11
+ export declare class TimeStamp implements Required<TimeStampValue>, JsDateConvertible {
12
+ readonly year: number;
13
+ readonly month: Gregorian.Month;
14
+ readonly day: number;
15
+ readonly hour: number;
16
+ readonly minute: number;
17
+ readonly second: number;
18
+ readonly millisecond: number;
19
+ readonly tick: number;
20
+ constructor(year: number, month: Gregorian.Month, day?: number, hour?: number, minute?: number, second?: number, millisecond?: number, tick?: number);
21
+ static from(d: Date | JsDateConvertible): TimeStamp;
22
+ static now(): TimeStamp;
23
+ toJsDate(): Date;
24
+ }
25
+ export default TimeStamp;
package/dist/TimeStamp.js CHANGED
@@ -1,46 +1,46 @@
1
- "use strict";
2
- /*!
3
- * @author electricessence / https://github.com/electricessence/
4
- * @license MIT
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.TimeStamp = void 0;
8
- const tslib_1 = require("tslib");
9
- const type_1 = tslib_1.__importDefault(require("@tsdotnet/type"));
10
- /**
11
- * An alternative to Date or DateTime. Is a model representing the exact date and time.
12
- */
13
- class TimeStamp {
14
- constructor(year, month, day = 1, hour = 0, minute = 0, second = 0, millisecond = 0, tick = 0) {
15
- // Add validation or properly carry out of range values?
16
- this.year = year;
17
- this.month = month;
18
- this.day = day;
19
- this.hour = hour;
20
- this.minute = minute;
21
- this.second = second;
22
- this.millisecond = millisecond;
23
- this.tick = tick;
24
- Object.freeze(this);
25
- }
26
- static from(d) {
27
- if (!(d instanceof Date) && type_1.default.hasMember(d, 'toJsDate'))
28
- d = d.toJsDate();
29
- if (d instanceof Date) {
30
- return new TimeStamp(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());
31
- }
32
- else {
33
- throw Error('Invalid date type.');
34
- }
35
- }
36
- static now() {
37
- return TimeStamp.from(new Date());
38
- }
39
- toJsDate() {
40
- const _ = this;
41
- return new Date(_.year, _.month, _.day, _.hour, _.minute, _.second, _.millisecond + _.tick / 10000 /* millisecond */);
42
- }
43
- }
44
- exports.TimeStamp = TimeStamp;
45
- exports.default = TimeStamp;
1
+ "use strict";
2
+ /*!
3
+ * @author electricessence / https://github.com/electricessence/
4
+ * @license MIT
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.TimeStamp = void 0;
8
+ const tslib_1 = require("tslib");
9
+ const type_1 = (0, tslib_1.__importDefault)(require("@tsdotnet/type"));
10
+ /**
11
+ * An alternative to Date or DateTime. Is a model representing the exact date and time.
12
+ */
13
+ class TimeStamp {
14
+ constructor(year, month, day = 1, hour = 0, minute = 0, second = 0, millisecond = 0, tick = 0) {
15
+ // Add validation or properly carry out of range values?
16
+ this.year = year;
17
+ this.month = month;
18
+ this.day = day;
19
+ this.hour = hour;
20
+ this.minute = minute;
21
+ this.second = second;
22
+ this.millisecond = millisecond;
23
+ this.tick = tick;
24
+ Object.freeze(this);
25
+ }
26
+ static from(d) {
27
+ if (!(d instanceof Date) && type_1.default.hasMember(d, 'toJsDate'))
28
+ d = d.toJsDate();
29
+ if (d instanceof Date) {
30
+ return new TimeStamp(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());
31
+ }
32
+ else {
33
+ throw Error('Invalid date type.');
34
+ }
35
+ }
36
+ static now() {
37
+ return TimeStamp.from(new Date());
38
+ }
39
+ toJsDate() {
40
+ const _ = this;
41
+ return new Date(_.year, _.month, _.day, _.hour, _.minute, _.second, _.millisecond + _.tick / 10000 /* millisecond */);
42
+ }
43
+ }
44
+ exports.TimeStamp = TimeStamp;
45
+ exports.default = TimeStamp;
46
46
  //# sourceMappingURL=TimeStamp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TimeStamp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AE,EACf,CAAC,CAAC,QAAQ,EAAE,EACZ,CAAC,CAAC,OAAO,EAAE,EACX,CAAC,CAAC,QAAQ,EAAE,EACZ,CAAC,CAAC,UAAU,EAAE,EACd,CAAC,CAAC,UAAU,EAAE,EACd,CAAC,CAAC,eAAe,EAAE,CACnB,CAAC;SACF;aAED;YACC,MAAM,KAAK,CAAC,oBAAoB,CAAC,CAAC;SAClC;IACF,CAAC;IAED,MAAM,CAAC,GAAG;QAET,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,QAAQ;QAEP,MAAM,CAAC,GAAG,IAAI,CAAC;QACf,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,IAAI,0BAAsB,CAAC,CAAC;IACnH,CAAC;CACD;AApDD,8BAoDC;AAED,kBAAe,SAAS,CAAC"}
@@ -1,47 +1,47 @@
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 TimeQuantity from './TimeQuantity';
7
- export declare namespace TimeUnit {
8
- /**
9
- * A distinct unit of time measurement.
10
- */
11
- enum UnitType {
12
- Ticks = 0,
13
- Milliseconds = 1,
14
- Seconds = 2,
15
- Minutes = 3,
16
- Hours = 4,
17
- Days = 5
18
- }
19
- /**
20
- * Converts any TimeUnit value to it's respective millisecond quantity.
21
- * @param {number} value
22
- * @param {UnitType} units
23
- * @return {number} Number of milliseconds representing the specified units.
24
- */
25
- function toMilliseconds(value: number, units: UnitType): number;
26
- /**
27
- * Converts milliseconds to the specified TimeUnit quantity.
28
- * @param {number} ms
29
- * @param {UnitType} units
30
- * @return {number}
31
- */
32
- function fromMilliseconds(ms: number, units: UnitType): number;
33
- /**
34
- * Converts a TimeQuantity to the the TimeUnit requested..
35
- * @param {TimeQuantity} quantity
36
- * @param {UnitType} toUnits
37
- * @return {number}
38
- */
39
- function from(quantity: TimeQuantity, toUnits: UnitType): number;
40
- /**
41
- * Asserts if the time unit value is valid.
42
- * @param {UnitType} unit
43
- * @return {true}
44
- */
45
- function assertValid(unit: UnitType): true | never;
46
- }
47
- export default TimeUnit;
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 TimeQuantity from './TimeQuantity';
7
+ export declare namespace TimeUnit {
8
+ /**
9
+ * A distinct unit of time measurement.
10
+ */
11
+ enum UnitType {
12
+ Ticks = 0,
13
+ Milliseconds = 1,
14
+ Seconds = 2,
15
+ Minutes = 3,
16
+ Hours = 4,
17
+ Days = 5
18
+ }
19
+ /**
20
+ * Converts any TimeUnit value to it's respective millisecond quantity.
21
+ * @param {number} value
22
+ * @param {UnitType} units
23
+ * @return {number} Number of milliseconds representing the specified units.
24
+ */
25
+ function toMilliseconds(value: number, units: UnitType): number;
26
+ /**
27
+ * Converts milliseconds to the specified TimeUnit quantity.
28
+ * @param {number} ms
29
+ * @param {UnitType} units
30
+ * @return {number}
31
+ */
32
+ function fromMilliseconds(ms: number, units: UnitType): number;
33
+ /**
34
+ * Converts a TimeQuantity to the the TimeUnit requested..
35
+ * @param {TimeQuantity} quantity
36
+ * @param {UnitType} toUnits
37
+ * @return {number}
38
+ */
39
+ function from(quantity: TimeQuantity, toUnits: UnitType): number;
40
+ /**
41
+ * Asserts if the time unit value is valid.
42
+ * @param {UnitType} unit
43
+ * @return {true}
44
+ */
45
+ function assertValid(unit: UnitType): true | never;
46
+ }
47
+ export default TimeUnit;