@tachybase/module-backup 1.3.18 → 1.3.20

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 (52) hide show
  1. package/dist/client/cron-jobs-table/AutoBackupTable.schema.d.ts +2 -3
  2. package/dist/client/index.js +2 -2
  3. package/dist/externalVersion.js +7 -7
  4. package/dist/node_modules/@hapi/topo/package.json +1 -1
  5. package/dist/node_modules/archiver/package.json +1 -1
  6. package/dist/node_modules/cron-parser/LICENSE +1 -1
  7. package/dist/node_modules/cron-parser/lib/date.js +252 -0
  8. package/dist/node_modules/cron-parser/lib/expression.js +1002 -0
  9. package/dist/node_modules/cron-parser/lib/field_compactor.js +70 -0
  10. package/dist/node_modules/cron-parser/lib/field_stringify.js +58 -0
  11. package/dist/node_modules/cron-parser/lib/parser.js +1 -0
  12. package/dist/node_modules/cron-parser/package.json +1 -1
  13. package/dist/node_modules/cron-parser/types/common.d.ts +131 -0
  14. package/dist/node_modules/cron-parser/types/index.d.ts +45 -0
  15. package/dist/node_modules/cron-parser/types/ts3/index.d.ts +28 -0
  16. package/dist/node_modules/mkdirp/package.json +1 -1
  17. package/dist/node_modules/semver/package.json +1 -1
  18. package/dist/node_modules/yauzl/package.json +1 -1
  19. package/dist/server/server.d.ts +1 -1
  20. package/package.json +12 -12
  21. package/dist/node_modules/cron-parser/dist/CronDate.js +0 -497
  22. package/dist/node_modules/cron-parser/dist/CronExpression.js +0 -376
  23. package/dist/node_modules/cron-parser/dist/CronExpressionParser.js +0 -384
  24. package/dist/node_modules/cron-parser/dist/CronFieldCollection.js +0 -371
  25. package/dist/node_modules/cron-parser/dist/CronFileParser.js +0 -109
  26. package/dist/node_modules/cron-parser/dist/fields/CronDayOfMonth.js +0 -44
  27. package/dist/node_modules/cron-parser/dist/fields/CronDayOfWeek.js +0 -51
  28. package/dist/node_modules/cron-parser/dist/fields/CronField.js +0 -183
  29. package/dist/node_modules/cron-parser/dist/fields/CronHour.js +0 -40
  30. package/dist/node_modules/cron-parser/dist/fields/CronMinute.js +0 -40
  31. package/dist/node_modules/cron-parser/dist/fields/CronMonth.js +0 -44
  32. package/dist/node_modules/cron-parser/dist/fields/CronSecond.js +0 -40
  33. package/dist/node_modules/cron-parser/dist/fields/index.js +0 -24
  34. package/dist/node_modules/cron-parser/dist/fields/types.js +0 -2
  35. package/dist/node_modules/cron-parser/dist/index.js +0 -1
  36. package/dist/node_modules/cron-parser/dist/types/CronDate.d.ts +0 -273
  37. package/dist/node_modules/cron-parser/dist/types/CronExpression.d.ts +0 -110
  38. package/dist/node_modules/cron-parser/dist/types/CronExpressionParser.d.ts +0 -70
  39. package/dist/node_modules/cron-parser/dist/types/CronFieldCollection.d.ts +0 -153
  40. package/dist/node_modules/cron-parser/dist/types/CronFileParser.d.ts +0 -30
  41. package/dist/node_modules/cron-parser/dist/types/fields/CronDayOfMonth.d.ts +0 -25
  42. package/dist/node_modules/cron-parser/dist/types/fields/CronDayOfWeek.d.ts +0 -30
  43. package/dist/node_modules/cron-parser/dist/types/fields/CronField.d.ts +0 -114
  44. package/dist/node_modules/cron-parser/dist/types/fields/CronHour.d.ts +0 -23
  45. package/dist/node_modules/cron-parser/dist/types/fields/CronMinute.d.ts +0 -23
  46. package/dist/node_modules/cron-parser/dist/types/fields/CronMonth.d.ts +0 -24
  47. package/dist/node_modules/cron-parser/dist/types/fields/CronSecond.d.ts +0 -23
  48. package/dist/node_modules/cron-parser/dist/types/fields/index.d.ts +0 -8
  49. package/dist/node_modules/cron-parser/dist/types/fields/types.d.ts +0 -18
  50. package/dist/node_modules/cron-parser/dist/types/index.d.ts +0 -8
  51. package/dist/node_modules/cron-parser/dist/types/utils/random.d.ts +0 -10
  52. package/dist/node_modules/cron-parser/dist/utils/random.js +0 -38
