@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/TimeUnit.js CHANGED
@@ -1,100 +1,100 @@
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.TimeUnit = void 0;
9
- /* eslint-disable no-fallthrough */
10
- var TimeUnit;
11
- (function (TimeUnit) {
12
- /**
13
- * A distinct unit of time measurement.
14
- */
15
- let UnitType;
16
- (function (UnitType) {
17
- UnitType[UnitType["Ticks"] = 0] = "Ticks";
18
- UnitType[UnitType["Milliseconds"] = 1] = "Milliseconds";
19
- UnitType[UnitType["Seconds"] = 2] = "Seconds";
20
- UnitType[UnitType["Minutes"] = 3] = "Minutes";
21
- UnitType[UnitType["Hours"] = 4] = "Hours";
22
- UnitType[UnitType["Days"] = 5] = "Days";
23
- })(UnitType = TimeUnit.UnitType || (TimeUnit.UnitType = {})); // Earth Days
24
- /**
25
- * Converts any TimeUnit value to it's respective millisecond quantity.
26
- * @param {number} value
27
- * @param {UnitType} units
28
- * @return {number} Number of milliseconds representing the specified units.
29
- */
30
- function toMilliseconds(value, units) {
31
- // noinspection FallThroughInSwitchStatementJS
32
- switch (units) {
33
- case UnitType.Days:
34
- value *= 24 /* day */;
35
- case UnitType.Hours:
36
- value *= 60 /* hour */;
37
- case UnitType.Minutes:
38
- value *= 60 /* minute */;
39
- case UnitType.Seconds:
40
- value *= 1000 /* second */;
41
- case UnitType.Milliseconds:
42
- return value;
43
- case UnitType.Ticks:
44
- return value / 10000 /* millisecond */;
45
- default:
46
- throw new Error('Invalid TimeUnit.');
47
- }
48
- }
49
- TimeUnit.toMilliseconds = toMilliseconds;
50
- /**
51
- * Converts milliseconds to the specified TimeUnit quantity.
52
- * @param {number} ms
53
- * @param {UnitType} units
54
- * @return {number}
55
- */
56
- function fromMilliseconds(ms, units) {
57
- switch (units) {
58
- case UnitType.Days:
59
- return ms / 86400000 /* day */;
60
- case UnitType.Hours:
61
- return ms / 3600000 /* hour */;
62
- case UnitType.Minutes:
63
- return ms / 60000 /* minute */;
64
- case UnitType.Seconds:
65
- return ms / 1000 /* second */;
66
- case UnitType.Milliseconds:
67
- return ms;
68
- case UnitType.Ticks:
69
- return ms * 10000 /* millisecond */;
70
- default:
71
- throw new Error('Invalid TimeUnit.');
72
- }
73
- }
74
- TimeUnit.fromMilliseconds = fromMilliseconds;
75
- /**
76
- * Converts a TimeQuantity to the the TimeUnit requested..
77
- * @param {TimeQuantity} quantity
78
- * @param {UnitType} toUnits
79
- * @return {number}
80
- */
81
- function from(quantity, toUnits) {
82
- return quantity && fromMilliseconds(quantity.getTotalMilliseconds(), toUnits);
83
- }
84
- TimeUnit.from = from;
85
- /**
86
- * Asserts if the time unit value is valid.
87
- * @param {UnitType} unit
88
- * @return {true}
89
- */
90
- function assertValid(unit) {
91
- if (isNaN(unit) || unit > UnitType.Days || unit < UnitType.Ticks || Math.floor(unit) !== unit)
92
- throw new Error('Invalid TimeUnit.');
93
- return true;
94
- }
95
- TimeUnit.assertValid = assertValid;
96
- })(TimeUnit = exports.TimeUnit || (exports.TimeUnit = {}));
97
- Object.freeze(TimeUnit.UnitType);
98
- Object.freeze(TimeUnit);
99
- exports.default = TimeUnit;
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.TimeUnit = void 0;
9
+ /* eslint-disable no-fallthrough */
10
+ var TimeUnit;
11
+ (function (TimeUnit) {
12
+ /**
13
+ * A distinct unit of time measurement.
14
+ */
15
+ let UnitType;
16
+ (function (UnitType) {
17
+ UnitType[UnitType["Ticks"] = 0] = "Ticks";
18
+ UnitType[UnitType["Milliseconds"] = 1] = "Milliseconds";
19
+ UnitType[UnitType["Seconds"] = 2] = "Seconds";
20
+ UnitType[UnitType["Minutes"] = 3] = "Minutes";
21
+ UnitType[UnitType["Hours"] = 4] = "Hours";
22
+ UnitType[UnitType["Days"] = 5] = "Days";
23
+ })(UnitType = TimeUnit.UnitType || (TimeUnit.UnitType = {})); // Earth Days
24
+ /**
25
+ * Converts any TimeUnit value to it's respective millisecond quantity.
26
+ * @param {number} value
27
+ * @param {UnitType} units
28
+ * @return {number} Number of milliseconds representing the specified units.
29
+ */
30
+ function toMilliseconds(value, units) {
31
+ // noinspection FallThroughInSwitchStatementJS
32
+ switch (units) {
33
+ case UnitType.Days:
34
+ value *= 24 /* day */;
35
+ case UnitType.Hours:
36
+ value *= 60 /* hour */;
37
+ case UnitType.Minutes:
38
+ value *= 60 /* minute */;
39
+ case UnitType.Seconds:
40
+ value *= 1000 /* second */;
41
+ case UnitType.Milliseconds:
42
+ return value;
43
+ case UnitType.Ticks:
44
+ return value / 10000 /* millisecond */;
45
+ default:
46
+ throw new Error('Invalid TimeUnit.');
47
+ }
48
+ }
49
+ TimeUnit.toMilliseconds = toMilliseconds;
50
+ /**
51
+ * Converts milliseconds to the specified TimeUnit quantity.
52
+ * @param {number} ms
53
+ * @param {UnitType} units
54
+ * @return {number}
55
+ */
56
+ function fromMilliseconds(ms, units) {
57
+ switch (units) {
58
+ case UnitType.Days:
59
+ return ms / 86400000 /* day */;
60
+ case UnitType.Hours:
61
+ return ms / 3600000 /* hour */;
62
+ case UnitType.Minutes:
63
+ return ms / 60000 /* minute */;
64
+ case UnitType.Seconds:
65
+ return ms / 1000 /* second */;
66
+ case UnitType.Milliseconds:
67
+ return ms;
68
+ case UnitType.Ticks:
69
+ return ms * 10000 /* millisecond */;
70
+ default:
71
+ throw new Error('Invalid TimeUnit.');
72
+ }
73
+ }
74
+ TimeUnit.fromMilliseconds = fromMilliseconds;
75
+ /**
76
+ * Converts a TimeQuantity to the the TimeUnit requested..
77
+ * @param {TimeQuantity} quantity
78
+ * @param {UnitType} toUnits
79
+ * @return {number}
80
+ */
81
+ function from(quantity, toUnits) {
82
+ return quantity && fromMilliseconds(quantity.getTotalMilliseconds(), toUnits);
83
+ }
84
+ TimeUnit.from = from;
85
+ /**
86
+ * Asserts if the time unit value is valid.
87
+ * @param {UnitType} unit
88
+ * @return {true}
89
+ */
90
+ function assertValid(unit) {
91
+ if (isNaN(unit) || unit > UnitType.Days || unit < UnitType.Ticks || Math.floor(unit) !== unit)
92
+ throw new Error('Invalid TimeUnit.');
93
+ return true;
94
+ }
95
+ TimeUnit.assertValid = assertValid;
96
+ })(TimeUnit = exports.TimeUnit || (exports.TimeUnit = {}));
97
+ Object.freeze(TimeUnit.UnitType);
98
+ Object.freeze(TimeUnit);
99
+ exports.default = TimeUnit;
100
100
  //# sourceMappingURL=TimeUnit.js.map
