@utiliread/primitives 1.0.0-34 → 1.0.0-35

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 (35) hide show
  1. package/dist/cjs/precision-number.js +6 -0
  2. package/dist/cjs/precision-number.js.map +1 -1
  3. package/dist/esm/precision-number.d.ts +2 -0
  4. package/dist/esm/precision-number.js +6 -0
  5. package/dist/esm/precision-number.js.map +1 -1
  6. package/package.json +36 -36
  7. package/src/aggregate-id.ts +9 -9
  8. package/src/consumption-type-id.ts +8 -8
  9. package/src/index.ts +30 -30
  10. package/src/measure-id.ts +14 -14
  11. package/src/number-formatter.spec.ts +93 -93
  12. package/src/number-formatter.ts +78 -78
  13. package/src/precision-number.ts +26 -18
  14. package/src/register-convention.spec.ts +42 -42
  15. package/src/register-convention.ts +61 -61
  16. package/src/register-definition.ts +17 -17
  17. package/src/register-id.ts +197 -197
  18. package/src/register-library.spec.ts +41 -41
  19. package/src/register-library.ts +57 -57
  20. package/src/register-pack.ts +5 -5
  21. package/src/register-utils.ts +6 -6
  22. package/src/step.spec.ts +29 -29
  23. package/src/step.ts +37 -37
  24. package/src/time-or-rule.ts +17 -17
  25. package/src/unit-id.ts +100 -100
  26. package/dist/cjs/register-converter.js +0 -31
  27. package/dist/cjs/register-converter.js.map +0 -1
  28. package/dist/cjs/register-converter.spec.js +0 -29
  29. package/dist/cjs/register-converter.spec.js.map +0 -1
  30. package/dist/esm/register-converter.d.ts +0 -9
  31. package/dist/esm/register-converter.js +0 -28
  32. package/dist/esm/register-converter.js.map +0 -1
  33. package/dist/esm/register-converter.spec.d.ts +0 -1
  34. package/dist/esm/register-converter.spec.js +0 -27
  35. package/dist/esm/register-converter.spec.js.map +0 -1
