cron 5.0.0-beta.2 → 5.0.0-beta.3
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/CHANGELOG.md +77 -1313
- package/dist/time.d.ts +4 -0
- package/dist/time.js +44 -12
- package/package.json +7 -7
package/dist/time.d.ts
CHANGED
|
@@ -25,6 +25,10 @@ export declare class CronTime {
|
|
|
25
25
|
error?: CronError;
|
|
26
26
|
};
|
|
27
27
|
private _getWeekDay;
|
|
28
|
+
private _matchesDay;
|
|
29
|
+
private _matches;
|
|
30
|
+
private _matchesMinute;
|
|
31
|
+
private _firstMatchBetween;
|
|
28
32
|
sendAt(): DateTime;
|
|
29
33
|
sendAt(i: number): DateTime[];
|
|
30
34
|
getTimeout(): number;
|
package/dist/time.js
CHANGED
|
@@ -55,6 +55,37 @@ class CronTime {
|
|
|
55
55
|
_getWeekDay(date) {
|
|
56
56
|
return date.weekday === 7 ? 0 : date.weekday;
|
|
57
57
|
}
|
|
58
|
+
_matchesDay(date) {
|
|
59
|
+
return !((!(date.day in this.dayOfMonth) &&
|
|
60
|
+
Object.keys(this.dayOfMonth).length !== 31 &&
|
|
61
|
+
!(this._getWeekDay(date) in this.dayOfWeek &&
|
|
62
|
+
Object.keys(this.dayOfWeek).length !== 7)) ||
|
|
63
|
+
(!(this._getWeekDay(date) in this.dayOfWeek) &&
|
|
64
|
+
Object.keys(this.dayOfWeek).length !== 7 &&
|
|
65
|
+
!(date.day in this.dayOfMonth &&
|
|
66
|
+
Object.keys(this.dayOfMonth).length !== 31)));
|
|
67
|
+
}
|
|
68
|
+
_matches(date) {
|
|
69
|
+
return this._matchesMinute(date) && date.second in this.second;
|
|
70
|
+
}
|
|
71
|
+
_matchesMinute(date) {
|
|
72
|
+
return (date.month in this.month &&
|
|
73
|
+
this._matchesDay(date) &&
|
|
74
|
+
date.hour in this.hour &&
|
|
75
|
+
date.minute in this.minute);
|
|
76
|
+
}
|
|
77
|
+
_firstMatchBetween(from, to) {
|
|
78
|
+
let date = from;
|
|
79
|
+
while (date < to) {
|
|
80
|
+
if (this._matches(date)) {
|
|
81
|
+
return date;
|
|
82
|
+
}
|
|
83
|
+
date = this._matchesMinute(date)
|
|
84
|
+
? date.plus({ second: 1 })
|
|
85
|
+
: date.plus({ minute: 1 }).startOf('minute');
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
58
89
|
sendAt(i) {
|
|
59
90
|
let date = this.realDate && this.source instanceof luxon_1.DateTime
|
|
60
91
|
? this.source
|
|
@@ -105,7 +136,7 @@ class CronTime {
|
|
|
105
136
|
});
|
|
106
137
|
}
|
|
107
138
|
getNextDateFrom(start, timeZone) {
|
|
108
|
-
var _a, _b;
|
|
139
|
+
var _a, _b, _c, _d;
|
|
109
140
|
if (start instanceof Date) {
|
|
110
141
|
start = luxon_1.DateTime.fromJSDate(start);
|
|
111
142
|
}
|
|
@@ -140,14 +171,7 @@ class CronTime {
|
|
|
140
171
|
date = date.set({ day: 1, hour: 0, minute: 0, second: 0 });
|
|
141
172
|
continue;
|
|
142
173
|
}
|
|
143
|
-
if (
|
|
144
|
-
Object.keys(this.dayOfMonth).length !== 31 &&
|
|
145
|
-
!(this._getWeekDay(date) in this.dayOfWeek &&
|
|
146
|
-
Object.keys(this.dayOfWeek).length !== 7)) ||
|
|
147
|
-
(!(this._getWeekDay(date) in this.dayOfWeek) &&
|
|
148
|
-
Object.keys(this.dayOfWeek).length !== 7 &&
|
|
149
|
-
!(date.day in this.dayOfMonth &&
|
|
150
|
-
Object.keys(this.dayOfMonth).length !== 31))) {
|
|
174
|
+
if (!this._matchesDay(date)) {
|
|
151
175
|
date = date.plus({ days: 1 });
|
|
152
176
|
date = date.set({ hour: 0, minute: 0, second: 0 });
|
|
153
177
|
continue;
|
|
@@ -176,7 +200,11 @@ class CronTime {
|
|
|
176
200
|
date = luxon_1.DateTime.fromFormat(`${date.year}-${date.month}-${date.day} ${date.hour}:${date.minute}:${date.second}`, 'yyyy-M-d H:m:s', {
|
|
177
201
|
zone: timeZone
|
|
178
202
|
});
|
|
179
|
-
const
|
|
203
|
+
const januaryReferenceDate = luxon_1.DateTime.fromFormat(`${date.year}-1-1 0:0:0`, 'yyyy-M-d H:m:s', { zone: timeZone });
|
|
204
|
+
const julyReferenceDate = luxon_1.DateTime.fromFormat(`${date.year}-7-1 0:0:0`, 'yyyy-M-d H:m:s', { zone: timeZone });
|
|
205
|
+
const nonDSTReferenceDate = januaryReferenceDate.offset <= julyReferenceDate.offset
|
|
206
|
+
? januaryReferenceDate
|
|
207
|
+
: julyReferenceDate;
|
|
180
208
|
if ((expectedHour !== date.hour || expectedMinute !== date.minute) &&
|
|
181
209
|
nonDSTReferenceDate.offset !== date.offset) {
|
|
182
210
|
while (date.minus({ minute: 1 }).offset !== nonDSTReferenceDate.offset) {
|
|
@@ -188,14 +216,18 @@ class CronTime {
|
|
|
188
216
|
const twoHourTestDate = date.minus({ hour: 2 });
|
|
189
217
|
if ((hourTestDate.hour === date.hour ||
|
|
190
218
|
twoHourTestDate.hour === hourTestDate.hour) &&
|
|
219
|
+
(hourTestDate.offset > date.offset ||
|
|
220
|
+
twoHourTestDate.offset > hourTestDate.offset) &&
|
|
191
221
|
hourTestDate > start) {
|
|
192
|
-
date = hourTestDate;
|
|
222
|
+
date = (_c = this._firstMatchBetween(hourTestDate, date)) !== null && _c !== void 0 ? _c : date;
|
|
193
223
|
}
|
|
194
224
|
const halfHourTestDate = date.minus({ minute: 30 });
|
|
195
225
|
if ((halfHourTestDate.minute === date.minute ||
|
|
196
226
|
hourTestDate.minute === halfHourTestDate.minute) &&
|
|
227
|
+
(halfHourTestDate.offset > date.offset ||
|
|
228
|
+
hourTestDate.offset > halfHourTestDate.offset) &&
|
|
197
229
|
halfHourTestDate > start) {
|
|
198
|
-
date = halfHourTestDate;
|
|
230
|
+
date = (_d = this._firstMatchBetween(halfHourTestDate, date)) !== null && _d !== void 0 ? _d : date;
|
|
199
231
|
}
|
|
200
232
|
return date;
|
|
201
233
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cron",
|
|
3
3
|
"description": "Cron jobs for your node",
|
|
4
|
-
"version": "5.0.0-beta.
|
|
4
|
+
"version": "5.0.0-beta.3",
|
|
5
5
|
"author": "Brandon der Blätter <https://intcreator.com/> (https://github.com/intcreator)",
|
|
6
6
|
"funding": {
|
|
7
7
|
"type": "ko-fi",
|
|
@@ -34,27 +34,27 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@commitlint/cli": "20.5.3",
|
|
36
36
|
"@eslint/js": "9.39.4",
|
|
37
|
-
"@fast-check/jest": "2.
|
|
37
|
+
"@fast-check/jest": "2.3.0",
|
|
38
38
|
"@insurgent/commitlint-config": "20.0.0",
|
|
39
39
|
"@insurgent/conventional-changelog-preset": "10.0.0",
|
|
40
40
|
"@semantic-release/changelog": "6.0.3",
|
|
41
41
|
"@semantic-release/commit-analyzer": "13.0.1",
|
|
42
42
|
"@semantic-release/git": "10.0.1",
|
|
43
|
-
"@semantic-release/github": "12.0.
|
|
44
|
-
"@semantic-release/npm": "13.
|
|
43
|
+
"@semantic-release/github": "12.0.10",
|
|
44
|
+
"@semantic-release/npm": "13.2.0",
|
|
45
45
|
"@semantic-release/release-notes-generator": "14.1.1",
|
|
46
|
-
"@swc/core": "1.16.
|
|
46
|
+
"@swc/core": "1.16.22",
|
|
47
47
|
"@swc/jest": "0.2.39",
|
|
48
48
|
"@types/jest": "30.0.0",
|
|
49
49
|
"@types/node": "24.13.3",
|
|
50
|
-
"@types/sinon": "22.0.
|
|
50
|
+
"@types/sinon": "22.0.2",
|
|
51
51
|
"cross-env": "7.0.3",
|
|
52
52
|
"eslint": "8.57.1",
|
|
53
53
|
"eslint-config-prettier": "9.1.2",
|
|
54
54
|
"eslint-plugin-jest": "27.9.0",
|
|
55
55
|
"eslint-plugin-prettier": "5.5.6",
|
|
56
56
|
"husky": "9.1.7",
|
|
57
|
-
"jest": "30.
|
|
57
|
+
"jest": "30.5.2",
|
|
58
58
|
"lint-staged": "15.5.2",
|
|
59
59
|
"prettier": "3.8.4",
|
|
60
60
|
"semantic-release": "25.0.9",
|