@@ -1 +1 @@
1
- {"name":"semver","version":"7.7.2","description":"The semantic version parser used by npm.","main":"index.js","scripts":{"test":"tap","snap":"tap","lint":"npm run eslint","postlint":"template-oss-check","lintfix":"npm run eslint -- --fix","posttest":"npm run lint","template-oss-apply":"template-oss-apply --force","eslint":"eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""},"devDependencies":{"@npmcli/eslint-config":"^5.0.0","@npmcli/template-oss":"4.24.3","benchmark":"^2.1.4","tap":"^16.0.0"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/npm/node-semver.git"},"bin":{"semver":"bin/semver.js"},"files":["bin/","lib/","classes/","functions/","internal/","ranges/","index.js","preload.js","range.bnf"],"tap":{"timeout":30,"coverage-map":"map.js","nyc-arg":["--exclude","tap-snapshots/**"]},"engines":{"node":">=10"},"author":"GitHub Inc.","templateOSS":{"//@npmcli/template-oss":"This file is partially managed by @npmcli/template-oss. Edits may be overwritten.","version":"4.24.3","engines":">=10","distPaths":["classes/","functions/","internal/","ranges/","index.js","preload.js","range.bnf"],"allowPaths":["/classes/","/functions/","/internal/","/ranges/","/index.js","/preload.js","/range.bnf","/benchmarks"],"publish":"true"},"_lastModified":"2025-07-17T07:47:18.867Z"}
1
+ {"name":"semver","version":"7.7.2","description":"The semantic version parser used by npm.","main":"index.js","scripts":{"test":"tap","snap":"tap","lint":"npm run eslint","postlint":"template-oss-check","lintfix":"npm run eslint -- --fix","posttest":"npm run lint","template-oss-apply":"template-oss-apply --force","eslint":"eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""},"devDependencies":{"@npmcli/eslint-config":"^5.0.0","@npmcli/template-oss":"4.24.3","benchmark":"^2.1.4","tap":"^16.0.0"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/npm/node-semver.git"},"bin":{"semver":"bin/semver.js"},"files":["bin/","lib/","classes/","functions/","internal/","ranges/","index.js","preload.js","range.bnf"],"tap":{"timeout":30,"coverage-map":"map.js","nyc-arg":["--exclude","tap-snapshots/**"]},"engines":{"node":">=10"},"author":"GitHub Inc.","templateOSS":{"//@npmcli/template-oss":"This file is partially managed by @npmcli/template-oss. Edits may be overwritten.","version":"4.24.3","engines":">=10","distPaths":["classes/","functions/","internal/","ranges/","index.js","preload.js","range.bnf"],"allowPaths":["/classes/","/functions/","/internal/","/ranges/","/index.js","/preload.js","/range.bnf","/benchmarks"],"publish":"true"},"_lastModified":"2025-07-24T06:24:57.241Z"}
@@ -1 +1 @@
1
- {"name":"yauzl","version":"3.2.0","description":"yet another unzip library for node","engines":{"node":">=12"},"main":"index.js","scripts":{"test":"node test/test.js"},"repository":{"type":"git","url":"git+https://github.com/thejoshwolfe/yauzl.git"},"keywords":["unzip","zip","stream","archive","file"],"author":"Josh Wolfe <thejoshwolfe@gmail.com>","license":"MIT","bugs":{"url":"https://github.com/thejoshwolfe/yauzl/issues"},"homepage":"https://github.com/thejoshwolfe/yauzl","dependencies":{"buffer-crc32":"~0.2.3","pend":"~1.2.0"},"devDependencies":{"bl":"^6.0.11"},"files":["fd-slicer.js","index.js"],"_lastModified":"2025-07-17T07:47:19.039Z"}
1
+ {"name":"yauzl","version":"3.2.0","description":"yet another unzip library for node","engines":{"node":">=12"},"main":"index.js","scripts":{"test":"node test/test.js"},"repository":{"type":"git","url":"git+https://github.com/thejoshwolfe/yauzl.git"},"keywords":["unzip","zip","stream","archive","file"],"author":"Josh Wolfe <thejoshwolfe@gmail.com>","license":"MIT","bugs":{"url":"https://github.com/thejoshwolfe/yauzl/issues"},"homepage":"https://github.com/thejoshwolfe/yauzl","dependencies":{"buffer-crc32":"~0.2.3","pend":"~1.2.0"},"devDependencies":{"bl":"^6.0.11"},"files":["fd-slicer.js","index.js"],"_lastModified":"2025-07-24T06:24:57.414Z"}
@@ -6,7 +6,7 @@ export default class PluginBackupRestoreServer extends Plugin {
6
6
  private timers;
7
7
  load(): Promise<void>;
8
8
  inspect(cronJobs: AutoBackupModel[]): void;
9
- getNextTime(cronJob: AutoBackupModel, currentDate: Date, nextSecond?: boolean): any;
9
+ getNextTime(cronJob: AutoBackupModel, currentDate: Date, nextSecond?: boolean): number;
10
10
  schedule(cronJob: AutoBackupModel, nextTime: number, toggle?: boolean): void;
11
11
  trigger(cronJobId: number, time: number): Promise<void>;
12
12
  on(cronJob: AutoBackupModel): void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tachybase/module-backup",
3
3
  "displayName": "App backup & restore",
4
- "version": "1.3.18",
4
+ "version": "1.3.20",
5
5
  "description": "Backup and restore applications for scenarios such as application replication, migration, and upgrades.",
6
6
  "keywords": [
7
7
  "System management"
@@ -13,11 +13,11 @@
13
13
  "@hapi/topo": "^6.0.2",
14
14
  "@types/archiver": "^5.3.4",
15
15
  "@types/file-saver": "^2.0.7",
16
- "@types/lodash": "4.17.13",
16
+ "@types/lodash": "4.17.20",
17
17
  "antd": "5.22.5",
18
18
  "archiver": "^5.3.2",
19
19
  "content-disposition": "^0.5.4",
20
- "cron-parser": "5.3.0",
20
+ "cron-parser": "4.9.0",
21
21
  "dayjs": "1.11.13",
22
22
  "decompress": "^4.2.1",
23
23
  "file-saver": "^2.0.5",
@@ -31,17 +31,17 @@
31
31
  "semver": "7.7.2",
32
32
  "tar": "^6.2.1",
33
33
  "yauzl": "^3.2.0",
34
- "@tachybase/components": "1.3.18",
35
- "@tachybase/module-worker-thread": "1.3.18"
34
+ "@tachybase/components": "1.3.20",
35
+ "@tachybase/module-worker-thread": "1.3.20"
36
36
  },
37
37
  "peerDependencies": {
38
- "@tachybase/actions": "1.3.18",
39
- "@tachybase/database": "1.3.18",
40
- "@tachybase/client": "1.3.18",
41
- "@tachybase/test": "1.3.18",
42
- "@tachybase/utils": "1.3.18",
43
- "@tachybase/schema": "1.3.18",
44
- "@tachybase/server": "1.3.18"
38
+ "@tachybase/actions": "1.3.20",
39
+ "@tachybase/client": "1.3.20",
40
+ "@tachybase/database": "1.3.20",
41
+ "@tachybase/server": "1.3.20",
42
+ "@tachybase/test": "1.3.20",
43
+ "@tachybase/schema": "1.3.20",
44
+ "@tachybase/utils": "1.3.20"
45
45
  },
46
46
  "description.zh-CN": "备份和还原应用,可用于应用的复制、迁移、升级等场景。",
47
47
  "displayName.zh-CN": "应用的备份与还原",
@@ -1,497 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CronDate = exports.DAYS_IN_MONTH = exports.DateMathOp = exports.TimeUnit = void 0;
4
- const luxon_1 = require("luxon");
5
- var TimeUnit;
6
- (function (TimeUnit) {
7
- TimeUnit["Second"] = "Second";
8
- TimeUnit["Minute"] = "Minute";
9
- TimeUnit["Hour"] = "Hour";
10
- TimeUnit["Day"] = "Day";
11
- TimeUnit["Month"] = "Month";
12
- TimeUnit["Year"] = "Year";
13
- })(TimeUnit || (exports.TimeUnit = TimeUnit = {}));
14
- var DateMathOp;
15
- (function (DateMathOp) {
16
- DateMathOp["Add"] = "Add";
17
- DateMathOp["Subtract"] = "Subtract";
18
- })(DateMathOp || (exports.DateMathOp = DateMathOp = {}));
19
- exports.DAYS_IN_MONTH = Object.freeze([31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]);
20
- /**
21
- * CronDate class that wraps the Luxon DateTime object to provide
22
- * a consistent API for working with dates and times in the context of cron.
23
- */
24
- class CronDate {
25
- #date;
26
- #dstStart = null;
27
- #dstEnd = null;
28
- /**
29
- * Maps the verb to the appropriate method
30
- */
31
- #verbMap = {
32
- add: {
33
- [TimeUnit.Year]: this.addYear.bind(this),
34
- [TimeUnit.Month]: this.addMonth.bind(this),
35
- [TimeUnit.Day]: this.addDay.bind(this),
36
- [TimeUnit.Hour]: this.addHour.bind(this),
37
- [TimeUnit.Minute]: this.addMinute.bind(this),
38
- [TimeUnit.Second]: this.addSecond.bind(this),
39
- },
40
- subtract: {
41
- [TimeUnit.Year]: this.subtractYear.bind(this),
42
- [TimeUnit.Month]: this.subtractMonth.bind(this),
43
- [TimeUnit.Day]: this.subtractDay.bind(this),
44
- [TimeUnit.Hour]: this.subtractHour.bind(this),
45
- [TimeUnit.Minute]: this.subtractMinute.bind(this),
46
- [TimeUnit.Second]: this.subtractSecond.bind(this),
47
- },
48
- };
49
- /**
50
- * Constructs a new CronDate instance.
51
- * @param {CronDate | Date | number | string} [timestamp] - The timestamp to initialize the CronDate with.
52
- * @param {string} [tz] - The timezone to use for the CronDate.
53
- */
54
- constructor(timestamp, tz) {
55
- const dateOpts = { zone: tz };
56
- // Initialize the internal DateTime object based on the type of timestamp provided.
57
- if (!timestamp) {
58
- this.#date = luxon_1.DateTime.local();
59
- }
60
- else if (timestamp instanceof CronDate) {
61
- this.#date = timestamp.#date;
62
- this.#dstStart = timestamp.#dstStart;
63
- this.#dstEnd = timestamp.#dstEnd;
64
- }
65
- else if (timestamp instanceof Date) {
66
- this.#date = luxon_1.DateTime.fromJSDate(timestamp, dateOpts);
67
- }
68
- else if (typeof timestamp === 'number') {
69
- this.#date = luxon_1.DateTime.fromMillis(timestamp, dateOpts);
70
- }
71
- else {
72
- this.#date = luxon_1.DateTime.fromISO(timestamp, dateOpts);
73
- this.#date.isValid || (this.#date = luxon_1.DateTime.fromRFC2822(timestamp, dateOpts));
74
- this.#date.isValid || (this.#date = luxon_1.DateTime.fromSQL(timestamp, dateOpts));
75
- this.#date.isValid || (this.#date = luxon_1.DateTime.fromFormat(timestamp, 'EEE, d MMM yyyy HH:mm:ss', dateOpts));
76
- }
77
- // Check for valid DateTime and throw an error if not valid.
78
- if (!this.#date.isValid) {
79
- throw new Error(`CronDate: unhandled timestamp: ${timestamp}`);
80
- }
81
- // Set the timezone if it is provided and different from the current zone.
82
- if (tz && tz !== this.#date.zoneName) {
83
- this.#date = this.#date.setZone(tz);
84
- }
85
- }
86
- /**
87
- * Determines if the given year is a leap year.
88
- * @param {number} year - The year to check
89
- * @returns {boolean} - True if the year is a leap year, false otherwise
90
- * @private
91
- */
92
- static #isLeapYear(year) {
93
- return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
94
- }
95
- /**
96
- * Returns daylight savings start time.
97
- * @returns {number | null}
98
- */
99
- get dstStart() {
100
- return this.#dstStart;
101
- }
102
- /**
103
- * Sets daylight savings start time.
104
- * @param {number | null} value
105
- */
106
- set dstStart(value) {
107
- this.#dstStart = value;
108
- }
109
- /**
110
- * Returns daylight savings end time.
111
- * @returns {number | null}
112
- */
113
- get dstEnd() {
114
- return this.#dstEnd;
115
- }
116
- /**
117
- * Sets daylight savings end time.
118
- * @param {number | null} value
119
- */
120
- set dstEnd(value) {
121
- this.#dstEnd = value;
122
- }
123
- /**
124
- * Adds one year to the current CronDate.
125
- */
126
- addYear() {
127
- this.#date = this.#date.plus({ years: 1 });
128
- }
129
- /**
130
- * Adds one month to the current CronDate.
131
- */
132
- addMonth() {
133
- this.#date = this.#date.plus({ months: 1 }).startOf('month');
134
- }
135
- /**
136
- * Adds one day to the current CronDate.
137
- */
138
- addDay() {
139
- this.#date = this.#date.plus({ days: 1 }).startOf('day');
140
- }
141
- /**
142
- * Adds one hour to the current CronDate.
143
- */
144
- addHour() {
145
- this.#date = this.#date.plus({ hours: 1 }).startOf('hour');
146
- }
147
- /**
148
- * Adds one minute to the current CronDate.
149
- */
150
- addMinute() {
151
- this.#date = this.#date.plus({ minutes: 1 }).startOf('minute');
152
- }
153
- /**
154
- * Adds one second to the current CronDate.
155
- */
156
- addSecond() {
157
- this.#date = this.#date.plus({ seconds: 1 });
158
- }
159
- /**
160
- * Subtracts one year from the current CronDate.
161
- */
162
- subtractYear() {
163
- this.#date = this.#date.minus({ years: 1 });
164
- }
165
- /**
166
- * Subtracts one month from the current CronDate.
167
- * If the month is 1, it will subtract one year instead.
168
- */
169
- subtractMonth() {
170
- this.#date = this.#date.minus({ months: 1 }).endOf('month').startOf('second');
171
- }
172
- /**
173
- * Subtracts one day from the current CronDate.
174
- * If the day is 1, it will subtract one month instead.
175
- */
176
- subtractDay() {
177
- this.#date = this.#date.minus({ days: 1 }).endOf('day').startOf('second');
178
- }
179
- /**
180
- * Subtracts one hour from the current CronDate.
181
- * If the hour is 0, it will subtract one day instead.
182
- */
183
- subtractHour() {
184
- this.#date = this.#date.minus({ hours: 1 }).endOf('hour').startOf('second');
185
- }
186
- /**
187
- * Subtracts one minute from the current CronDate.
188
- * If the minute is 0, it will subtract one hour instead.
189
- */
190
- subtractMinute() {
191
- this.#date = this.#date.minus({ minutes: 1 }).endOf('minute').startOf('second');
192
- }
193
- /**
194
- * Subtracts one second from the current CronDate.
195
- * If the second is 0, it will subtract one minute instead.
196
- */
197
- subtractSecond() {
198
- this.#date = this.#date.minus({ seconds: 1 });
199
- }
200
- /**
201
- * Adds a unit of time to the current CronDate.
202
- * @param {TimeUnit} unit
203
- */
204
- addUnit(unit) {
205
- this.#verbMap.add[unit]();
206
- }
207
- /**
208
- * Subtracts a unit of time from the current CronDate.
209
- * @param {TimeUnit} unit
210
- */
211
- subtractUnit(unit) {
212
- this.#verbMap.subtract[unit]();
213
- }
214
- /**
215
- * Handles a math operation.
216
- * @param {DateMathOp} verb - {'add' | 'subtract'}
217
- * @param {TimeUnit} unit - {'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'}
218
- */
219
- invokeDateOperation(verb, unit) {
220
- if (verb === DateMathOp.Add) {
221
- this.addUnit(unit);
222
- return;
223
- }
224
- if (verb === DateMathOp.Subtract) {
225
- this.subtractUnit(unit);
226
- return;
227
- }
228
- /* istanbul ignore next - this would only happen if an end user call the handleMathOp with an invalid verb */
229
- throw new Error(`Invalid verb: ${verb}`);
230
- }
231
- /**
232
- * Returns the day.
233
- * @returns {number}
234
- */
235
- getDate() {
236
- return this.#date.day;
237
- }
238
- /**
239
- * Returns the year.
240
- * @returns {number}
241
- */
242
- getFullYear() {
243
- return this.#date.year;
244
- }
245
- /**
246
- * Returns the day of the week.
247
- * @returns {number}
248
- */
249
- getDay() {
250
- const weekday = this.#date.weekday;
251
- return weekday === 7 ? 0 : weekday;
252
- }
253
- /**
254
- * Returns the month.
255
- * @returns {number}
256
- */
257
- getMonth() {
258
- return this.#date.month - 1;
259
- }
260
- /**
261
- * Returns the hour.
262
- * @returns {number}
263
- */
264
- getHours() {
265
- return this.#date.hour;
266
- }
267
- /**
268
- * Returns the minutes.
269
- * @returns {number}
270
- */
271
- getMinutes() {
272
- return this.#date.minute;
273
- }
274
- /**
275
- * Returns the seconds.
276
- * @returns {number}
277
- */
278
- getSeconds() {
279
- return this.#date.second;
280
- }
281
- /**
282
- * Returns the milliseconds.
283
- * @returns {number}
284
- */
285
- getMilliseconds() {
286
- return this.#date.millisecond;
287
- }
288
- /**
289
- * Returns the time.
290
- * @returns {number}
291
- */
292
- getTime() {
293
- return this.#date.valueOf();
294
- }
295
- /**
296
- * Returns the UTC day.
297
- * @returns {number}
298
- */
299
- getUTCDate() {
300
- return this.#getUTC().day;
301
- }
302
- /**
303
- * Returns the UTC year.
304
- * @returns {number}
305
- */
306
- getUTCFullYear() {
307
- return this.#getUTC().year;
308
- }
309
- /**
310
- * Returns the UTC day of the week.
311
- * @returns {number}
312
- */
313
- getUTCDay() {
314
- const weekday = this.#getUTC().weekday;
315
- return weekday === 7 ? 0 : weekday;
316
- }
317
- /**
318
- * Returns the UTC month.
319
- * @returns {number}
320
- */
321
- getUTCMonth() {
322
- return this.#getUTC().month - 1;
323
- }
324
- /**
325
- * Returns the UTC hour.
326
- * @returns {number}
327
- */
328
- getUTCHours() {
329
- return this.#getUTC().hour;
330
- }
331
- /**
332
- * Returns the UTC minutes.
333
- * @returns {number}
334
- */
335
- getUTCMinutes() {
336
- return this.#getUTC().minute;
337
- }
338
- /**
339
- * Returns the UTC seconds.
340
- * @returns {number}
341
- */
342
- getUTCSeconds() {
343
- return this.#getUTC().second;
344
- }
345
- /**
346
- * Returns the UTC milliseconds.
347
- * @returns {string | null}
348
- */
349
- toISOString() {
350
- return this.#date.toUTC().toISO();
351
- }
352
- /**
353
- * Returns the date as a JSON string.
354
- * @returns {string | null}
355
- */
356
- toJSON() {
357
- return this.#date.toJSON();
358
- }
359
- /**
360
- * Sets the day.
361
- * @param d
362
- */
363
- setDate(d) {
364
- this.#date = this.#date.set({ day: d });
365
- }
366
- /**
367
- * Sets the year.
368
- * @param y
369
- */
370
- setFullYear(y) {
371
- this.#date = this.#date.set({ year: y });
372
- }
373
- /**
374
- * Sets the day of the week.
375
- * @param d
376
- */
377
- setDay(d) {
378
- this.#date = this.#date.set({ weekday: d });
379
- }
380
- /**
381
- * Sets the month.
382
- * @param m
383
- */
384
- setMonth(m) {
385
- this.#date = this.#date.set({ month: m + 1 });
386
- }
387
- /**
388
- * Sets the hour.
389
- * @param h
390
- */
391
- setHours(h) {
392
- this.#date = this.#date.set({ hour: h });
393
- }
394
- /**
395
- * Sets the minutes.
396
- * @param m
397
- */
398
- setMinutes(m) {
399
- this.#date = this.#date.set({ minute: m });
400
- }
401
- /**
402
- * Sets the seconds.
403
- * @param s
404
- */
405
- setSeconds(s) {
406
- this.#date = this.#date.set({ second: s });
407
- }
408
- /**
409
- * Sets the milliseconds.
410
- * @param s
411
- */
412
- setMilliseconds(s) {
413
- this.#date = this.#date.set({ millisecond: s });
414
- }
415
- /**
416
- * Returns the date as a string.
417
- * @returns {string}
418
- */
419
- toString() {
420
- return this.toDate().toString();
421
- }
422
- /**
423
- * Returns the date as a Date object.
424
- * @returns {Date}
425
- */
426
- toDate() {
427
- return this.#date.toJSDate();
428
- }
429
- /**
430
- * Returns true if the day is the last day of the month.
431
- * @returns {boolean}
432
- */
433
- isLastDayOfMonth() {
434
- const { day, month } = this.#date;
435
- // Special handling for February in leap years
436
- if (month === 2) {
437
- const isLeap = CronDate.#isLeapYear(this.#date.year);
438
- return day === exports.DAYS_IN_MONTH[month - 1] - (isLeap ? 0 : 1);
439
- }
440
- // For other months, check against the static map
441
- return day === exports.DAYS_IN_MONTH[month - 1];
442
- }
443
- /**
444
- * Returns true if the day is the last weekday of the month.
445
- * @returns {boolean}
446
- */
447
- isLastWeekdayOfMonth() {
448
- const { day, month } = this.#date;
449
- // Get the last day of the current month
450
- let lastDay;
451
- if (month === 2) {
452
- // Special handling for February
453
- lastDay = exports.DAYS_IN_MONTH[month - 1] - (CronDate.#isLeapYear(this.#date.year) ? 0 : 1);
454
- }
455
- else {
456
- lastDay = exports.DAYS_IN_MONTH[month - 1];
457
- }
458
- // Check if the current day is within 7 days of the end of the month
459
- return day > lastDay - 7;
460
- }
461
- /**
462
- * Primarily for internal use.
463
- * @param {DateMathOp} op - The operation to perform.
464
- * @param {TimeUnit} unit - The unit of time to use.
465
- * @param {number} [hoursLength] - The length of the hours. Required when unit is not month or day.
466
- */
467
- applyDateOperation(op, unit, hoursLength) {
468
- if (unit === TimeUnit.Month || unit === TimeUnit.Day) {
469
- this.invokeDateOperation(op, unit);
470
- return;
471
- }
472
- const previousHour = this.getHours();
473
- this.invokeDateOperation(op, unit);
474
- const currentHour = this.getHours();
475
- const diff = currentHour - previousHour;
476
- if (diff === 2) {
477
- if (hoursLength !== 24) {
478
- this.dstStart = currentHour;
479
- }
480
- }
481
- else if (diff === 0 && this.getMinutes() === 0 && this.getSeconds() === 0) {
482
- if (hoursLength !== 24) {
483
- this.dstEnd = currentHour;
484
- }
485
- }
486
- }
487
- /**
488
- * Returns the UTC date.
489
- * @private
490
- * @returns {DateTime}
491
- */
492
- #getUTC() {
493
- return this.#date.toUTC();
494
- }
495
- }
496
- exports.CronDate = CronDate;
497
- exports.default = CronDate;