@@ -1,19 +1,19 @@
1
- /*!
2
- * @author electricessence / https://github.com/electricessence/
3
- * @license MIT
4
- */
5
- import TimeQuantity from './TimeQuantity';
6
- import TimeUnit from './TimeUnit';
7
- /**
8
- * TimeUnitValue allows for passing around a reference to a mutable measure of time coerced by its unit type.
9
- */
10
- export default class TimeUnitValue extends TimeQuantity {
11
- private _units;
12
- constructor(value: number | TimeQuantity, _units: TimeUnit.UnitType);
13
- get value(): number;
14
- set value(v: number);
15
- get units(): TimeUnit.UnitType;
16
- static from(value: number | TimeQuantity, units?: TimeUnit.UnitType): TimeUnitValue;
17
- getTotalMilliseconds(): number;
18
- to(units?: TimeUnit.UnitType): TimeUnitValue;
19
- }
1
+ /*!
2
+ * @author electricessence / https://github.com/electricessence/
3
+ * @license MIT
4
+ */
5
+ import TimeQuantity from './TimeQuantity';
6
+ import TimeUnit from './TimeUnit';
7
+ /**
8
+ * TimeUnitValue allows for passing around a reference to a mutable measure of time coerced by its unit type.
9
+ */
10
+ export default class TimeUnitValue extends TimeQuantity {
11
+ private _units;
12
+ constructor(value: number | TimeQuantity, _units: TimeUnit.UnitType);
13
+ get value(): number;
14
+ set value(v: number);
15
+ get units(): TimeUnit.UnitType;
16
+ static from(value: number | TimeQuantity, units?: TimeUnit.UnitType): TimeUnitValue;
17
+ getTotalMilliseconds(): number;
18
+ to(units?: TimeUnit.UnitType): TimeUnitValue;
19
+ }
@@ -1,47 +1,47 @@
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 TimeQuantity_1 = tslib_1.__importDefault(require("./TimeQuantity"));
9
- const TimeUnit_1 = tslib_1.__importDefault(require("./TimeUnit"));
10
- /**
11
- * TimeUnitValue allows for passing around a reference to a mutable measure of time coerced by its unit type.
12
- */
13
- class TimeUnitValue extends TimeQuantity_1.default {
14
- constructor(value, _units) {
15
- super(typeof value == 'number'
16
- ? value
17
- : getUnitQuantityFrom(value, _units));
18
- this._units = _units;
19
- TimeUnit_1.default.assertValid(_units);
20
- }
21
- get value() {
22
- return this._quantity;
23
- }
24
- set value(v) {
25
- this._quantity = v;
26
- if (!this._total.tryReset())
27
- throw new Error('Unable to update underlying value.');
28
- }
29
- // To avoid confusion, the unit type can only be set once at construction.
30
- get units() {
31
- return this._units;
32
- }
33
- static from(value, units = TimeUnit_1.default.UnitType.Milliseconds) {
34
- return new TimeUnitValue(value, units);
35
- }
36
- getTotalMilliseconds() {
37
- return TimeUnit_1.default.toMilliseconds(this._quantity, this._units);
38
- }
39
- to(units = this.units) {
40
- return TimeUnitValue.from(this, units);
41
- }
42
- }
43
- exports.default = TimeUnitValue;
44
- function getUnitQuantityFrom(q, units) {
45
- return TimeUnit_1.default.fromMilliseconds(q.getTotalMilliseconds(), units);
46
- }
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 TimeQuantity_1 = (0, tslib_1.__importDefault)(require("./TimeQuantity"));
9
+ const TimeUnit_1 = (0, tslib_1.__importDefault)(require("./TimeUnit"));
10
+ /**
11
+ * TimeUnitValue allows for passing around a reference to a mutable measure of time coerced by its unit type.
12
+ */
13
+ class TimeUnitValue extends TimeQuantity_1.default {
14
+ constructor(value, _units) {
15
+ super(typeof value == 'number'
16
+ ? value
17
+ : getUnitQuantityFrom(value, _units));
18
+ this._units = _units;
19
+ TimeUnit_1.default.assertValid(_units);
20
+ }
21
+ get value() {
22
+ return this._quantity;
23
+ }
24
+ set value(v) {
25
+ this._quantity = v;
26
+ if (!this._total.tryReset())
27
+ throw new Error('Unable to update underlying value.');
28
+ }
29
+ // To avoid confusion, the unit type can only be set once at construction.
30
+ get units() {
31
+ return this._units;
32
+ }
33
+ static from(value, units = TimeUnit_1.default.UnitType.Milliseconds) {
34
+ return new TimeUnitValue(value, units);
35
+ }
36
+ getTotalMilliseconds() {
37
+ return TimeUnit_1.default.toMilliseconds(this._quantity, this._units);
38
+ }
39
+ to(units = this.units) {
40
+ return TimeUnitValue.from(this, units);
41
+ }
42
+ }
43
+ exports.default = TimeUnitValue;
44
+ function getUnitQuantityFrom(q, units) {
45
+ return TimeUnit_1.default.fromMilliseconds(q.getTotalMilliseconds(), units);
46
+ }
47
47
  //# sourceMappingURL=TimeUnitValue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TimeUnitValue.js","sourceRoot":"","sources":["../src/TimeUnitValue.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,0EAA0C;AAC1C,kEAAkC;AAElC;;GAEG;AACH,MAAqB,aACpB,SAAQ,sBAAY;IAEpB,YAAa,KAA4B,EAAU,MAAyB;QAE3E,KAAK,CAAC,OAAO,KAAK,IAAE,QAAQ;YAC3B,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;QAJW,WAAM,GAAN,MAAM,CAAmB;QAK3E,k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;YACP,CAAC,CAAC,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;QAJW,WAAM,GAAN,MAAM,CAAmB;QAK3E,kBAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI,KAAK;QAER,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAED,IAAI,KAAK,CAAE,CAAS;QAEnB,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QACnB,IAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACnF,CAAC;IAED,0EAA0E;IAC1E,IAAI,KAAK;QAER,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,MAAM,CAAC,IAAI,CACV,KAA4B,EAC5B,QAA2B,kBAAQ,CAAC,QAAQ,CAAC,YAAY;QAEzD,OAAO,IAAI,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,oBAAoB;QAEnB,OAAO,kBAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;IAED,EAAE,CAAE,QAA2B,IAAI,CAAC,KAAK;QAExC,OAAO,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;CAED;AA7CD,gCA6CC;AAED,SAAS,mBAAmB,CAAE,CAAe,EAAE,KAAwB;IAEtE,OAAO,kBAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,oBAAoB,EAAE,EAAE,KAAK,CAAC,CAAC;AACnE,CAAC"}
