@wmfs/tymly-schedule-plugin 1.3.0 → 1.4.0
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/.version +1 -1
- package/CHANGELOG.md +27 -0
- package/README.md +1 -1
- package/lib/components/services/schedule/utils/datetime-to-rule.js +8 -6
- package/package.json +6 -6
- package/plugin.json +1 -1
- package/test/rule-to-datetime-tests.js +43 -13
package/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION=1.
|
|
1
|
+
VERSION=1.4.0
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
# [1.4.0](https://github.com/wmfs/tymly-schedule-plugin/compare/v1.3.1...v1.4.0) (2022-12-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### ✨ Features
|
|
5
|
+
|
|
6
|
+
* commiting progress ([26d8ed1](https://github.com/wmfs/tymly-schedule-plugin/commit/26d8ed1b5fdbbb0a8a85e0a40308e9c8fb8d4339))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
* issues with conflict ([37af828](https://github.com/wmfs/tymly-schedule-plugin/commit/37af82807d1b4b20c57f9a5ebc8396394790b2d9))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### 🛠 Builds
|
|
15
|
+
|
|
16
|
+
* **deps-dev:** update dependency [@semantic-release](https://github.com/semantic-release)/changelog to v6.0.2 ([908350d](https://github.com/wmfs/tymly-schedule-plugin/commit/908350d9c5d5a28848018e49504d8d0efb8f2fc2))
|
|
17
|
+
* **deps-dev:** update dependency [@wmfs](https://github.com/wmfs)/tymly-pg-plugin to v1.276.0 ([c1d33c2](https://github.com/wmfs/tymly-schedule-plugin/commit/c1d33c24891d1bdea789bb7ebc362fd46c2c288b))
|
|
18
|
+
* **deps-dev:** update dependency [@wmfs](https://github.com/wmfs)/tymly-test-helpers to v1.22.2 ([7ce3a0d](https://github.com/wmfs/tymly-schedule-plugin/commit/7ce3a0d358b642dd9b3b48aa1458459e4b266dc7))
|
|
19
|
+
* **deps-dev:** update dependency chai to v4.3.7 ([0ba95fa](https://github.com/wmfs/tymly-schedule-plugin/commit/0ba95fa34087c7efafe4d5da6f3f709c9d014a5d))
|
|
20
|
+
|
|
21
|
+
## [1.3.1](https://github.com/wmfs/tymly-schedule-plugin/compare/v1.3.0...v1.3.1) (2022-11-29)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### 🐛 Bug Fixes
|
|
25
|
+
|
|
26
|
+
* changed access to public & force build ([0a5ae10](https://github.com/wmfs/tymly-schedule-plugin/commit/0a5ae10bf9acc93ebf42fbeb447bc2e9a38b543c))
|
|
27
|
+
|
|
1
28
|
# [1.3.0](https://github.com/wmfs/tymly-schedule-plugin/compare/v1.2.0...v1.3.0) (2022-11-29)
|
|
2
29
|
|
|
3
30
|
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
[](https://standardjs.com)
|
|
9
9
|
[](https://github.com/wmfs/tymly-schedule-plugin/blob/master/LICENSE)
|
|
10
10
|
|
|
11
|
-
> Provides state machine scheduling for the Tymly framework
|
|
11
|
+
> Provides state machine scheduling for the Tymly framework
|
|
12
12
|
|
|
13
13
|
## <a name="install"></a>Install
|
|
14
14
|
```bash
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
const moment = require('moment')
|
|
2
|
+
|
|
1
3
|
module.exports = function (datetime) {
|
|
2
4
|
if (!(datetime instanceof Date)) {
|
|
3
5
|
datetime = new Date()
|
|
4
6
|
}
|
|
5
7
|
|
|
6
8
|
return {
|
|
7
|
-
year: datetime.
|
|
8
|
-
month: datetime.
|
|
9
|
-
date: datetime.
|
|
10
|
-
hour: datetime.
|
|
11
|
-
minute: datetime.
|
|
12
|
-
second: datetime.
|
|
9
|
+
year: moment(datetime).year(),
|
|
10
|
+
month: moment(datetime).month(),
|
|
11
|
+
date: moment(datetime).date(),
|
|
12
|
+
hour: moment(datetime).hour(),
|
|
13
|
+
minute: moment(datetime).minute(),
|
|
14
|
+
second: moment(datetime).second()
|
|
13
15
|
}
|
|
14
16
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wmfs/tymly-schedule-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Provides state machine scheduling for the Tymly framework",
|
|
5
5
|
"homepage": "https://github.com/wmfs/tymly-schedule-plugin#readme",
|
|
6
6
|
"author": "West Midlands Fire Service",
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"uuid": "^9.0.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@semantic-release/changelog": "6.0.
|
|
29
|
+
"@semantic-release/changelog": "6.0.2",
|
|
30
30
|
"@semantic-release/exec": "6.0.3",
|
|
31
31
|
"@semantic-release/git": "10.0.1",
|
|
32
32
|
"@wmfs/tymly": "1.242.0",
|
|
33
|
-
"@wmfs/tymly-pg-plugin": "1.
|
|
34
|
-
"@wmfs/tymly-test-helpers": "1.22.
|
|
35
|
-
"chai": "4.3.
|
|
33
|
+
"@wmfs/tymly-pg-plugin": "1.276.0",
|
|
34
|
+
"@wmfs/tymly-test-helpers": "1.22.2",
|
|
35
|
+
"chai": "4.3.7",
|
|
36
36
|
"codecov": "3.8.3",
|
|
37
37
|
"conventional-changelog-metahub": "4.0.1",
|
|
38
38
|
"cz-conventional-changelog": "3.3.0",
|
|
@@ -55,6 +55,6 @@
|
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
|
-
"access": "
|
|
58
|
+
"access": "public"
|
|
59
59
|
}
|
|
60
60
|
}
|
package/plugin.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const expect = require('chai').expect
|
|
4
4
|
|
|
5
|
+
const moment = require('moment')
|
|
5
6
|
const ruleToDatetime = require('../lib/components/services/schedule/utils/rule-to-datetime')
|
|
6
7
|
const datetimeToRule = require('../lib/components/services/schedule/utils/datetime-to-rule')
|
|
7
8
|
|
|
@@ -75,29 +76,58 @@ describe('Rule to datetime tests', function () {
|
|
|
75
76
|
|
|
76
77
|
describe('Datetime to rule tests', function () {
|
|
77
78
|
it('No options, should default to now', () => {
|
|
78
|
-
const now =
|
|
79
|
+
const now = moment()
|
|
79
80
|
const rule = datetimeToRule()
|
|
80
81
|
|
|
81
|
-
expect(rule.year).to.eql(now.
|
|
82
|
-
expect(rule.month).to.eql(now.
|
|
83
|
-
expect(rule.date).to.eql(now.
|
|
84
|
-
expect(rule.hour).to.eql(now.
|
|
85
|
-
expect(rule.minute).to.eql(now.
|
|
86
|
-
expect(rule.second).to.eql(now.
|
|
82
|
+
expect(rule.year).to.eql(now.year())
|
|
83
|
+
expect(rule.month).to.eql(now.month())
|
|
84
|
+
expect(rule.date).to.eql(now.date())
|
|
85
|
+
expect(rule.hour).to.eql(now.hour())
|
|
86
|
+
expect(rule.minute).to.eql(now.minute())
|
|
87
|
+
expect(rule.second).to.eql(now.second())
|
|
87
88
|
})
|
|
88
89
|
|
|
89
90
|
it('Specific year, the rest should default to now', () => {
|
|
90
|
-
|
|
91
|
+
let datetime = new Date()
|
|
91
92
|
const year = datetime.getFullYear() + 2
|
|
92
93
|
datetime.setFullYear(year)
|
|
93
94
|
|
|
94
95
|
const rule = datetimeToRule(datetime)
|
|
96
|
+
datetime = moment(datetime)
|
|
95
97
|
|
|
96
98
|
expect(rule.year).to.eql(year)
|
|
97
|
-
expect(rule.month).to.eql(datetime.
|
|
98
|
-
expect(rule.date).to.eql(datetime.
|
|
99
|
-
expect(rule.hour).to.eql(datetime.
|
|
100
|
-
expect(rule.minute).to.eql(datetime.
|
|
101
|
-
expect(rule.second).to.eql(datetime.
|
|
99
|
+
expect(rule.month).to.eql(datetime.month())
|
|
100
|
+
expect(rule.date).to.eql(datetime.date())
|
|
101
|
+
expect(rule.hour).to.eql(datetime.hour())
|
|
102
|
+
expect(rule.minute).to.eql(datetime.minute())
|
|
103
|
+
expect(rule.second).to.eql(datetime.second())
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
it('DST test, should change time by +1 hour', () => {
|
|
107
|
+
const currentDateTime = new Date('Sunday March 27 2022 00:59:00')
|
|
108
|
+
|
|
109
|
+
// 2022-03-27T02:00:00+01:00
|
|
110
|
+
const startDSTDateTime = moment(currentDateTime).add(1, 'minutes')
|
|
111
|
+
|
|
112
|
+
// adding 1 min and setting as Date object
|
|
113
|
+
const rule = datetimeToRule(new Date(currentDateTime.getTime() + (60 * 1000)))
|
|
114
|
+
|
|
115
|
+
expect(rule.date).to.eql(startDSTDateTime.date())
|
|
116
|
+
expect(rule.hour).to.eql(startDSTDateTime.hour())
|
|
117
|
+
expect(rule.minute).to.eql(startDSTDateTime.minute())
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('DST test, should change time by -1 hour', () => {
|
|
121
|
+
const currentDateTime = new Date('Sunday October 30 2022 01:59:00')
|
|
122
|
+
|
|
123
|
+
// 2022-10-30T01:00:00+00:00
|
|
124
|
+
const endDSTDateTime = moment(currentDateTime).add(1, 'minutes')
|
|
125
|
+
|
|
126
|
+
// adding 1 min and setting as Date object
|
|
127
|
+
const rule = datetimeToRule(new Date(currentDateTime.getTime() + (60 * 1000)))
|
|
128
|
+
|
|
129
|
+
expect(rule.date).to.eql(endDSTDateTime.date())
|
|
130
|
+
expect(rule.hour).to.eql(endDSTDateTime.hour())
|
|
131
|
+
expect(rule.minute).to.eql(endDSTDateTime.minute())
|
|
102
132
|
})
|
|
103
133
|
})
|