@@ -1,197 +1,197 @@
1
- export type RegisterId =
2
- "none" |
3
-
4
- "heatEnergy" |
5
- "diffHeatEnergy" |
6
-
7
- "heatEnergyVolumeInInlet" |
8
- "diffHeatEnergyVolumeInInlet" |
9
-
10
- "heatEnergyVolumeInOutlet" |
11
- "diffHeatEnergyVolumeInOutlet" |
12
-
13
- "coolingEnergy" |
14
- "diffCoolingEnergy" |
15
-
16
- "coolingEnergyVolumeInInlet" |
17
- "diffCoolingEnergyVolumeInInlet" |
18
-
19
- "coolingEnergyVolumeInOutlet" |
20
- "diffCoolingEnergyVolumeInOutlet" |
21
-
22
- "electricalEnergy" |
23
- "diffElectricalEnergy" |
24
-
25
- "reactiveEnergy" |
26
- "diffReactiveEnergy" |
27
-
28
- "volume" |
29
- "diffVolume" |
30
-
31
- "inletVolume" |
32
- "diffInletVolume" |
33
-
34
- "outletVolume" |
35
- "diffOutletVolume" |
36
-
37
- "pulseInputAVolume" |
38
- "diffPulseInputAVolume" |
39
-
40
- "pulseInputBVolume" |
41
- "diffPulseInputBVolume" |
42
-
43
- "mass" |
44
- "diffMass" |
45
-
46
- "inletMass" |
47
- "diffInletMass" |
48
-
49
- "outletMass" |
50
- "diffOutletMass" |
51
-
52
- "power" |
53
- "maxPower" |
54
- "minPower" |
55
- "avgPower" |
56
-
57
- "inletPower" |
58
- "maxInletPower" |
59
- "minInletPower" |
60
- "avgInletPower" |
61
-
62
- "outletPower" |
63
- "maxOutletPower" |
64
- "minOutletPower" |
65
- "avgOutletPower" |
66
-
67
- "volumeFlow" |
68
- "maxVolumeFlow" |
69
- "minVolumeFlow" |
70
- "avgVolumeFlow" |
71
-
72
- "inletVolumeFlow" |
73
- "maxInletVolumeFlow" |
74
- "minInletVolumeFlow" |
75
- "avgInletVolumeFlow" |
76
-
77
- "outletVolumeFlow" |
78
- "maxOutletVolumeFlow" |
79
- "minOutletVolumeFlow" |
80
- "avgOutletVolumeFlow" |
81
-
82
- "massFlow" |
83
- "maxMassFlow" |
84
- "minMassFlow" |
85
- "avgMassFlow" |
86
-
87
- "inletMassFlow" |
88
- "maxInletMassFlow" |
89
- "minInletMassFlow" |
90
- "avgInletMassFlow" |
91
-
92
- "outletMassFlow" |
93
- "maxOutletMassFlow" |
94
- "minOutletMassFlow" |
95
- "avgOutletMassFlow" |
96
-
97
- "flowTemperature" |
98
- "maxFlowTemperature" |
99
- "minFlowTemperature" |
100
- "avgFlowTemperature" |
101
-
102
- "inletFlowTemperature" |
103
- "maxInletFlowTemperature" |
104
- "minInletFlowTemperature" |
105
- "avgInletFlowTemperature" |
106
-
107
- "outletFlowTemperature" |
108
- "maxOutletFlowTemperature" |
109
- "minOutletFlowTemperature" |
110
- "avgOutletFlowTemperature" |
111
-
112
- "inletMinusOutletFlowTemperatureDifference" |
113
- "maxInletMinusOutletFlowTemperatureDifference" |
114
- "minInletMinusOutletFlowTemperatureDifference" |
115
- "avgInletMinusOutletFlowTemperatureDifference" |
116
-
117
- "outletMinusInletFlowTemperatureDifference" |
118
- "maxOutletMinusInletFlowTemperatureDifference" |
119
- "minOutletMinusInletFlowTemperatureDifference" |
120
- "avgOutletMinusInletFlowTemperatureDifference" |
121
-
122
- "ambientTemperature" |
123
- "maxAmbientTemperature" |
124
- "minAmbientTemperature" |
125
- "avgAmbientTemperature" |
126
-
127
- "radiatorTemperature" |
128
- "maxRadiatorTemperature" |
129
- "minRadiatorTemperature" |
130
- "avgRadiatorTemperature" |
131
-
132
- "relativeHumidity" |
133
-
134
- "kamstrupE8Inlet" |
135
- "diffKamstrupE8Inlet" |
136
- "kamstrupE9Outlet" |
137
- "diffKamstrupE9Outlet" |
138
-
139
- "operatingTime" |
140
- "diffOperatingTime" |
141
-
142
- "remainingBatteryTime" |
143
- "diffRemainingBatteryTime" |
144
-
145
- "deviceDate" |
146
- "deviceTime" |
147
- "deviceDateTime" |
148
-
149
- "timeSinceLastExactOverhearingArrived" |
150
- "timeAtLastExactOverhearingArrived" |
151
-
152
- "timeSinceLastPossibleCandidateOverhearingArrived" |
153
- "timeAtLastPossibleCandidateOverhearingArrived" |
154
-
155
- "timeSinceLastSampled" |
156
- "timeAtLastSampled" |
157
-
158
- "timeSinceLastInstallationMounted" |
159
- "timeAtLastInstallationMounted" |
160
-
161
- "basetime" |
162
- "instantTime" |
163
- "periodStartTime" |
164
- "periodEndTime" |
165
- "instantOrPeriodStartTime" |
166
- "instantOrPeriodEndTime" |
167
-
168
- "device" |
169
- "wMBusDeviceAddresses" |
170
- "kamdraftDeviceAddresses" |
171
- "tchlrDeviceAddresses" |
172
- "kamdaDeviceAddresses" |
173
- "msisdnDeviceAddresses" |
174
- "deviceRegisters" |
175
- "consumptionZone" |
176
-
177
- "mBusFormatStringSignature" |
178
- "deviceSoftwareVersion" |
179
-
180
- "kamstrupMulticalInfocodeType1" |
181
- "kamstrupMulticalInfocodeType2" |
182
- "kamstrupMulticalInfocodeType3" |
183
- "kamstrupMulticalInfocodeType4" |
184
- "kamstrupMulticalInfocode" |
185
- "kamstrupModuleType" |
186
-
187
- "diehlInfocodeType1" |
188
- "diehlInfocode" |
189
-
190
- "landisGyrMBusStatusType1" |
191
- "landisGyrMBusStatusType2" |
192
- "landisGyrMBusStatus" |
193
- "landisGyrInfocodeType1" |
194
- "landisGyrInfocodeType2" |
195
- "landisGyrInfocode" |
196
-
197
- "infocode";
1
+ export type RegisterId =
2
+ "none" |
3
+
4
+ "heatEnergy" |
5
+ "diffHeatEnergy" |
6
+
7
+ "heatEnergyVolumeInInlet" |
8
+ "diffHeatEnergyVolumeInInlet" |
9
+
10
+ "heatEnergyVolumeInOutlet" |
11
+ "diffHeatEnergyVolumeInOutlet" |
12
+
13
+ "coolingEnergy" |
14
+ "diffCoolingEnergy" |
15
+
16
+ "coolingEnergyVolumeInInlet" |
17
+ "diffCoolingEnergyVolumeInInlet" |
18
+
19
+ "coolingEnergyVolumeInOutlet" |
20
+ "diffCoolingEnergyVolumeInOutlet" |
21
+
22
+ "electricalEnergy" |
23
+ "diffElectricalEnergy" |
24
+
25
+ "reactiveEnergy" |
26
+ "diffReactiveEnergy" |
27
+
28
+ "volume" |
29
+ "diffVolume" |
30
+
31
+ "inletVolume" |
32
+ "diffInletVolume" |
33
+
34
+ "outletVolume" |
35
+ "diffOutletVolume" |
36
+
37
+ "pulseInputAVolume" |
38
+ "diffPulseInputAVolume" |
39
+
40
+ "pulseInputBVolume" |
41
+ "diffPulseInputBVolume" |
42
+
43
+ "mass" |
44
+ "diffMass" |
45
+
46
+ "inletMass" |
47
+ "diffInletMass" |
48
+
49
+ "outletMass" |
50
+ "diffOutletMass" |
51
+
52
+ "power" |
53
+ "maxPower" |
54
+ "minPower" |
55
+ "avgPower" |
56
+
57
+ "inletPower" |
58
+ "maxInletPower" |
59
+ "minInletPower" |
60
+ "avgInletPower" |
61
+
62
+ "outletPower" |
63
+ "maxOutletPower" |
64
+ "minOutletPower" |
65
+ "avgOutletPower" |
66
+
67
+ "volumeFlow" |
68
+ "maxVolumeFlow" |
69
+ "minVolumeFlow" |
70
+ "avgVolumeFlow" |
71
+
72
+ "inletVolumeFlow" |
73
+ "maxInletVolumeFlow" |
74
+ "minInletVolumeFlow" |
75
+ "avgInletVolumeFlow" |
76
+
77
+ "outletVolumeFlow" |
78
+ "maxOutletVolumeFlow" |
79
+ "minOutletVolumeFlow" |
80
+ "avgOutletVolumeFlow" |
81
+
82
+ "massFlow" |
83
+ "maxMassFlow" |
84
+ "minMassFlow" |
85
+ "avgMassFlow" |
86
+
87
+ "inletMassFlow" |
88
+ "maxInletMassFlow" |
89
+ "minInletMassFlow" |
90
+ "avgInletMassFlow" |
91
+
92
+ "outletMassFlow" |
93
+ "maxOutletMassFlow" |
94
+ "minOutletMassFlow" |
95
+ "avgOutletMassFlow" |
96
+
97
+ "flowTemperature" |
98
+ "maxFlowTemperature" |
99
+ "minFlowTemperature" |
100
+ "avgFlowTemperature" |
101
+
102
+ "inletFlowTemperature" |
103
+ "maxInletFlowTemperature" |
104
+ "minInletFlowTemperature" |
105
+ "avgInletFlowTemperature" |
106
+
107
+ "outletFlowTemperature" |
108
+ "maxOutletFlowTemperature" |
109
+ "minOutletFlowTemperature" |
110
+ "avgOutletFlowTemperature" |
111
+
112
+ "inletMinusOutletFlowTemperatureDifference" |
113
+ "maxInletMinusOutletFlowTemperatureDifference" |
114
+ "minInletMinusOutletFlowTemperatureDifference" |
115
+ "avgInletMinusOutletFlowTemperatureDifference" |
116
+
117
+ "outletMinusInletFlowTemperatureDifference" |
118
+ "maxOutletMinusInletFlowTemperatureDifference" |
119
+ "minOutletMinusInletFlowTemperatureDifference" |
120
+ "avgOutletMinusInletFlowTemperatureDifference" |
121
+
122
+ "ambientTemperature" |
123
+ "maxAmbientTemperature" |
124
+ "minAmbientTemperature" |
125
+ "avgAmbientTemperature" |
126
+
127
+ "radiatorTemperature" |
128
+ "maxRadiatorTemperature" |
129
+ "minRadiatorTemperature" |
130
+ "avgRadiatorTemperature" |
131
+
132
+ "relativeHumidity" |
133
+
134
+ "kamstrupE8Inlet" |
135
+ "diffKamstrupE8Inlet" |
136
+ "kamstrupE9Outlet" |
137
+ "diffKamstrupE9Outlet" |
138
+
139
+ "operatingTime" |
140
+ "diffOperatingTime" |
141
+
142
+ "remainingBatteryTime" |
143
+ "diffRemainingBatteryTime" |
144
+
145
+ "deviceDate" |
146
+ "deviceTime" |
147
+ "deviceDateTime" |
148
+
149
+ "timeSinceLastExactOverhearingArrived" |
150
+ "timeAtLastExactOverhearingArrived" |
151
+
152
+ "timeSinceLastPossibleCandidateOverhearingArrived" |
153
+ "timeAtLastPossibleCandidateOverhearingArrived" |
154
+
155
+ "timeSinceLastSampled" |
156
+ "timeAtLastSampled" |
157
+
158
+ "timeSinceLastInstallationMounted" |
159
+ "timeAtLastInstallationMounted" |
160
+
161
+ "basetime" |
162
+ "instantTime" |
163
+ "periodStartTime" |
164
+ "periodEndTime" |
165
+ "instantOrPeriodStartTime" |
166
+ "instantOrPeriodEndTime" |
167
+
168
+ "device" |
169
+ "wMBusDeviceAddresses" |
170
+ "kamdraftDeviceAddresses" |
171
+ "tchlrDeviceAddresses" |
172
+ "kamdaDeviceAddresses" |
173
+ "msisdnDeviceAddresses" |
174
+ "deviceRegisters" |
175
+ "consumptionZone" |
176
+
177
+ "mBusFormatStringSignature" |
178
+ "deviceSoftwareVersion" |
179
+
180
+ "kamstrupMulticalInfocodeType1" |
181
+ "kamstrupMulticalInfocodeType2" |
182
+ "kamstrupMulticalInfocodeType3" |
183
+ "kamstrupMulticalInfocodeType4" |
184
+ "kamstrupMulticalInfocode" |
185
+ "kamstrupModuleType" |
186
+
187
+ "diehlInfocodeType1" |
188
+ "diehlInfocode" |
189
+
190
+ "landisGyrMBusStatusType1" |
191
+ "landisGyrMBusStatusType2" |
192
+ "landisGyrMBusStatus" |
193
+ "landisGyrInfocodeType1" |
194
+ "landisGyrInfocodeType2" |
195
+ "landisGyrInfocode" |
196
+
197
+ "infocode";
@@ -1,41 +1,41 @@
1
- import { expect } from "chai";
2
- import { RegisterDefinition } from ".";
3
- import { RegisterLibrary } from "./register-library";
4
-
5
- const volume: RegisterDefinition = {
6
- id: "volume",
7
- measure: "volume",
8
- aggregate: "instant",
9
- units: ["cubicMeter"]
10
- };
11
-
12
- describe("library", () => {
13
- beforeEach(() => {
14
- RegisterLibrary.reset();
15
- });
16
-
17
- it("should get added definition", () => {
18
- RegisterLibrary.add(volume);
19
- const definition = RegisterLibrary.get("volume");
20
- expect(definition.id).to.equal("volume");
21
- });
22
-
23
- it("should add all definitions in pack", () => {
24
- RegisterLibrary.add({
25
- someRandomKey: volume
26
- });
27
- const definition = RegisterLibrary.get("volume");
28
- expect(definition.id).to.equal("volume");
29
- });
30
-
31
- it("should throw when getting not added register", () => {
32
- expect(() => RegisterLibrary.get("volume")).to.throw();
33
- });
34
-
35
- it("should return all definitions when invoking all()", () => {
36
- RegisterLibrary.add(volume);
37
- RegisterLibrary.add(volume); // Only added once.
38
- const all = RegisterLibrary.all();
39
- expect(all.length).to.equal(1);
40
- })
41
- });
1
+ import { expect } from "chai";
2
+ import { RegisterDefinition } from ".";
3
+ import { RegisterLibrary } from "./register-library";
4
+
5
+ const volume: RegisterDefinition = {
6
+ id: "volume",
7
+ measure: "volume",
8
+ aggregate: "instant",
9
+ units: ["cubicMeter"]
10
+ };
11
+
12
+ describe("library", () => {
13
+ beforeEach(() => {
14
+ RegisterLibrary.reset();
15
+ });
16
+
17
+ it("should get added definition", () => {
18
+ RegisterLibrary.add(volume);
19
+ const definition = RegisterLibrary.get("volume");
20
+ expect(definition.id).to.equal("volume");
21
+ });
22
+
23
+ it("should add all definitions in pack", () => {
24
+ RegisterLibrary.add({
25
+ someRandomKey: volume
26
+ });
27
+ const definition = RegisterLibrary.get("volume");
28
+ expect(definition.id).to.equal("volume");
29
+ });
30
+
31
+ it("should throw when getting not added register", () => {
32
+ expect(() => RegisterLibrary.get("volume")).to.throw();
33
+ });
34
+
35
+ it("should return all definitions when invoking all()", () => {
36
+ RegisterLibrary.add(volume);
37
+ RegisterLibrary.add(volume); // Only added once.
38
+ const all = RegisterLibrary.all();
39
+ expect(all.length).to.equal(1);
40
+ })
41
+ });
@@ -1,57 +1,57 @@
1
- import { RegisterDefinition } from "./register-definition";
2
- import { RegisterId } from "./register-id";
3
- import { RegisterPack } from "./register-pack";
4
-
5
- class Library {
6
- private definitions: Partial<{ [id in RegisterId]: RegisterDefinition }> = {};
7
- public add(...definitions: (RegisterDefinition | RegisterPack)[]) {
8
- for (const definition of definitions) {
9
- if (isDefinition(definition)) {
10
- this.tryAdd(definition);
11
- }
12
- else {
13
- for (const definitionInPack of Object.values(definition)) {
14
- this.tryAdd(definitionInPack);
15
- }
16
- }
17
- }
18
- }
19
-
20
- private tryAdd(definition: RegisterDefinition) {
21
- if (!this.definitions[definition.id]) {
22
- this.definitions[definition.id] = definition;
23
- return true;
24
- }
25
- return false;
26
- }
27
-
28
- public has(id: RegisterId) {
29
- return !!this.definitions[id];
30
- }
31
-
32
- public tryGet(id: RegisterId) {
33
- return this.definitions[id];
34
- }
35
-
36
- public get(id: RegisterId) {
37
- const definition = this.definitions[id];
38
- if (!definition) {
39
- throw new Error(`Defintion was not loaded for register ${id}`);
40
- }
41
- return definition;
42
- }
43
-
44
- public all() {
45
- return Object.values(this.definitions).map(x => x!);
46
- }
47
-
48
- public reset() {
49
- this.definitions = {};
50
- }
51
- }
52
-
53
- function isDefinition(definitionOrPack: RegisterDefinition | RegisterPack): definitionOrPack is RegisterDefinition {
54
- return !!(definitionOrPack.id && definitionOrPack.aggregate && definitionOrPack.units);
55
- }
56
-
57
- export const RegisterLibrary = new Library();
1
+ import { RegisterDefinition } from "./register-definition";
2
+ import { RegisterId } from "./register-id";
3
+ import { RegisterPack } from "./register-pack";
4
+
5
+ class Library {
6
+ private definitions: Partial<{ [id in RegisterId]: RegisterDefinition }> = {};
7
+ public add(...definitions: (RegisterDefinition | RegisterPack)[]) {
8
+ for (const definition of definitions) {
9
+ if (isDefinition(definition)) {
10
+ this.tryAdd(definition);
11
+ }
12
+ else {
13
+ for (const definitionInPack of Object.values(definition)) {
14
+ this.tryAdd(definitionInPack);
15
+ }
16
+ }
17
+ }
18
+ }
19
+
20
+ private tryAdd(definition: RegisterDefinition) {
21
+ if (!this.definitions[definition.id]) {
22
+ this.definitions[definition.id] = definition;
23
+ return true;
24
+ }
25
+ return false;
26
+ }
27
+
28
+ public has(id: RegisterId) {
29
+ return !!this.definitions[id];
30
+ }
31
+
32
+ public tryGet(id: RegisterId) {
33
+ return this.definitions[id];
34
+ }
35
+
36
+ public get(id: RegisterId) {
37
+ const definition = this.definitions[id];
38
+ if (!definition) {
39
+ throw new Error(`Defintion was not loaded for register ${id}`);
40
+ }
41
+ return definition;
42
+ }
43
+
44
+ public all() {
45
+ return Object.values(this.definitions).map(x => x!);
46
+ }
47
+
48
+ public reset() {
49
+ this.definitions = {};
50
+ }
51
+ }
52
+
53
+ function isDefinition(definitionOrPack: RegisterDefinition | RegisterPack): definitionOrPack is RegisterDefinition {
54
+ return !!(definitionOrPack.id && definitionOrPack.aggregate && definitionOrPack.units);
55
+ }
56
+
57
+ export const RegisterLibrary = new Library();
@@ -1,5 +1,5 @@
1
- import { RegisterDefinition } from "./register-definition";
2
-
3
- export interface RegisterPack {
4
- [key: string]: RegisterDefinition;
5
- }
1
+ import { RegisterDefinition } from "./register-definition";
2
+
3
+ export interface RegisterPack {
4
+ [key: string]: RegisterDefinition;
5
+ }
@@ -1,6 +1,6 @@
1
- import { RegisterDefinition } from "./register-definition";
2
- import { RegisterId } from "./register-id";
3
-
4
- export function getRegisterId(register: RegisterId | RegisterDefinition) {
5
- return typeof register === "string" ? register : register.id;
6
- }
1
+ import { RegisterDefinition } from "./register-definition";
2
+ import { RegisterId } from "./register-id";
3
+
4
+ export function getRegisterId(register: RegisterId | RegisterDefinition) {
5
+ return typeof register === "string" ? register : register.id;
6
+ }
package/src/step.spec.ts CHANGED
@@ -1,30 +1,30 @@
1
- import { expect } from "chai";
2
- import { DateTime } from "luxon";
3
- import { DayOfWeek, Step } from "./step";
4
-
5
- describe("startOf", () => {
6
- it("returns start of day", () => {
7
- const dt = DateTime.fromISO("2020-01-11T05:00:00+01:00");
8
- const result = Step.startOf(dt, "day");
9
- expect(+result).to.equal(+DateTime.fromISO("2020-01-11T00:00:00+01:00"));
10
- });
11
-
12
- it("returns previous monday from saturday", () => {
13
- const dt = DateTime.fromISO("2020-01-11T05:00:00+01:00");
14
- const result = Step.startOf(dt, "week", DayOfWeek.Monday);
15
- expect(+result).to.equal(+DateTime.fromISO("2020-01-06T00:00:00+01:00"));
16
- });
17
-
18
- it("returns same monday from monday with hour", () => {
19
- const dt = DateTime.fromISO("2020-01-13T05:00:00+01:00");
20
- const result = Step.startOf(dt, "week", DayOfWeek.Monday);
21
- expect(+result).to.equal(+DateTime.fromISO("2020-01-13T00:00:00+01:00"));
22
- });
1
+ import { expect } from "chai";
2
+ import { DateTime } from "luxon";
3
+ import { DayOfWeek, Step } from "./step";
4
+
5
+ describe("startOf", () => {
6
+ it("returns start of day", () => {
7
+ const dt = DateTime.fromISO("2020-01-11T05:00:00+01:00");
8
+ const result = Step.startOf(dt, "day");
9
+ expect(+result).to.equal(+DateTime.fromISO("2020-01-11T00:00:00+01:00"));
10
+ });
11
+
12
+ it("returns previous monday from saturday", () => {
13
+ const dt = DateTime.fromISO("2020-01-11T05:00:00+01:00");
14
+ const result = Step.startOf(dt, "week", DayOfWeek.Monday);
15
+ expect(+result).to.equal(+DateTime.fromISO("2020-01-06T00:00:00+01:00"));
16
+ });
17
+
18
+ it("returns same monday from monday with hour", () => {
19
+ const dt = DateTime.fromISO("2020-01-13T05:00:00+01:00");
20
+ const result = Step.startOf(dt, "week", DayOfWeek.Monday);
21
+ expect(+result).to.equal(+DateTime.fromISO("2020-01-13T00:00:00+01:00"));
22
+ });
23
+ });
24
+
25
+ describe("asDuration", () => {
26
+ it("should return equivalent duration", () => {
27
+ const duration = Step.asDuration("week");
28
+ expect(duration.days).to.equal(7);
29
+ });
23
30
  });
24
-
25
- describe("asDuration", () => {
26
- it("should return equivalent duration", () => {
27
- const duration = Step.asDuration("week");
28
- expect(duration.days).to.equal(7);
29
- });
30
- });