@@ -1,14 +1,20 @@
1
- /*!
2
- * @author electricessence / https://github.com/electricessence/
3
- * @license MIT
4
- */
5
- import Gregorian from './Calendars/Gregorian';
6
- import ClockTime from './ClockTime';
7
- import DateTime from './DateTime';
8
- import * as howMany from './howMany';
9
- import TimeQuantity from './TimeQuantity';
10
- import TimeSpan from './TimeSpan';
11
- import TimeStamp from './TimeStamp';
12
- import TimeUnit from './TimeUnit';
13
- import TimeUnitValue from './TimeUnitValue';
14
- export { Gregorian, ClockTime, DateTime, howMany, TimeQuantity, TimeSpan, TimeStamp, TimeUnit, TimeUnitValue };
1
+ /*!
2
+ * @author electricessence / https://github.com/electricessence/
3
+ * @license MIT
4
+ */
5
+ import Gregorian from './Calendars/Gregorian';
6
+ import CalendarDate from './CalendarDate';
7
+ import ClockTime from './ClockTime';
8
+ import ClockTimeValue from './ClockTimeValue';
9
+ import DateTime from './DateTime';
10
+ import DateTimeKind from './DateTimeKind';
11
+ import * as howMany from './howMany';
12
+ import TimeMeasurement from './TimeMeasurement';
13
+ import TimeQuantity from './TimeQuantity';
14
+ import TimeSpan from './TimeSpan';
15
+ import TimeStamp from './TimeStamp';
16
+ import TimeStampValue from './TimeStampValue';
17
+ import TimeUnit from './TimeUnit';
18
+ import TimeUnitValue from './TimeUnitValue';
19
+ import JsDateConvertible from './JsDateConvertible';
20
+ export { Gregorian, CalendarDate, ClockTime, ClockTimeValue, DateTime, DateTimeKind, howMany, TimeMeasurement, TimeQuantity, TimeSpan, TimeStamp, TimeStampValue, TimeUnit, TimeUnitValue, JsDateConvertible };
package/dist/date-time.js CHANGED
@@ -1,25 +1,25 @@
1
- "use strict";
2
- /*!
3
- * @author electricessence / https://github.com/electricessence/
4
- * @license MIT
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.TimeUnitValue = exports.TimeUnit = exports.TimeStamp = exports.TimeSpan = exports.TimeQuantity = exports.howMany = exports.DateTime = exports.ClockTime = void 0;
8
- const tslib_1 = require("tslib");
9
- const ClockTime_1 = tslib_1.__importDefault(require("./ClockTime"));
10
- exports.ClockTime = ClockTime_1.default;
11
- const DateTime_1 = tslib_1.__importDefault(require("./DateTime"));
12
- exports.DateTime = DateTime_1.default;
13
- const howMany = tslib_1.__importStar(require("./howMany"));
14
- exports.howMany = howMany;
15
- const TimeQuantity_1 = tslib_1.__importDefault(require("./TimeQuantity"));
16
- exports.TimeQuantity = TimeQuantity_1.default;
17
- const TimeSpan_1 = tslib_1.__importDefault(require("./TimeSpan"));
18
- exports.TimeSpan = TimeSpan_1.default;
19
- const TimeStamp_1 = tslib_1.__importDefault(require("./TimeStamp"));
20
- exports.TimeStamp = TimeStamp_1.default;
21
- const TimeUnit_1 = tslib_1.__importDefault(require("./TimeUnit"));
22
- exports.TimeUnit = TimeUnit_1.default;
23
- const TimeUnitValue_1 = tslib_1.__importDefault(require("./TimeUnitValue"));
24
- exports.TimeUnitValue = TimeUnitValue_1.default;
1
+ "use strict";
2
+ /*!
3
+ * @author electricessence / https://github.com/electricessence/
4
+ * @license MIT
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.TimeUnitValue = exports.TimeUnit = exports.TimeStamp = exports.TimeSpan = exports.TimeQuantity = exports.howMany = exports.DateTime = exports.ClockTime = void 0;
8
+ const tslib_1 = require("tslib");
9
+ const ClockTime_1 = (0, tslib_1.__importDefault)(require("./ClockTime"));
10
+ exports.ClockTime = ClockTime_1.default;
11
+ const DateTime_1 = (0, tslib_1.__importDefault)(require("./DateTime"));
12
+ exports.DateTime = DateTime_1.default;
13
+ const howMany = (0, tslib_1.__importStar)(require("./howMany"));
14
+ exports.howMany = howMany;
15
+ const TimeQuantity_1 = (0, tslib_1.__importDefault)(require("./TimeQuantity"));
16
+ exports.TimeQuantity = TimeQuantity_1.default;
17
+ const TimeSpan_1 = (0, tslib_1.__importDefault)(require("./TimeSpan"));
18
+ exports.TimeSpan = TimeSpan_1.default;
19
+ const TimeStamp_1 = (0, tslib_1.__importDefault)(require("./TimeStamp"));
20
+ exports.TimeStamp = TimeStamp_1.default;
21
+ const TimeUnit_1 = (0, tslib_1.__importDefault)(require("./TimeUnit"));
22
+ exports.TimeUnit = TimeUnit_1.default;
23
+ const TimeUnitValue_1 = (0, tslib_1.__importDefault)(require("./TimeUnitValue"));
24
+ exports.TimeUnitValue = TimeUnitValue_1.default;
25
25
  //# sourceMappingURL=date-time.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"date-time.js","sourceRoot":"","sources":["../src/date-time.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAGH,oEAAoC;AAWnC,oBAXM,mBAAS,CAWN;AAVV,kEAAkC;AAWjC,mBAXM,kBAAQ,CAWN;AAVT,2DAAqC;AAWpC,0BAAO;AAVR,0EAA0C;AAWzC,uBAXM,sBAAY,CAWN;AAVb,kEAAkC;AAWjC,mBAXM,kBAAQ,CAWN;AAVT,oEAAoC;AAWnC,oBAXM,mBAAS,CAWN;AAVV,kEAAkC;AAWjC,mBAXM,kBAAQ,CAWN;AAVT,4EAA4C;AAW3C,wBAXM,uBAAa,CAWN"}
1
+ {"version":3,"file":"date-time.js","sourceRoot":"","sources":["../src/date-time.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAIH,yEAAoC;AAkBnC,oBAlBM,mBAAS,CAkBN;AAhBV,uEAAkC;AAkBjC,mBAlBM,kBAAQ,CAkBN;AAhBT,gEAAqC;AAkBpC,0BAAO;AAhBR,+EAA0C;AAkBzC,uBAlBM,sBAAY,CAkBN;AAjBb,uEAAkC;AAkBjC,mBAlBM,kBAAQ,CAkBN;AAjBT,yEAAoC;AAkBnC,oBAlBM,mBAAS,CAkBN;AAhBV,uEAAkC;AAkBjC,mBAlBM,kBAAQ,CAkBN;AAjBT,iFAA4C;AAkB3C,wBAlBM,uBAAa,CAkBN"}
@@ -1,63 +1,63 @@
1
- /*!
2
- * @author electricessence / https://github.com/electricessence/
3
- * @license MIT
4
- */
5
- import TimeQuantity from './TimeQuantity';
6
- export class ClockTime extends TimeQuantity {
7
- constructor(...args) {
8
- super(args.length > 1
9
- ? ClockTime.millisecondsFromTime(args[0] || 0, args[1] || 0, args.length > 2 && args[2] || 0, args.length > 3 && args[3] || 0)
10
- : (args.length > 0 && args[0] || 0));
11
- const ms = Math.abs(this.getTotalMilliseconds());
12
- let msi = Math.floor(ms);
13
- this.tick = (ms - msi) * 10000 /* millisecond */;
14
- this.day = (msi / 86400000 /* day */) | 0;
15
- msi -= this.day * 86400000 /* day */;
16
- this.hour = (msi / 3600000 /* hour */) | 0;
17
- msi -= this.hour * 3600000 /* hour */;
18
- this.minute = (msi / 60000 /* minute */) | 0;
19
- msi -= this.minute * 60000 /* minute */;
20
- this.second = (msi / 1000 /* second */) | 0;
21
- msi -= this.second * 1000 /* second */;
22
- this.millisecond = msi;
23
- Object.freeze(this);
24
- }
25
- // Static version for relative consistency. Constructor does allow this format.
26
- static from(hours, minutes, seconds = 0, milliseconds = 0) {
27
- return new ClockTime(hours, minutes, seconds, milliseconds);
28
- }
29
- static millisecondsFromTime(hours, minutes, seconds = 0, milliseconds = 0) {
30
- let value = hours;
31
- value *= 60 /* hour */;
32
- value += minutes;
33
- value *= 60 /* minute */;
34
- value += seconds;
35
- value *= 1000 /* second */;
36
- value += milliseconds;
37
- return value;
38
- }
39
- toString( /*format?:string, formatProvider?:IFormatProvider*/) {
40
- /* INSERT CUSTOM FORMATTING CODE HERE */
41
- const _ = this;
42
- const a = [];
43
- if (_.day)
44
- a.push(pluralize(_.day, 'day'));
45
- if (_.hour)
46
- a.push(pluralize(_.hour, 'hour'));
47
- if (_.minute)
48
- a.push(pluralize(_.minute, 'minute'));
49
- if (_.second)
50
- a.push(pluralize(_.second, 'second'));
51
- if (a.length > 1)
52
- a.splice(a.length - 1, 0, 'and');
53
- return a.join(', ').replace(', and, ', ' and ');
54
- }
55
- }
56
- // Temporary until the full TimeSpanFormat is available.
57
- function pluralize(value, label) {
58
- if (Math.abs(value) !== 1)
59
- label += 's';
60
- return label;
61
- }
62
- export default ClockTime;
1
+ /*!
2
+ * @author electricessence / https://github.com/electricessence/
3
+ * @license MIT
4
+ */
5
+ import TimeQuantity from './TimeQuantity';
6
+ export class ClockTime extends TimeQuantity {
7
+ constructor(...args) {
8
+ super(args.length > 1
9
+ ? ClockTime.millisecondsFromTime(args[0] || 0, args[1] || 0, args.length > 2 && args[2] || 0, args.length > 3 && args[3] || 0)
10
+ : (args.length > 0 && args[0] || 0));
11
+ const ms = Math.abs(this.getTotalMilliseconds());
12
+ let msi = Math.floor(ms);
13
+ this.tick = (ms - msi) * 10000 /* millisecond */;
14
+ this.day = (msi / 86400000 /* day */) | 0;
15
+ msi -= this.day * 86400000 /* day */;
16
+ this.hour = (msi / 3600000 /* hour */) | 0;
17
+ msi -= this.hour * 3600000 /* hour */;
18
+ this.minute = (msi / 60000 /* minute */) | 0;
19
+ msi -= this.minute * 60000 /* minute */;
20
+ this.second = (msi / 1000 /* second */) | 0;
21
+ msi -= this.second * 1000 /* second */;
22
+ this.millisecond = msi;
23
+ Object.freeze(this);
24
+ }
25
+ // Static version for relative consistency. Constructor does allow this format.
26
+ static from(hours, minutes, seconds = 0, milliseconds = 0) {
27
+ return new ClockTime(hours, minutes, seconds, milliseconds);
28
+ }
29
+ static millisecondsFromTime(hours, minutes, seconds = 0, milliseconds = 0) {
30
+ let value = hours;
31
+ value *= 60 /* hour */;
32
+ value += minutes;
33
+ value *= 60 /* minute */;
34
+ value += seconds;
35
+ value *= 1000 /* second */;
36
+ value += milliseconds;
37
+ return value;
38
+ }
39
+ toString( /*format?:string, formatProvider?:IFormatProvider*/) {
40
+ /* INSERT CUSTOM FORMATTING CODE HERE */
41
+ const _ = this;
42
+ const a = [];
43
+ if (_.day)
44
+ a.push(pluralize(_.day, 'day'));
45
+ if (_.hour)
46
+ a.push(pluralize(_.hour, 'hour'));
47
+ if (_.minute)
48
+ a.push(pluralize(_.minute, 'minute'));
49
+ if (_.second)
50
+ a.push(pluralize(_.second, 'second'));
51
+ if (a.length > 1)
52
+ a.splice(a.length - 1, 0, 'and');
53
+ return a.join(', ').replace(', and, ', ' and ');
54
+ }
55
+ }
56
+ // Temporary until the full TimeSpanFormat is available.
57
+ function pluralize(value, label) {
58
+ if (Math.abs(value) !== 1)
59
+ label += 's';
60
+ return label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