cron 4.1.0 → 4.1.2
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 +41 -0
- package/dist/time.d.ts +9 -6
- package/dist/time.js +54 -171
- package/package.json +17 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
+
## [4.1.2](https://github.com/kelektiv/node-cron/compare/v4.1.1...v4.1.2) (2025-03-28)
|
|
2
|
+
|
|
3
|
+
### 🐛 Bug Fixes
|
|
4
|
+
|
|
5
|
+
* timezone should default to local ([#972](https://github.com/kelektiv/node-cron/issues/972)) ([d2b1aac](https://github.com/kelektiv/node-cron/commit/d2b1aac9c705e111a466daa85b95bed9f7725abd)), closes [#971](https://github.com/kelektiv/node-cron/issues/971) [#971](https://github.com/kelektiv/node-cron/issues/971)
|
|
6
|
+
|
|
7
|
+
## [4.1.1](https://github.com/kelektiv/node-cron/compare/v4.1.0...v4.1.1) (2025-03-26)
|
|
8
|
+
|
|
9
|
+
### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
* cron should still execute after changing the time back during daylight savings ([#966](https://github.com/kelektiv/node-cron/issues/966)) ([8cf0712](https://github.com/kelektiv/node-cron/commit/8cf07121290beb1b9e1a33bd393503fa031c691a)), closes [#881](https://github.com/kelektiv/node-cron/issues/881) [#881](https://github.com/kelektiv/node-cron/issues/881)
|
|
12
|
+
|
|
13
|
+
### ♻️ Chores
|
|
14
|
+
|
|
15
|
+
* **action:** update actions/setup-node action to v4.3.0 ([e70709f](https://github.com/kelektiv/node-cron/commit/e70709f3b004f8ccdddbebf308e85aeabf76ffb5))
|
|
16
|
+
* **action:** update actions/upload-artifact action to v4.6.1 ([06ed76c](https://github.com/kelektiv/node-cron/commit/06ed76c0f0947132eb951b13503f7cb0db797880))
|
|
17
|
+
* **action:** update actions/upload-artifact action to v4.6.2 ([69ea222](https://github.com/kelektiv/node-cron/commit/69ea2223febff26b5dd0074bde002f218ba93c4c))
|
|
18
|
+
* **action:** update github/codeql-action action to v3.28.10 ([1d14a08](https://github.com/kelektiv/node-cron/commit/1d14a0896732686dbc1020fb3ba9d0bf890acec4))
|
|
19
|
+
* **action:** update github/codeql-action action to v3.28.11 ([cd28d4f](https://github.com/kelektiv/node-cron/commit/cd28d4ffb7000c35d766b564f33d2988be5b4601))
|
|
20
|
+
* **action:** update github/codeql-action action to v3.28.13 ([154f885](https://github.com/kelektiv/node-cron/commit/154f885d2da0c203395daa746a9fd3c378d35ab8))
|
|
21
|
+
* **action:** update ossf/scorecard-action action to v2.4.1 ([6a4ec39](https://github.com/kelektiv/node-cron/commit/6a4ec391836848fa4fa0949cc03acb0da1d1cf6b))
|
|
22
|
+
* **deps:** lock file maintenance ([6742c01](https://github.com/kelektiv/node-cron/commit/6742c01a10ec1651de29897d826b0fa21e5f44fc))
|
|
23
|
+
* **deps:** lock file maintenance ([a97cdb1](https://github.com/kelektiv/node-cron/commit/a97cdb19b2c179c1e7fcb07c8f5357299e252a13))
|
|
24
|
+
* **deps:** lock file maintenance ([c585973](https://github.com/kelektiv/node-cron/commit/c585973bf822713a8c0c9006074827732130f345))
|
|
25
|
+
* **deps:** lock file maintenance ([e156aa7](https://github.com/kelektiv/node-cron/commit/e156aa768821ca644c61ddd1387764aa817c85ca))
|
|
26
|
+
* **deps:** update dependency [@commitlint](https://github.com/commitlint)/cli to v19.8.0 ([3984884](https://github.com/kelektiv/node-cron/commit/3984884b29315d73c7323f52d238480e31da1ba3))
|
|
27
|
+
* **deps:** update dependency [@eslint](https://github.com/eslint)/js to v9.22.0 ([7415480](https://github.com/kelektiv/node-cron/commit/7415480ccafddad023f62df6cd9ca975930c8315))
|
|
28
|
+
* **deps:** update dependency [@eslint](https://github.com/eslint)/js to v9.23.0 ([00fc7ed](https://github.com/kelektiv/node-cron/commit/00fc7ed1e679f31eeef1a057cbb791bd415c76e7))
|
|
29
|
+
* **deps:** update dependency [@fast-check](https://github.com/fast-check)/jest to v2.1.0 ([a9a8608](https://github.com/kelektiv/node-cron/commit/a9a860807f01fe8526e0d8983b6371ceb27c68dd))
|
|
30
|
+
* **deps:** update dependency [@types](https://github.com/types)/node to v22.13.11 ([38cf6a6](https://github.com/kelektiv/node-cron/commit/38cf6a6ce15d17d888b6103457c4a0c8cb4a1019))
|
|
31
|
+
* **deps:** update dependency [@types](https://github.com/types)/node to v22.13.5 ([a746320](https://github.com/kelektiv/node-cron/commit/a746320f3efe92e47423cf949f42ed1eef945a45))
|
|
32
|
+
* **deps:** update dependency [@types](https://github.com/types)/node to v22.13.9 ([4ac339f](https://github.com/kelektiv/node-cron/commit/4ac339fe4848e20caad97844a283df5a4344bedd))
|
|
33
|
+
* **deps:** update dependency lint-staged to v15.5.0 ([5efb27f](https://github.com/kelektiv/node-cron/commit/5efb27f1e1657fc439781ba3ea1fdb2e571ea03e))
|
|
34
|
+
* **deps:** update dependency prettier to v3.5.3 ([d8f2456](https://github.com/kelektiv/node-cron/commit/d8f245616d1415fa08569ac571af4db77ed7f4ab))
|
|
35
|
+
* **deps:** update dependency sinon to v19.0.4 ([5144f4d](https://github.com/kelektiv/node-cron/commit/5144f4dfd90d0755591200cf957b3aff76f52afb))
|
|
36
|
+
* **deps:** update dependency ts-jest to v29.2.6 ([3625528](https://github.com/kelektiv/node-cron/commit/3625528fbcd2fd0e3da63a03e80271541fe92086))
|
|
37
|
+
* **deps:** update dependency typescript to v5.8.2 ([4ef66e8](https://github.com/kelektiv/node-cron/commit/4ef66e84985b5b2259ae67aded6391f5cbd3a5ec))
|
|
38
|
+
* **deps:** update linters ([ecbe916](https://github.com/kelektiv/node-cron/commit/ecbe916c825663839038e94a23aefe5c91744fe5))
|
|
39
|
+
* **deps:** update node.js to v23.10.0 ([#970](https://github.com/kelektiv/node-cron/issues/970)) ([6775fff](https://github.com/kelektiv/node-cron/commit/6775fff2d06798954d60cc66964e2b671a8be1e7))
|
|
40
|
+
* **deps:** update tests ([5d5e555](https://github.com/kelektiv/node-cron/commit/5d5e55527a5dc108f814f5ab8825e405b91a467d))
|
|
41
|
+
|
|
1
42
|
## [4.1.0](https://github.com/kelektiv/node-cron/compare/v4.0.0...v4.1.0) (2025-02-24)
|
|
2
43
|
|
|
3
44
|
### ✨ Features
|
package/dist/time.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { DateTime, Zone } from 'luxon';
|
|
2
2
|
import { CronError } from './errors';
|
|
3
3
|
import { CronJobParams } from './types/cron.types';
|
|
4
|
+
type CustomZone = Zone & {
|
|
5
|
+
zoneName?: string;
|
|
6
|
+
fixed?: string;
|
|
7
|
+
};
|
|
8
|
+
type CustomDateTime = Omit<DateTime, 'zone'> & {
|
|
9
|
+
zone: CustomZone;
|
|
10
|
+
};
|
|
4
11
|
export declare class CronTime {
|
|
5
12
|
source: string | DateTime;
|
|
6
13
|
timeZone?: string;
|
|
@@ -24,14 +31,10 @@ export declare class CronTime {
|
|
|
24
31
|
getTimeout(): number;
|
|
25
32
|
toString(): string;
|
|
26
33
|
toJSON(): string[];
|
|
27
|
-
getNextDateFrom(start: Date |
|
|
28
|
-
private _findPreviousDSTJump;
|
|
29
|
-
private _checkTimeInSkippedRange;
|
|
30
|
-
private _checkTimeInSkippedRangeSingleHour;
|
|
31
|
-
private _checkTimeInSkippedRangeMultiHour;
|
|
32
|
-
private _forwardDSTJump;
|
|
34
|
+
getNextDateFrom(start: Date | CustomDateTime, timeZone?: string | CustomZone): DateTime;
|
|
33
35
|
private _wcOrAll;
|
|
34
36
|
private _hasAll;
|
|
35
37
|
private _parse;
|
|
36
38
|
private _parseField;
|
|
37
39
|
}
|
|
40
|
+
export {};
|
package/dist/time.js
CHANGED
|
@@ -26,6 +26,10 @@ class CronTime {
|
|
|
26
26
|
if (utcOffset != null) {
|
|
27
27
|
this.utcOffset = utcOffset;
|
|
28
28
|
}
|
|
29
|
+
if (timeZone == null && utcOffset == null) {
|
|
30
|
+
const systemTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
31
|
+
this.timeZone = systemTimezone;
|
|
32
|
+
}
|
|
29
33
|
if (source instanceof Date || source instanceof luxon_1.DateTime) {
|
|
30
34
|
this.source =
|
|
31
35
|
source instanceof Date ? luxon_1.DateTime.fromJSDate(source) : source;
|
|
@@ -56,7 +60,7 @@ class CronTime {
|
|
|
56
60
|
sendAt(i) {
|
|
57
61
|
let date = this.realDate && this.source instanceof luxon_1.DateTime
|
|
58
62
|
? this.source
|
|
59
|
-
: luxon_1.DateTime.
|
|
63
|
+
: luxon_1.DateTime.utc();
|
|
60
64
|
if (this.timeZone) {
|
|
61
65
|
date = date.setZone(this.timeZone);
|
|
62
66
|
}
|
|
@@ -79,7 +83,8 @@ class CronTime {
|
|
|
79
83
|
return date;
|
|
80
84
|
}
|
|
81
85
|
if (i === undefined || isNaN(i) || i < 0) {
|
|
82
|
-
|
|
86
|
+
const nextDate = this.getNextDateFrom(date);
|
|
87
|
+
return nextDate;
|
|
83
88
|
}
|
|
84
89
|
else {
|
|
85
90
|
const dates = [];
|
|
@@ -91,7 +96,7 @@ class CronTime {
|
|
|
91
96
|
}
|
|
92
97
|
}
|
|
93
98
|
getTimeout() {
|
|
94
|
-
return Math.max(-1, this.sendAt().toMillis() - luxon_1.DateTime.
|
|
99
|
+
return Math.max(-1, this.sendAt().toMillis() - luxon_1.DateTime.utc().toMillis());
|
|
95
100
|
}
|
|
96
101
|
toString() {
|
|
97
102
|
return this.toJSON().join(' ');
|
|
@@ -102,15 +107,20 @@ class CronTime {
|
|
|
102
107
|
});
|
|
103
108
|
}
|
|
104
109
|
getNextDateFrom(start, timeZone) {
|
|
105
|
-
var _a;
|
|
110
|
+
var _a, _b;
|
|
106
111
|
if (start instanceof Date) {
|
|
107
112
|
start = luxon_1.DateTime.fromJSDate(start);
|
|
108
113
|
}
|
|
109
|
-
let date = start;
|
|
110
|
-
const firstDate = start.toMillis();
|
|
111
114
|
if (timeZone) {
|
|
112
|
-
|
|
115
|
+
start = start.setZone(timeZone);
|
|
113
116
|
}
|
|
117
|
+
else {
|
|
118
|
+
timeZone = (_a = start.zone.zoneName) !== null && _a !== void 0 ? _a : start.zone.fixed;
|
|
119
|
+
}
|
|
120
|
+
let date = luxon_1.DateTime.fromFormat(`${start.year}-${start.month}-${start.day} ${start.hour}:${start.minute}:${start.second}`, 'yyyy-M-d H:m:s', {
|
|
121
|
+
zone: 'UTC'
|
|
122
|
+
});
|
|
123
|
+
const firstDate = date.toMillis();
|
|
114
124
|
if (!this.realDate) {
|
|
115
125
|
if (date.millisecond > 0) {
|
|
116
126
|
date = date.set({ millisecond: 0, second: date.second + 1 });
|
|
@@ -121,202 +131,75 @@ class CronTime {
|
|
|
121
131
|
}
|
|
122
132
|
const maxMatch = luxon_1.DateTime.now().plus({ years: 8 });
|
|
123
133
|
while (true) {
|
|
124
|
-
const diff = date.toMillis() - start.toMillis();
|
|
125
134
|
if (date > maxMatch) {
|
|
126
135
|
throw new errors_1.CronError(`Something went wrong. No execution date was found in the next 8 years.
|
|
127
136
|
Please provide the following string if you would like to help debug:
|
|
128
|
-
Time Zone: ${(
|
|
137
|
+
Time Zone: ${(_b = timeZone === null || timeZone === void 0 ? void 0 : timeZone.toString()) !== null && _b !== void 0 ? _b : '""'} - Cron String: ${this.source.toString()} - UTC offset: ${date.offset} - current Date: ${luxon_1.DateTime.local().toString()}`);
|
|
129
138
|
}
|
|
130
139
|
if (!(date.month in this.month) &&
|
|
131
140
|
Object.keys(this.month).length !== 12) {
|
|
132
|
-
date = date.plus({
|
|
141
|
+
date = date.plus({ month: 1 });
|
|
133
142
|
date = date.set({ day: 1, hour: 0, minute: 0, second: 0 });
|
|
134
|
-
if (this._forwardDSTJump(0, 0, date)) {
|
|
135
|
-
const [isDone, newDate] = this._findPreviousDSTJump(date);
|
|
136
|
-
date = newDate;
|
|
137
|
-
if (isDone)
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
143
|
continue;
|
|
141
144
|
}
|
|
142
|
-
if (!(date.day in this.dayOfMonth) &&
|
|
145
|
+
if ((!(date.day in this.dayOfMonth) &&
|
|
143
146
|
Object.keys(this.dayOfMonth).length !== 31 &&
|
|
144
147
|
!(this._getWeekDay(date) in this.dayOfWeek &&
|
|
145
|
-
Object.keys(this.dayOfWeek).length !== 7))
|
|
146
|
-
date
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
date = newDate;
|
|
151
|
-
if (isDone)
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
if (!(this._getWeekDay(date) in this.dayOfWeek) &&
|
|
157
|
-
Object.keys(this.dayOfWeek).length !== 7 &&
|
|
158
|
-
!(date.day in this.dayOfMonth &&
|
|
159
|
-
Object.keys(this.dayOfMonth).length !== 31)) {
|
|
148
|
+
Object.keys(this.dayOfWeek).length !== 7)) ||
|
|
149
|
+
(!(this._getWeekDay(date) in this.dayOfWeek) &&
|
|
150
|
+
Object.keys(this.dayOfWeek).length !== 7 &&
|
|
151
|
+
!(date.day in this.dayOfMonth &&
|
|
152
|
+
Object.keys(this.dayOfMonth).length !== 31))) {
|
|
160
153
|
date = date.plus({ days: 1 });
|
|
161
154
|
date = date.set({ hour: 0, minute: 0, second: 0 });
|
|
162
|
-
if (this._forwardDSTJump(0, 0, date)) {
|
|
163
|
-
const [isDone, newDate] = this._findPreviousDSTJump(date);
|
|
164
|
-
date = newDate;
|
|
165
|
-
if (isDone)
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
155
|
continue;
|
|
169
156
|
}
|
|
170
157
|
if (!(date.hour in this.hour) && Object.keys(this.hour).length !== 24) {
|
|
171
|
-
|
|
172
|
-
const expectedMinute = date.minute;
|
|
173
|
-
date = date.set({ hour: expectedHour });
|
|
158
|
+
date = date.plus({ hour: 1 });
|
|
174
159
|
date = date.set({ minute: 0, second: 0 });
|
|
175
|
-
if (this._forwardDSTJump(expectedHour, expectedMinute, date)) {
|
|
176
|
-
const [isDone, newDate] = this._findPreviousDSTJump(date);
|
|
177
|
-
date = newDate;
|
|
178
|
-
if (isDone)
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
160
|
continue;
|
|
182
161
|
}
|
|
183
162
|
if (!(date.minute in this.minute) &&
|
|
184
163
|
Object.keys(this.minute).length !== 60) {
|
|
185
|
-
|
|
186
|
-
const expectedHour = date.hour + (expectedMinute === 60 ? 1 : 0);
|
|
187
|
-
date = date.set({ minute: expectedMinute });
|
|
164
|
+
date = date.plus({ minute: 1 });
|
|
188
165
|
date = date.set({ second: 0 });
|
|
189
|
-
if (this._forwardDSTJump(expectedHour, expectedMinute, date)) {
|
|
190
|
-
const [isDone, newDate] = this._findPreviousDSTJump(date);
|
|
191
|
-
date = newDate;
|
|
192
|
-
if (isDone)
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
continue;
|
|
196
|
-
}
|
|
197
|
-
if (!(date.second in this.second) &&
|
|
198
|
-
Object.keys(this.second).length !== 60) {
|
|
199
|
-
const expectedSecond = date.second === 59 && diff > 60000 ? 0 : date.second + 1;
|
|
200
|
-
const expectedMinute = date.minute + (expectedSecond === 60 ? 1 : 0);
|
|
201
|
-
const expectedHour = date.hour + (expectedMinute === 60 ? 1 : 0);
|
|
202
|
-
date = date.set({ second: expectedSecond });
|
|
203
|
-
if (this._forwardDSTJump(expectedHour, expectedMinute, date)) {
|
|
204
|
-
const [isDone, newDate] = this._findPreviousDSTJump(date);
|
|
205
|
-
date = newDate;
|
|
206
|
-
if (isDone)
|
|
207
|
-
break;
|
|
208
|
-
}
|
|
209
166
|
continue;
|
|
210
167
|
}
|
|
211
|
-
if (date.toMillis() === firstDate
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
date = date.set({ second: expectedSecond });
|
|
216
|
-
if (this._forwardDSTJump(expectedHour, expectedMinute, date)) {
|
|
217
|
-
const [isDone, newDate] = this._findPreviousDSTJump(date);
|
|
218
|
-
date = newDate;
|
|
219
|
-
if (isDone)
|
|
220
|
-
break;
|
|
221
|
-
}
|
|
168
|
+
if (date.toMillis() === firstDate ||
|
|
169
|
+
(!(date.second in this.second) &&
|
|
170
|
+
Object.keys(this.second).length !== 60)) {
|
|
171
|
+
date = date.plus({ second: 1 });
|
|
222
172
|
continue;
|
|
223
173
|
}
|
|
224
174
|
break;
|
|
225
175
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
throw new errors_1.CronError(`ERROR: This DST checking related function assumes the input DateTime (${(_a = date.toISO()) !== null && _a !== void 0 ? _a : date.toMillis()}) is within 24 hours of a DST jump.`);
|
|
237
|
-
}
|
|
238
|
-
expectedMinute = maybeJumpingPoint.minute - 1;
|
|
239
|
-
expectedHour = maybeJumpingPoint.hour;
|
|
240
|
-
if (expectedMinute < 0) {
|
|
241
|
-
expectedMinute += 60;
|
|
242
|
-
expectedHour = (expectedHour + 24 - 1) % 24;
|
|
176
|
+
const expectedHour = date.hour;
|
|
177
|
+
const expectedMinute = date.minute;
|
|
178
|
+
date = luxon_1.DateTime.fromFormat(`${date.year}-${date.month}-${date.day} ${date.hour}:${date.minute}:${date.second}`, 'yyyy-M-d H:m:s', {
|
|
179
|
+
zone: timeZone
|
|
180
|
+
});
|
|
181
|
+
const nonDSTReferenceDate = luxon_1.DateTime.fromFormat(`${date.year}-1-1 0:0:0`, 'yyyy-M-d H:m:s', { zone: timeZone });
|
|
182
|
+
if ((expectedHour !== date.hour || expectedMinute !== date.minute) &&
|
|
183
|
+
nonDSTReferenceDate.offset !== date.offset) {
|
|
184
|
+
while (date.minus({ minute: 1 }).offset !== nonDSTReferenceDate.offset) {
|
|
185
|
+
date = date.minus({ minute: 1 });
|
|
243
186
|
}
|
|
244
|
-
|
|
245
|
-
actualMinute = maybeJumpingPoint.minute;
|
|
246
|
-
actualHour = maybeJumpingPoint.hour;
|
|
247
|
-
} while (expectedMinute === actualMinute && expectedHour === actualHour);
|
|
248
|
-
const afterJumpingPoint = maybeJumpingPoint
|
|
249
|
-
.plus({ minute: 1 })
|
|
250
|
-
.set({ second: 0, millisecond: 0 });
|
|
251
|
-
const beforeJumpingPoint = afterJumpingPoint.minus({ second: 1 });
|
|
252
|
-
if (date.month in this.month &&
|
|
253
|
-
date.day in this.dayOfMonth &&
|
|
254
|
-
this._getWeekDay(date) in this.dayOfWeek) {
|
|
255
|
-
return [
|
|
256
|
-
this._checkTimeInSkippedRange(beforeJumpingPoint, afterJumpingPoint),
|
|
257
|
-
afterJumpingPoint
|
|
258
|
-
];
|
|
259
|
-
}
|
|
260
|
-
return [false, afterJumpingPoint];
|
|
261
|
-
}
|
|
262
|
-
_checkTimeInSkippedRange(beforeJumpingPoint, afterJumpingPoint) {
|
|
263
|
-
const startingMinute = (beforeJumpingPoint.minute + 1) % 60;
|
|
264
|
-
const startingHour = (beforeJumpingPoint.hour + (startingMinute === 0 ? 1 : 0)) % 24;
|
|
265
|
-
const hourRangeSize = afterJumpingPoint.hour - startingHour + 1;
|
|
266
|
-
const isHourJump = startingMinute === 0 && afterJumpingPoint.minute === 0;
|
|
267
|
-
if (hourRangeSize === 2 && isHourJump) {
|
|
268
|
-
return startingHour in this.hour;
|
|
269
|
-
}
|
|
270
|
-
else if (hourRangeSize === 1) {
|
|
271
|
-
return (startingHour in this.hour &&
|
|
272
|
-
this._checkTimeInSkippedRangeSingleHour(startingMinute, afterJumpingPoint.minute));
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
return this._checkTimeInSkippedRangeMultiHour(startingHour, startingMinute, afterJumpingPoint.hour, afterJumpingPoint.minute);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
_checkTimeInSkippedRangeSingleHour(startMinute, endMinute) {
|
|
279
|
-
for (let minute = startMinute; minute < endMinute; ++minute) {
|
|
280
|
-
if (minute in this.minute)
|
|
281
|
-
return true;
|
|
187
|
+
return date;
|
|
282
188
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
189
|
+
const hourTestDate = date.minus({ hour: 1 });
|
|
190
|
+
const twoHourTestDate = date.minus({ hour: 2 });
|
|
191
|
+
if ((hourTestDate.hour === date.hour ||
|
|
192
|
+
twoHourTestDate.hour === hourTestDate.hour) &&
|
|
193
|
+
hourTestDate > start) {
|
|
194
|
+
date = hourTestDate;
|
|
288
195
|
}
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
return firstHourMinuteRange;
|
|
295
|
-
}
|
|
296
|
-
else if (forHour === endHour) {
|
|
297
|
-
return lastHourMinuteRange;
|
|
298
|
-
}
|
|
299
|
-
else {
|
|
300
|
-
return middleHourMinuteRange;
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
for (let hour = startHour; hour <= endHour; ++hour) {
|
|
304
|
-
if (!(hour in this.hour))
|
|
305
|
-
continue;
|
|
306
|
-
const usingRange = selectRange(hour);
|
|
307
|
-
for (const minute of usingRange) {
|
|
308
|
-
if (minute in this.minute)
|
|
309
|
-
return true;
|
|
310
|
-
}
|
|
196
|
+
const halfHourTestDate = date.minus({ minute: 30 });
|
|
197
|
+
if ((halfHourTestDate.minute === date.minute ||
|
|
198
|
+
hourTestDate.minute === halfHourTestDate.minute) &&
|
|
199
|
+
halfHourTestDate > start) {
|
|
200
|
+
date = halfHourTestDate;
|
|
311
201
|
}
|
|
312
|
-
return
|
|
313
|
-
}
|
|
314
|
-
_forwardDSTJump(expectedHour, expectedMinute, actualDate) {
|
|
315
|
-
const actualHour = actualDate.hour;
|
|
316
|
-
const actualMinute = actualDate.minute;
|
|
317
|
-
const didHoursJumped = expectedHour % 24 < actualHour;
|
|
318
|
-
const didMinutesJumped = expectedMinute % 60 < actualMinute;
|
|
319
|
-
return didHoursJumped || didMinutesJumped;
|
|
202
|
+
return date;
|
|
320
203
|
}
|
|
321
204
|
_wcOrAll(unit) {
|
|
322
205
|
if (this._hasAll(unit)) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cron",
|
|
3
3
|
"description": "Cron jobs for your node",
|
|
4
|
-
"version": "4.1.
|
|
4
|
+
"version": "4.1.2",
|
|
5
5
|
"author": "Nick Campbell <nicholas.j.campbell@gmail.com> (https://github.com/ncb000gt)",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/kelektiv/node-cron/issues"
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"lint:prettier": "prettier ./**/*.{json,md,yml} --check",
|
|
19
19
|
"lint": "npm run lint:eslint && npm run lint:prettier",
|
|
20
20
|
"lint:fix": "npm run lint:eslint -- --fix && npm run lint:prettier -- --write",
|
|
21
|
-
"test": "jest --coverage",
|
|
22
|
-
"test:watch": "jest --watch --coverage",
|
|
23
|
-
"test:fuzz": "jest
|
|
21
|
+
"test": "cross-env TZ='Europe/Paris' jest --coverage",
|
|
22
|
+
"test:watch": "cross-env TZ='Europe/Paris' jest --watch --coverage",
|
|
23
|
+
"test:fuzz": "cross-env TZ='Europe/Paris' jest --testMatch='**/*.fuzz.ts' --coverage=false --testTimeout=120000",
|
|
24
24
|
"prepare": "husky"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"luxon": "~3.5.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@commitlint/cli": "19.
|
|
32
|
-
"@eslint/js": "9.
|
|
33
|
-
"@fast-check/jest": "2.0
|
|
31
|
+
"@commitlint/cli": "19.8.0",
|
|
32
|
+
"@eslint/js": "9.23.0",
|
|
33
|
+
"@fast-check/jest": "2.1.0",
|
|
34
34
|
"@insurgent/commitlint-config": "20.0.0",
|
|
35
35
|
"@insurgent/conventional-changelog-preset": "10.0.0",
|
|
36
36
|
"@semantic-release/changelog": "6.0.3",
|
|
@@ -39,22 +39,24 @@
|
|
|
39
39
|
"@semantic-release/github": "11.0.1",
|
|
40
40
|
"@semantic-release/npm": "12.0.1",
|
|
41
41
|
"@semantic-release/release-notes-generator": "14.0.3",
|
|
42
|
+
"@swc/core": "^1.10.18",
|
|
43
|
+
"@swc/jest": "^0.2.37",
|
|
42
44
|
"@types/jest": "29.5.14",
|
|
43
|
-
"@types/node": "22.13.
|
|
44
|
-
"@types/sinon": "17.0.
|
|
45
|
-
"chai": "5.
|
|
45
|
+
"@types/node": "22.13.11",
|
|
46
|
+
"@types/sinon": "17.0.4",
|
|
47
|
+
"chai": "5.2.0",
|
|
48
|
+
"cross-env": "7.0.3",
|
|
46
49
|
"eslint": "8.57.1",
|
|
47
50
|
"eslint-config-prettier": "9.1.0",
|
|
48
51
|
"eslint-plugin-jest": "27.9.0",
|
|
49
52
|
"eslint-plugin-prettier": "5.2.3",
|
|
50
53
|
"husky": "9.1.7",
|
|
51
54
|
"jest": "29.7.0",
|
|
52
|
-
"lint-staged": "15.
|
|
53
|
-
"prettier": "3.5.
|
|
55
|
+
"lint-staged": "15.5.0",
|
|
56
|
+
"prettier": "3.5.3",
|
|
54
57
|
"semantic-release": "24.2.3",
|
|
55
|
-
"sinon": "19.0.
|
|
56
|
-
"
|
|
57
|
-
"typescript": "5.7.3",
|
|
58
|
+
"sinon": "19.0.4",
|
|
59
|
+
"typescript": "5.8.2",
|
|
58
60
|
"typescript-eslint": "7.18.0"
|
|
59
61
|
},
|
|
60
62
|
"keywords": [
|