cron 2.4.3 → 2.4.4
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 +7 -0
- package/README.md +2 -2
- package/lib/time.js +16 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [2.4.4](https://github.com/kelektiv/node-cron/compare/v2.4.3...v2.4.4) (2023-09-25)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### 🐛 Bug Fixes
|
|
5
|
+
|
|
6
|
+
* added fractional offset support ([#685](https://github.com/kelektiv/node-cron/issues/685)) ([ce78478](https://github.com/kelektiv/node-cron/commit/ce784784575b65bd75b8b1a4adda3d8fd42fe1c0))
|
|
7
|
+
|
|
1
8
|
## [2.4.3](https://github.com/kelektiv/node-cron/compare/v2.4.2...v2.4.3) (2023-08-26)
|
|
2
9
|
|
|
3
10
|
|
package/README.md
CHANGED
|
@@ -94,10 +94,10 @@ Parameter Based
|
|
|
94
94
|
- `onTick` - [REQUIRED] - The function to fire at the specified time. If an `onComplete` callback was provided, `onTick` will receive it as an argument. `onTick` may call `onComplete` when it has finished its work.
|
|
95
95
|
- `onComplete` - [OPTIONAL] - A function that will fire when the job is stopped with `job.stop()`, and may also be called by `onTick` at the end of each run.
|
|
96
96
|
- `start` - [OPTIONAL] - Specifies whether to start the job just before exiting the constructor. By default this is set to false. If left at default you will need to call `job.start()` in order to start the job (assuming `job` is the variable you set the cronjob to). This does not immediately fire your `onTick` function, it just gives you more control over the behavior of your jobs.
|
|
97
|
-
- `timeZone` - [OPTIONAL] - Specify the time zone for the execution. This will modify the actual time relative to your time zone. If the time zone is invalid, an error is thrown. By default (if this is omitted) the local time zone will be used. You can check
|
|
97
|
+
- `timeZone` - [OPTIONAL] - Specify the time zone for the execution. This will modify the actual time relative to your time zone. If the time zone is invalid, an error is thrown. By default (if this is omitted) the local time zone will be used. You can check the various time zones format accepted in the [Luxon documentation](https://github.com/moment/luxon/blob/master/docs/zones.md#specifying-a-zone). Note: This parameter supports minutes offsets, e.g. `UTC+5:30`. **Warning**: Probably don't use both `timeZone` and `utcOffset` together or weird things may happen.
|
|
98
98
|
- `context` - [OPTIONAL] - The context within which to execute the onTick method. This defaults to the cronjob itself allowing you to call `this.stop()`. However, if you change this you'll have access to the functions and values within your context object.
|
|
99
99
|
- `runOnInit` - [OPTIONAL] - This will immediately fire your `onTick` function as soon as the requisite initialization has happened. This option is set to `false` by default for backwards compatibility.
|
|
100
|
-
- `utcOffset` - [OPTIONAL] - This allows you to specify the offset of your time zone rather than using the `timeZone` param. This should be an integer
|
|
100
|
+
- `utcOffset` - [OPTIONAL] - This allows you to specify the offset of your time zone rather than using the `timeZone` param. This should be an integer representing the number of minutes offset (like `120` for +2 hours or `-90` for -1.5 hours). **Warning**: Minutes offsets < 60 and >-60 will be treated as an offset in hours. This means a minute offset of `30` means an offset of +30 hours. Use the `timeZone` param in this case. This behavior [is planned to be removed in V3](https://github.com/kelektiv/node-cron/pull/685#issuecomment-1676417917). **Warning**: Probably don't use both `timeZone` and `utcOffset` together or weird things may happen.
|
|
101
101
|
- `unrefTimeout` - [OPTIONAL] - If you have code that keeps the event loop running and want to stop the node process when that finishes regardless of the state of your cronjob, you can do so making use of this parameter. This is off by default and cron will run as if it needs to control the event loop. For more information take a look at [timers#timers_timeout_unref](https://nodejs.org/api/timers.html#timers_timeout_unref) from the NodeJS docs.
|
|
102
102
|
- `start` - Runs your job.
|
|
103
103
|
- `stop` - Stops your job.
|
package/lib/time.js
CHANGED
|
@@ -152,17 +152,26 @@ function CronTime(luxon) {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
if (typeof this.utcOffset !== 'undefined') {
|
|
155
|
-
|
|
155
|
+
const offsetHours = parseInt(
|
|
156
156
|
this.utcOffset >= 60 || this.utcOffset <= -60
|
|
157
157
|
? this.utcOffset / 60
|
|
158
|
-
: this.utcOffset
|
|
159
|
-
|
|
158
|
+
: this.utcOffset
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
const offsetMins =
|
|
162
|
+
this.utcOffset >= 60 || this.utcOffset <= -60
|
|
163
|
+
? Math.abs(this.utcOffset - offsetHours * 60)
|
|
164
|
+
: 0;
|
|
165
|
+
const offsetMinsStr = offsetMins >= 10 ? offsetMins : '0' + offsetMins;
|
|
160
166
|
|
|
161
167
|
let utcZone = 'UTC';
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
168
|
+
|
|
169
|
+
if (parseInt(this.utcOffset) < 0) {
|
|
170
|
+
utcZone += `${
|
|
171
|
+
offsetHours === 0 ? '-0' : offsetHours
|
|
172
|
+
}:${offsetMinsStr}`;
|
|
173
|
+
} else {
|
|
174
|
+
utcZone += `+${offsetHours}:${offsetMinsStr}`;
|
|
166
175
|
}
|
|
167
176
|
|
|
168
177
|
date = date.setZone(utcZone);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cron",
|
|
3
3
|
"description": "Cron jobs for your node",
|
|
4
|
-
"version": "2.4.
|
|
4
|
+
"version": "2.4.4",
|
|
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"
|