@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
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 /* hours.per.day */;
|
|
35
|
+
case UnitType.Hours:
|
|
36
|
+
value *= 60 /* minutes.per.hour */;
|
|
37
|
+
case UnitType.Minutes:
|
|
38
|
+
value *= 60 /* seconds.per.minute */;
|
|
39
|
+
case UnitType.Seconds:
|
|
40
|
+
value *= 1000 /* milliseconds.per.second */;
|
|
41
|
+
case UnitType.Milliseconds:
|
|
42
|
+
return value;
|
|
43
|
+
case UnitType.Ticks:
|
|
44
|
+
return value / 10000 /* ticks.per.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 /* milliseconds.per.day */;
|
|
60
|
+
case UnitType.Hours:
|
|
61
|
+
return ms / 3600000 /* milliseconds.per.hour */;
|
|
62
|
+
case UnitType.Minutes:
|
|
63
|
+
return ms / 60000 /* milliseconds.per.minute */;
|
|
64
|
+
case UnitType.Seconds:
|
|
65
|
+
return ms / 1000 /* milliseconds.per.second */;
|
|
66
|
+
case UnitType.Milliseconds:
|
|
67
|
+
return ms;
|
|
68
|
+
case UnitType.Ticks:
|
|
69
|
+
return ms * 10000 /* ticks.per.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
|
package/dist/TimeUnit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeUnit.js","sourceRoot":"","sources":["../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AEtC,OAAO,IAAI,CAAC;IACb,CAAC;IANe,oBAAW,cAM1B,CAAA;AAEF,CAAC,EAnGgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAmGxB;AAED,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACjC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAExB,kBAAe,QAAQ,CAAC"}
|
package/dist/TimeUnitValue.d.ts
CHANGED
|
@@ -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
|
+
}
|
package/dist/TimeUnitValue.js
CHANGED
|
@@ -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 =
|
|
9
|
-
const TimeUnit_1 =
|
|
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 = 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
|
+
}
|
|
47
47
|
//# sourceMappingURL=TimeUnitValue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeUnitValue.js","sourceRoot":"","sources":["../src/TimeUnitValue.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH
|
|
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,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"}
|
package/dist/date-time.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
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 };
|
|
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,29 @@
|
|
|
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
|
|
10
|
-
exports.
|
|
11
|
-
const
|
|
12
|
-
exports.
|
|
13
|
-
const
|
|
14
|
-
exports.
|
|
15
|
-
const
|
|
16
|
-
exports.
|
|
17
|
-
const
|
|
18
|
-
exports.
|
|
19
|
-
const
|
|
20
|
-
exports.
|
|
21
|
-
const
|
|
22
|
-
exports.
|
|
23
|
-
const
|
|
24
|
-
exports.
|
|
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.DateTimeKind = exports.DateTime = exports.ClockTime = exports.Gregorian = void 0;
|
|
8
|
+
const tslib_1 = require("tslib");
|
|
9
|
+
const Gregorian_1 = tslib_1.__importDefault(require("./Calendars/Gregorian"));
|
|
10
|
+
exports.Gregorian = Gregorian_1.default;
|
|
11
|
+
const ClockTime_1 = tslib_1.__importDefault(require("./ClockTime"));
|
|
12
|
+
exports.ClockTime = ClockTime_1.default;
|
|
13
|
+
const DateTime_1 = tslib_1.__importDefault(require("./DateTime"));
|
|
14
|
+
exports.DateTime = DateTime_1.default;
|
|
15
|
+
const DateTimeKind_1 = tslib_1.__importDefault(require("./DateTimeKind"));
|
|
16
|
+
exports.DateTimeKind = DateTimeKind_1.default;
|
|
17
|
+
const howMany = tslib_1.__importStar(require("./howMany"));
|
|
18
|
+
exports.howMany = howMany;
|
|
19
|
+
const TimeQuantity_1 = tslib_1.__importDefault(require("./TimeQuantity"));
|
|
20
|
+
exports.TimeQuantity = TimeQuantity_1.default;
|
|
21
|
+
const TimeSpan_1 = tslib_1.__importDefault(require("./TimeSpan"));
|
|
22
|
+
exports.TimeSpan = TimeSpan_1.default;
|
|
23
|
+
const TimeStamp_1 = tslib_1.__importDefault(require("./TimeStamp"));
|
|
24
|
+
exports.TimeStamp = TimeStamp_1.default;
|
|
25
|
+
const TimeUnit_1 = tslib_1.__importDefault(require("./TimeUnit"));
|
|
26
|
+
exports.TimeUnit = TimeUnit_1.default;
|
|
27
|
+
const TimeUnitValue_1 = tslib_1.__importDefault(require("./TimeUnitValue"));
|
|
28
|
+
exports.TimeUnitValue = TimeUnitValue_1.default;
|
|
25
29
|
//# sourceMappingURL=date-time.js.map
|
package/dist/date-time.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-time.js","sourceRoot":"","sources":["../src/date-time.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;
|
|
1
|
+
{"version":3,"file":"date-time.js","sourceRoot":"","sources":["../src/date-time.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,8EAA8C;AAkB7C,oBAlBM,mBAAS,CAkBN;AAhBV,oEAAoC;AAkBnC,oBAlBM,mBAAS,CAkBN;AAhBV,kEAAkC;AAkBjC,mBAlBM,kBAAQ,CAkBN;AAjBT,0EAA0C;AAkBzC,uBAlBM,sBAAY,CAkBN;AAjBb,2DAAqC;AAkBpC,0BAAO;AAhBR,0EAA0C;AAkBzC,uBAlBM,sBAAY,CAkBN;AAjBb,kEAAkC;AAkBjC,mBAlBM,kBAAQ,CAkBN;AAjBT,oEAAoC;AAkBnC,oBAlBM,mBAAS,CAkBN;AAhBV,kEAAkC;AAkBjC,mBAlBM,kBAAQ,CAkBN;AAjBT,4EAA4C;AAkB3C,wBAlBM,uBAAa,CAkBN"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @author electricessence / https://github.com/electricessence/
|
|
3
|
+
* @license MIT
|
|
4
|
+
*/
|
|
5
|
+
export declare namespace hours {
|
|
6
|
+
const enum per {
|
|
7
|
+
day = 24
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export declare namespace minutes {
|
|
11
|
+
const enum per {
|
|
12
|
+
hour = 60,
|
|
13
|
+
day = 1440
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export declare namespace seconds {
|
|
17
|
+
const enum per {
|
|
18
|
+
minute = 60,
|
|
19
|
+
hour = 3600,
|
|
20
|
+
day = 86400
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export declare namespace milliseconds {
|
|
24
|
+
const enum per {
|
|
25
|
+
second = 1000,
|
|
26
|
+
minute = 60000,
|
|
27
|
+
hour = 3600000,
|
|
28
|
+
day = 86400000
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export declare namespace ticks {
|
|
32
|
+
const enum per {
|
|
33
|
+
millisecond = 10000,
|
|
34
|
+
second = 10000000,
|
|
35
|
+
minute = 600000000,
|
|
36
|
+
hour = 36000000000,
|
|
37
|
+
day = 864000000000
|
|
38
|
+
}
|
|
39
|
+
}
|
package/dist/howMany.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* @author electricessence / https://github.com/electricessence/
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ticks = exports.milliseconds = exports.seconds = exports.minutes = exports.hours = void 0;
|
|
8
|
+
var hours;
|
|
9
|
+
(function (hours) {
|
|
10
|
+
let per;
|
|
11
|
+
(function (per) {
|
|
12
|
+
per[per["day"] = 24] = "day";
|
|
13
|
+
})(per = hours.per || (hours.per = {}));
|
|
14
|
+
})(hours = exports.hours || (exports.hours = {}));
|
|
15
|
+
var minutes;
|
|
16
|
+
(function (minutes) {
|
|
17
|
+
let per;
|
|
18
|
+
(function (per) {
|
|
19
|
+
per[per["hour"] = 60] = "hour";
|
|
20
|
+
per[per["day"] = 1440] = "day";
|
|
21
|
+
})(per = minutes.per || (minutes.per = {}));
|
|
22
|
+
})(minutes = exports.minutes || (exports.minutes = {}));
|
|
23
|
+
var seconds;
|
|
24
|
+
(function (seconds) {
|
|
25
|
+
let per;
|
|
26
|
+
(function (per) {
|
|
27
|
+
per[per["minute"] = 60] = "minute";
|
|
28
|
+
per[per["hour"] = 3600] = "hour";
|
|
29
|
+
per[per["day"] = 86400] = "day";
|
|
30
|
+
})(per = seconds.per || (seconds.per = {}));
|
|
31
|
+
})(seconds = exports.seconds || (exports.seconds = {}));
|
|
32
|
+
var milliseconds;
|
|
33
|
+
(function (milliseconds) {
|
|
34
|
+
let per;
|
|
35
|
+
(function (per) {
|
|
36
|
+
per[per["second"] = 1000] = "second";
|
|
37
|
+
per[per["minute"] = 60000] = "minute";
|
|
38
|
+
per[per["hour"] = 3600000] = "hour";
|
|
39
|
+
per[per["day"] = 86400000] = "day";
|
|
40
|
+
})(per = milliseconds.per || (milliseconds.per = {}));
|
|
41
|
+
})(milliseconds = exports.milliseconds || (exports.milliseconds = {}));
|
|
42
|
+
var ticks;
|
|
43
|
+
(function (ticks) {
|
|
44
|
+
let per;
|
|
45
|
+
(function (per) {
|
|
46
|
+
per[per["millisecond"] = 10000] = "millisecond";
|
|
47
|
+
per[per["second"] = 10000000] = "second";
|
|
48
|
+
per[per["minute"] = 600000000] = "minute";
|
|
49
|
+
per[per["hour"] = 36000000000] = "hour";
|
|
50
|
+
per[per["day"] = 864000000000] = "day";
|
|
51
|
+
})(per = ticks.per || (ticks.per = {}));
|
|
52
|
+
})(ticks = exports.ticks || (exports.ticks = {}));
|
|
53
|
+
//# sourceMappingURL=howMany.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"howMany.js","sourceRoot":"","sources":["../src/howMany.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,IAAiB,KAAK,CAMrB;AAND,WAAiB,KAAK;IAErB,IAAkB,GAGjB;IAHD,WAAkB,GAAG;QAEpB,4BAAQ,CAAA;IACT,CAAC,EAHiB,GAAG,GAAH,SAAG,KAAH,SAAG,QAGpB;AACF,CAAC,EANgB,KAAK,GAAL,aAAK,KAAL,aAA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