@teammy/server 0.2.20 → 0.2.22
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/dist/main.js +8784 -7601
- package/dist/web/assets/Assistant-Dm68Y4gs.js +1 -0
- package/dist/web/assets/Computers-BtcIsnDD.css +1 -0
- package/dist/web/assets/Computers-mf4P8Wjw.js +13 -0
- package/dist/web/assets/{Conversation-BjRCD81A.js → Conversation-ClLZZ3fG.js} +1 -1
- package/dist/web/assets/{Dashboard-DmtWx-WI.js → Dashboard-pokwbwJV.js} +1 -1
- package/dist/web/assets/{Dropdown-DXEtBxVr.js → Dropdown-DGFI68Vd.js} +1 -1
- package/dist/web/assets/Files-CtxaCO6n.js +1 -0
- package/dist/web/assets/{Help-BeJ09zt7.js → Help-B_1p7Xir.js} +87 -25
- package/dist/web/assets/Markdown-gPLWRWEJ.js +29 -0
- package/dist/web/assets/{MessageComposer-0eprbRl2.js → MessageComposer-BoOgfyPA.js} +1 -1
- package/dist/web/assets/ResourceLibrary-Cr_Emgq2.js +6 -0
- package/dist/web/assets/{TerminalPane-CEaXud0k.js → TerminalPane-5Gw9ZNxq.js} +2 -2
- package/dist/web/assets/WorkspaceTree-DZ6DN_OX.js +1 -0
- package/dist/web/assets/{file-links-Bo7XBz3i.js → file-links-CoVqmrXg.js} +1 -1
- package/dist/web/assets/index-BZEKT27U.js +10 -0
- package/dist/web/assets/task-links-DTqf18C2.js +1 -0
- package/dist/web/downloads/teammy-inbox-skill.zip +0 -0
- package/dist/web/downloads/teammy-skill.zip +0 -0
- package/dist/web/index.html +2 -2
- package/dist/web/notification-worker.js +126 -0
- package/node_modules/cron-parser/LICENSE +21 -0
- package/node_modules/cron-parser/README.md +437 -0
- package/node_modules/cron-parser/dist/CronDate.js +558 -0
- package/node_modules/cron-parser/dist/CronExpression.js +531 -0
- package/node_modules/cron-parser/dist/CronExpressionParser.js +482 -0
- package/node_modules/cron-parser/dist/CronFieldCollection.js +380 -0
- package/node_modules/cron-parser/dist/CronFileParser.js +92 -0
- package/node_modules/cron-parser/dist/fields/CronDayOfMonth.js +60 -0
- package/node_modules/cron-parser/dist/fields/CronDayOfWeek.js +57 -0
- package/node_modules/cron-parser/dist/fields/CronField.js +222 -0
- package/node_modules/cron-parser/dist/fields/CronHour.js +40 -0
- package/node_modules/cron-parser/dist/fields/CronMinute.js +40 -0
- package/node_modules/cron-parser/dist/fields/CronMonth.js +44 -0
- package/node_modules/cron-parser/dist/fields/CronSecond.js +40 -0
- package/node_modules/cron-parser/dist/fields/index.js +24 -0
- package/node_modules/cron-parser/dist/fields/types.js +2 -0
- package/node_modules/cron-parser/dist/index.js +31 -0
- package/node_modules/cron-parser/dist/types/CronDate.d.ts +293 -0
- package/node_modules/cron-parser/dist/types/CronExpression.d.ts +118 -0
- package/node_modules/cron-parser/dist/types/CronExpressionParser.d.ts +65 -0
- package/node_modules/cron-parser/dist/types/CronFieldCollection.d.ts +153 -0
- package/node_modules/cron-parser/dist/types/CronFileParser.d.ts +30 -0
- package/node_modules/cron-parser/dist/types/fields/CronDayOfMonth.d.ts +33 -0
- package/node_modules/cron-parser/dist/types/fields/CronDayOfWeek.d.ts +31 -0
- package/node_modules/cron-parser/dist/types/fields/CronField.d.ts +136 -0
- package/node_modules/cron-parser/dist/types/fields/CronHour.d.ts +23 -0
- package/node_modules/cron-parser/dist/types/fields/CronMinute.d.ts +23 -0
- package/node_modules/cron-parser/dist/types/fields/CronMonth.d.ts +24 -0
- package/node_modules/cron-parser/dist/types/fields/CronSecond.d.ts +23 -0
- package/node_modules/cron-parser/dist/types/fields/index.d.ts +8 -0
- package/node_modules/cron-parser/dist/types/fields/types.d.ts +18 -0
- package/node_modules/cron-parser/dist/types/index.d.ts +8 -0
- package/node_modules/cron-parser/dist/types/utils/random.d.ts +10 -0
- package/node_modules/cron-parser/dist/utils/random.js +38 -0
- package/node_modules/cron-parser/package.json +117 -0
- package/node_modules/luxon/LICENSE.md +7 -0
- package/node_modules/luxon/README.md +55 -0
- package/node_modules/luxon/build/amd/luxon.js +8741 -0
- package/node_modules/luxon/build/amd/luxon.js.map +1 -0
- package/node_modules/luxon/build/cjs-browser/luxon.js +8739 -0
- package/node_modules/luxon/build/cjs-browser/luxon.js.map +1 -0
- package/node_modules/luxon/build/es6/luxon.mjs +8133 -0
- package/node_modules/luxon/build/es6/luxon.mjs.map +1 -0
- package/node_modules/luxon/build/global/luxon.js +8744 -0
- package/node_modules/luxon/build/global/luxon.js.map +1 -0
- package/node_modules/luxon/build/global/luxon.min.js +1 -0
- package/node_modules/luxon/build/global/luxon.min.js.map +1 -0
- package/node_modules/luxon/build/node/luxon.js +7792 -0
- package/node_modules/luxon/build/node/luxon.js.map +1 -0
- package/node_modules/luxon/package.json +87 -0
- package/node_modules/luxon/src/datetime.js +2603 -0
- package/node_modules/luxon/src/duration.js +1009 -0
- package/node_modules/luxon/src/errors.js +61 -0
- package/node_modules/luxon/src/impl/conversions.js +206 -0
- package/node_modules/luxon/src/impl/diff.js +95 -0
- package/node_modules/luxon/src/impl/digits.js +94 -0
- package/node_modules/luxon/src/impl/english.js +233 -0
- package/node_modules/luxon/src/impl/formats.js +176 -0
- package/node_modules/luxon/src/impl/formatter.js +434 -0
- package/node_modules/luxon/src/impl/invalid.js +14 -0
- package/node_modules/luxon/src/impl/locale.js +569 -0
- package/node_modules/luxon/src/impl/regexParser.js +335 -0
- package/node_modules/luxon/src/impl/tokenParser.js +505 -0
- package/node_modules/luxon/src/impl/util.js +330 -0
- package/node_modules/luxon/src/impl/zoneUtil.js +34 -0
- package/node_modules/luxon/src/info.js +205 -0
- package/node_modules/luxon/src/interval.js +669 -0
- package/node_modules/luxon/src/luxon.js +26 -0
- package/node_modules/luxon/src/package.json +4 -0
- package/node_modules/luxon/src/settings.js +180 -0
- package/node_modules/luxon/src/zone.js +97 -0
- package/node_modules/luxon/src/zones/IANAZone.js +235 -0
- package/node_modules/luxon/src/zones/fixedOffsetZone.js +150 -0
- package/node_modules/luxon/src/zones/invalidZone.js +53 -0
- package/node_modules/luxon/src/zones/systemZone.js +61 -0
- package/package.json +3 -1
- package/dist/web/assets/Assistant-By7rPMl2.js +0 -1
- package/dist/web/assets/Computers-B4ZMJ8tu.js +0 -13
- package/dist/web/assets/Computers-CBnQX-2p.css +0 -1
- package/dist/web/assets/Files-4IxSFpqk.js +0 -1
- package/dist/web/assets/Markdown-DGF8VSqv.js +0 -29
- package/dist/web/assets/ResourceLibrary-rlrdDWGo.js +0 -6
- package/dist/web/assets/WorkspaceTree-CwGvdfr0.js +0 -1
- package/dist/web/assets/index-Cr9kdjwc.js +0 -10
- package/dist/web/assets/task-links-B7fExlHK.js +0 -1
|
@@ -0,0 +1,558 @@
|
|
|
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
|
+
#dstStartLandingHour = null;
|
|
28
|
+
#dstEnd = null;
|
|
29
|
+
/**
|
|
30
|
+
* Constructs a new CronDate instance.
|
|
31
|
+
* @param {CronDate | Date | number | string} [timestamp] - The timestamp to initialize the CronDate with.
|
|
32
|
+
* @param {string} [tz] - The timezone to use for the CronDate.
|
|
33
|
+
*/
|
|
34
|
+
constructor(timestamp, tz) {
|
|
35
|
+
const dateOpts = { zone: tz };
|
|
36
|
+
// Initialize the internal DateTime object based on the type of timestamp provided.
|
|
37
|
+
// 0 is the Unix epoch, not a missing timestamp
|
|
38
|
+
if (!timestamp && timestamp !== 0) {
|
|
39
|
+
this.#date = luxon_1.DateTime.local();
|
|
40
|
+
}
|
|
41
|
+
else if (timestamp instanceof CronDate) {
|
|
42
|
+
this.#date = timestamp.#date;
|
|
43
|
+
this.#dstStart = timestamp.#dstStart;
|
|
44
|
+
this.#dstStartLandingHour = timestamp.#dstStartLandingHour;
|
|
45
|
+
this.#dstEnd = timestamp.#dstEnd;
|
|
46
|
+
}
|
|
47
|
+
else if (timestamp instanceof Date) {
|
|
48
|
+
this.#date = luxon_1.DateTime.fromJSDate(timestamp, dateOpts);
|
|
49
|
+
}
|
|
50
|
+
else if (typeof timestamp === 'number') {
|
|
51
|
+
this.#date = luxon_1.DateTime.fromMillis(timestamp, dateOpts);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this.#date = luxon_1.DateTime.fromISO(timestamp, dateOpts);
|
|
55
|
+
this.#date.isValid || (this.#date = luxon_1.DateTime.fromRFC2822(timestamp, dateOpts));
|
|
56
|
+
this.#date.isValid || (this.#date = luxon_1.DateTime.fromSQL(timestamp, dateOpts));
|
|
57
|
+
this.#date.isValid || (this.#date = luxon_1.DateTime.fromFormat(timestamp, 'EEE, d MMM yyyy HH:mm:ss', dateOpts));
|
|
58
|
+
this.#date.isValid || (this.#date = luxon_1.DateTime.fromHTTP(timestamp, dateOpts));
|
|
59
|
+
}
|
|
60
|
+
// Check for valid DateTime and throw an error if not valid.
|
|
61
|
+
if (!this.#date.isValid) {
|
|
62
|
+
throw new Error(`CronDate: unhandled timestamp: ${timestamp}`);
|
|
63
|
+
}
|
|
64
|
+
// Set the timezone if it is provided and different from the current zone.
|
|
65
|
+
if (tz && tz !== this.#date.zoneName) {
|
|
66
|
+
this.#date = this.#date.setZone(tz);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Determines if the given year is a leap year.
|
|
71
|
+
* @param {number} year - The year to check
|
|
72
|
+
* @returns {boolean} - True if the year is a leap year, false otherwise
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
static #isLeapYear(year) {
|
|
76
|
+
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Returns daylight savings start time.
|
|
80
|
+
* @returns {number | null}
|
|
81
|
+
*/
|
|
82
|
+
get dstStart() {
|
|
83
|
+
return this.#dstStart;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Returns the first existing hour after the skipped window, or null.
|
|
87
|
+
* @returns {number | null}
|
|
88
|
+
*/
|
|
89
|
+
get dstStartLandingHour() {
|
|
90
|
+
return this.#dstStartLandingHour;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Discards the recorded daylight savings start window. The two halves are
|
|
94
|
+
* only meaningful together, so neither is writable on its own.
|
|
95
|
+
*/
|
|
96
|
+
clearDstStart() {
|
|
97
|
+
this.#dstStart = null;
|
|
98
|
+
this.#dstStartLandingHour = null;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Returns daylight savings end time.
|
|
102
|
+
* @returns {number | null}
|
|
103
|
+
*/
|
|
104
|
+
get dstEnd() {
|
|
105
|
+
return this.#dstEnd;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Sets daylight savings end time.
|
|
109
|
+
* @param {number | null} value
|
|
110
|
+
*/
|
|
111
|
+
set dstEnd(value) {
|
|
112
|
+
this.#dstEnd = value;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Adds one year to the current CronDate.
|
|
116
|
+
*/
|
|
117
|
+
addYear() {
|
|
118
|
+
this.#date = this.#date.plus({ years: 1 });
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Adds one month to the current CronDate.
|
|
122
|
+
*/
|
|
123
|
+
addMonth() {
|
|
124
|
+
this.#date = this.#date.plus({ months: 1 }).startOf('month');
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Adds one day to the current CronDate.
|
|
128
|
+
*/
|
|
129
|
+
addDay() {
|
|
130
|
+
this.#date = this.#date.plus({ days: 1 }).startOf('day');
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Adds one hour to the current CronDate.
|
|
134
|
+
*/
|
|
135
|
+
addHour() {
|
|
136
|
+
this.#date = this.#date.plus({ hours: 1 }).startOf('hour');
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Adds one minute to the current CronDate.
|
|
140
|
+
*/
|
|
141
|
+
addMinute() {
|
|
142
|
+
this.#date = this.#date.plus({ minutes: 1 }).startOf('minute');
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Adds one second to the current CronDate.
|
|
146
|
+
*/
|
|
147
|
+
addSecond() {
|
|
148
|
+
this.#date = this.#date.plus({ seconds: 1 });
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Subtracts one year from the current CronDate.
|
|
152
|
+
*/
|
|
153
|
+
subtractYear() {
|
|
154
|
+
this.#date = this.#date.minus({ years: 1 });
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Subtracts one month from the current CronDate.
|
|
158
|
+
* If the month is 1, it will subtract one year instead.
|
|
159
|
+
*/
|
|
160
|
+
subtractMonth() {
|
|
161
|
+
this.#date = this.#date.minus({ months: 1 }).endOf('month').startOf('second');
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Subtracts one day from the current CronDate.
|
|
165
|
+
* If the day is 1, it will subtract one month instead.
|
|
166
|
+
*/
|
|
167
|
+
subtractDay() {
|
|
168
|
+
this.#date = this.#date.minus({ days: 1 }).endOf('day').startOf('second');
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Subtracts one hour from the current CronDate.
|
|
172
|
+
* If the hour is 0, it will subtract one day instead.
|
|
173
|
+
*/
|
|
174
|
+
subtractHour() {
|
|
175
|
+
this.#date = this.#date.minus({ hours: 1 }).endOf('hour').startOf('second');
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Subtracts one minute from the current CronDate.
|
|
179
|
+
* If the minute is 0, it will subtract one hour instead.
|
|
180
|
+
*/
|
|
181
|
+
subtractMinute() {
|
|
182
|
+
this.#date = this.#date.minus({ minutes: 1 }).endOf('minute').startOf('second');
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Subtracts one second from the current CronDate.
|
|
186
|
+
* If the second is 0, it will subtract one minute instead.
|
|
187
|
+
*/
|
|
188
|
+
subtractSecond() {
|
|
189
|
+
this.#date = this.#date.minus({ seconds: 1 });
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Adds a unit of time to the current CronDate.
|
|
193
|
+
* @param {TimeUnit} unit
|
|
194
|
+
*/
|
|
195
|
+
addUnit(unit) {
|
|
196
|
+
switch (unit) {
|
|
197
|
+
case TimeUnit.Year:
|
|
198
|
+
return this.addYear();
|
|
199
|
+
case TimeUnit.Month:
|
|
200
|
+
return this.addMonth();
|
|
201
|
+
case TimeUnit.Day:
|
|
202
|
+
return this.addDay();
|
|
203
|
+
case TimeUnit.Hour:
|
|
204
|
+
return this.addHour();
|
|
205
|
+
case TimeUnit.Minute:
|
|
206
|
+
return this.addMinute();
|
|
207
|
+
case TimeUnit.Second:
|
|
208
|
+
return this.addSecond();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Subtracts a unit of time from the current CronDate.
|
|
213
|
+
* @param {TimeUnit} unit
|
|
214
|
+
*/
|
|
215
|
+
subtractUnit(unit) {
|
|
216
|
+
switch (unit) {
|
|
217
|
+
case TimeUnit.Year:
|
|
218
|
+
return this.subtractYear();
|
|
219
|
+
case TimeUnit.Month:
|
|
220
|
+
return this.subtractMonth();
|
|
221
|
+
case TimeUnit.Day:
|
|
222
|
+
return this.subtractDay();
|
|
223
|
+
case TimeUnit.Hour:
|
|
224
|
+
return this.subtractHour();
|
|
225
|
+
case TimeUnit.Minute:
|
|
226
|
+
return this.subtractMinute();
|
|
227
|
+
case TimeUnit.Second:
|
|
228
|
+
return this.subtractSecond();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Handles a math operation.
|
|
233
|
+
* @param {DateMathOp} verb - {'add' | 'subtract'}
|
|
234
|
+
* @param {TimeUnit} unit - {'year' | 'month' | 'day' | 'hour' | 'minute' | 'second'}
|
|
235
|
+
*/
|
|
236
|
+
invokeDateOperation(verb, unit) {
|
|
237
|
+
if (verb === DateMathOp.Add) {
|
|
238
|
+
this.addUnit(unit);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
if (verb === DateMathOp.Subtract) {
|
|
242
|
+
this.subtractUnit(unit);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
/* istanbul ignore next - this would only happen if an end user call the handleMathOp with an invalid verb */
|
|
246
|
+
throw new Error(`Invalid verb: ${verb}`);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Returns the day.
|
|
250
|
+
* @returns {number}
|
|
251
|
+
*/
|
|
252
|
+
getDate() {
|
|
253
|
+
return this.#date.day;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Returns the year.
|
|
257
|
+
* @returns {number}
|
|
258
|
+
*/
|
|
259
|
+
getFullYear() {
|
|
260
|
+
return this.#date.year;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Returns the day of the week.
|
|
264
|
+
* @returns {number}
|
|
265
|
+
*/
|
|
266
|
+
getDay() {
|
|
267
|
+
const weekday = this.#date.weekday;
|
|
268
|
+
return weekday === 7 ? 0 : weekday;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Returns the month.
|
|
272
|
+
* @returns {number}
|
|
273
|
+
*/
|
|
274
|
+
getMonth() {
|
|
275
|
+
return this.#date.month - 1;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Returns the hour.
|
|
279
|
+
* @returns {number}
|
|
280
|
+
*/
|
|
281
|
+
getHours() {
|
|
282
|
+
return this.#date.hour;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Returns the minutes.
|
|
286
|
+
* @returns {number}
|
|
287
|
+
*/
|
|
288
|
+
getMinutes() {
|
|
289
|
+
return this.#date.minute;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Returns the seconds.
|
|
293
|
+
* @returns {number}
|
|
294
|
+
*/
|
|
295
|
+
getSeconds() {
|
|
296
|
+
return this.#date.second;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Returns the milliseconds.
|
|
300
|
+
* @returns {number}
|
|
301
|
+
*/
|
|
302
|
+
getMilliseconds() {
|
|
303
|
+
return this.#date.millisecond;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Returns the timezone offset from UTC in minutes (e.g. UTC+2 => 120).
|
|
307
|
+
* Useful for detecting DST transition days.
|
|
308
|
+
*
|
|
309
|
+
* @returns {number} UTC offset in minutes
|
|
310
|
+
*/
|
|
311
|
+
getUTCOffset() {
|
|
312
|
+
return this.#date.offset;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Sets the time to the start of the day (00:00:00.000) in the current timezone.
|
|
316
|
+
*/
|
|
317
|
+
setStartOfDay() {
|
|
318
|
+
this.#date = this.#date.startOf('day');
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Sets the time to the end of the day (23:59:59.999) in the current timezone.
|
|
322
|
+
*/
|
|
323
|
+
setEndOfDay() {
|
|
324
|
+
this.#date = this.#date.endOf('day');
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Returns the time.
|
|
328
|
+
* @returns {number}
|
|
329
|
+
*/
|
|
330
|
+
getTime() {
|
|
331
|
+
return this.#date.valueOf();
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Returns the UTC day.
|
|
335
|
+
* @returns {number}
|
|
336
|
+
*/
|
|
337
|
+
getUTCDate() {
|
|
338
|
+
return this.#getUTC().day;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Returns the UTC year.
|
|
342
|
+
* @returns {number}
|
|
343
|
+
*/
|
|
344
|
+
getUTCFullYear() {
|
|
345
|
+
return this.#getUTC().year;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Returns the UTC day of the week.
|
|
349
|
+
* @returns {number}
|
|
350
|
+
*/
|
|
351
|
+
getUTCDay() {
|
|
352
|
+
const weekday = this.#getUTC().weekday;
|
|
353
|
+
return weekday === 7 ? 0 : weekday;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Returns the UTC month.
|
|
357
|
+
* @returns {number}
|
|
358
|
+
*/
|
|
359
|
+
getUTCMonth() {
|
|
360
|
+
return this.#getUTC().month - 1;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Returns the UTC hour.
|
|
364
|
+
* @returns {number}
|
|
365
|
+
*/
|
|
366
|
+
getUTCHours() {
|
|
367
|
+
return this.#getUTC().hour;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Returns the UTC minutes.
|
|
371
|
+
* @returns {number}
|
|
372
|
+
*/
|
|
373
|
+
getUTCMinutes() {
|
|
374
|
+
return this.#getUTC().minute;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Returns the UTC seconds.
|
|
378
|
+
* @returns {number}
|
|
379
|
+
*/
|
|
380
|
+
getUTCSeconds() {
|
|
381
|
+
return this.#getUTC().second;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Returns the UTC milliseconds.
|
|
385
|
+
* @returns {string | null}
|
|
386
|
+
*/
|
|
387
|
+
toISOString() {
|
|
388
|
+
return this.#date.toUTC().toISO();
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Returns the date as a JSON string.
|
|
392
|
+
* @returns {string | null}
|
|
393
|
+
*/
|
|
394
|
+
toJSON() {
|
|
395
|
+
return this.#date.toJSON();
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Sets a date unit, skipping the luxon `set` call when the value does not change.
|
|
399
|
+
*/
|
|
400
|
+
#set(unit, value) {
|
|
401
|
+
if (this.#date[unit] !== value) {
|
|
402
|
+
this.#date = this.#date.set({ [unit]: value });
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Sets the day.
|
|
407
|
+
* @param d
|
|
408
|
+
*/
|
|
409
|
+
setDate(d) {
|
|
410
|
+
this.#set('day', d);
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Sets the year.
|
|
414
|
+
* @param y
|
|
415
|
+
*/
|
|
416
|
+
setFullYear(y) {
|
|
417
|
+
this.#set('year', y);
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Sets the day of the week.
|
|
421
|
+
* @param d
|
|
422
|
+
*/
|
|
423
|
+
setDay(d) {
|
|
424
|
+
this.#set('weekday', d);
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Sets the month.
|
|
428
|
+
* @param m
|
|
429
|
+
*/
|
|
430
|
+
setMonth(m) {
|
|
431
|
+
this.#set('month', m + 1);
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Sets the hour.
|
|
435
|
+
* @param h
|
|
436
|
+
*/
|
|
437
|
+
setHours(h) {
|
|
438
|
+
this.#set('hour', h);
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Sets the minutes.
|
|
442
|
+
* @param m
|
|
443
|
+
*/
|
|
444
|
+
setMinutes(m) {
|
|
445
|
+
this.#set('minute', m);
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Sets the seconds.
|
|
449
|
+
* @param s
|
|
450
|
+
*/
|
|
451
|
+
setSeconds(s) {
|
|
452
|
+
this.#set('second', s);
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Sets the milliseconds.
|
|
456
|
+
* @param s
|
|
457
|
+
*/
|
|
458
|
+
setMilliseconds(s) {
|
|
459
|
+
this.#set('millisecond', s);
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Returns the date as a string.
|
|
463
|
+
* @returns {string}
|
|
464
|
+
*/
|
|
465
|
+
toString() {
|
|
466
|
+
return this.toDate().toString();
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Returns the date as a Date object.
|
|
470
|
+
* @returns {Date}
|
|
471
|
+
*/
|
|
472
|
+
toDate() {
|
|
473
|
+
return this.#date.toJSDate();
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Returns true if the day is the last day of the month.
|
|
477
|
+
* @returns {boolean}
|
|
478
|
+
*/
|
|
479
|
+
isLastDayOfMonth() {
|
|
480
|
+
const { day, month } = this.#date;
|
|
481
|
+
// Special handling for February in leap years
|
|
482
|
+
if (month === 2) {
|
|
483
|
+
const isLeap = CronDate.#isLeapYear(this.#date.year);
|
|
484
|
+
return day === exports.DAYS_IN_MONTH[month - 1] - (isLeap ? 0 : 1);
|
|
485
|
+
}
|
|
486
|
+
// For other months, check against the static map
|
|
487
|
+
return day === exports.DAYS_IN_MONTH[month - 1];
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Returns true if the day is the last weekday of the month.
|
|
491
|
+
* @returns {boolean}
|
|
492
|
+
*/
|
|
493
|
+
isLastWeekdayOfMonth() {
|
|
494
|
+
const { day, month } = this.#date;
|
|
495
|
+
// Get the last day of the current month
|
|
496
|
+
let lastDay;
|
|
497
|
+
if (month === 2) {
|
|
498
|
+
// Special handling for February
|
|
499
|
+
lastDay = exports.DAYS_IN_MONTH[month - 1] - (CronDate.#isLeapYear(this.#date.year) ? 0 : 1);
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
lastDay = exports.DAYS_IN_MONTH[month - 1];
|
|
503
|
+
}
|
|
504
|
+
// Check if the current day is within 7 days of the end of the month
|
|
505
|
+
return day > lastDay - 7;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Primarily for internal use.
|
|
509
|
+
* @param {DateMathOp} op - The operation to perform.
|
|
510
|
+
* @param {TimeUnit} unit - The unit of time to use.
|
|
511
|
+
* @param {number} [hoursLength] - The length of the hours. Used to skip the DST handling when every hour is scheduled.
|
|
512
|
+
*/
|
|
513
|
+
applyDateOperation(op, unit, hoursLength) {
|
|
514
|
+
if (unit === TimeUnit.Month || unit === TimeUnit.Day) {
|
|
515
|
+
this.invokeDateOperation(op, unit);
|
|
516
|
+
// The hours a DST change skipped belong to the day that was left
|
|
517
|
+
this.clearDstStart();
|
|
518
|
+
// Stepping forward lands on 00:00, or on the first hour that exists when a DST change skips midnight
|
|
519
|
+
if (op === DateMathOp.Add && hoursLength !== 24 && this.getHours() > 0) {
|
|
520
|
+
this.#dstStart = 0;
|
|
521
|
+
this.#dstStartLandingHour = this.getHours();
|
|
522
|
+
}
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
const previousHour = this.getHours();
|
|
526
|
+
const previousOffset = this.getUTCOffset();
|
|
527
|
+
this.invokeDateOperation(op, unit);
|
|
528
|
+
const currentHour = this.getHours();
|
|
529
|
+
// Wall-clock hours crossed, modular so a step over midnight measures the
|
|
530
|
+
// same as one within the day.
|
|
531
|
+
const advance = (currentHour - previousHour + 24) % 24;
|
|
532
|
+
// advance >= 2: at least one whole wall-clock hour was skipped, which
|
|
533
|
+
// sub-hour shifts and calendar-day jumps must not qualify as.
|
|
534
|
+
if (op === DateMathOp.Add && this.getUTCOffset() > previousOffset && advance >= 2) {
|
|
535
|
+
if (hoursLength !== 24) {
|
|
536
|
+
// First skipped hour, then the hour landed on. Modulo carries a window
|
|
537
|
+
// that starts at 23:00 over midnight.
|
|
538
|
+
this.#dstStart = (previousHour + 1) % 24;
|
|
539
|
+
this.#dstStartLandingHour = currentHour;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
else if (advance === 0 && this.getMinutes() === 0 && this.getSeconds() === 0) {
|
|
543
|
+
if (hoursLength !== 24) {
|
|
544
|
+
this.dstEnd = currentHour;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Returns the UTC date.
|
|
550
|
+
* @private
|
|
551
|
+
* @returns {DateTime}
|
|
552
|
+
*/
|
|
553
|
+
#getUTC() {
|
|
554
|
+
return this.#date.toUTC();
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
exports.CronDate = CronDate;
|
|
558
|
+
exports.default = CronDate;
|