@autometa/datetime 0.1.16 → 1.0.0-rc.0
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/README.md +47 -2
- package/dist/dates/clock.d.ts +5 -0
- package/dist/dates/date-factory.d.ts +20 -0
- package/dist/dates/formatted-date-factory.d.ts +23 -0
- package/dist/dates/iso-date-factory.d.ts +23 -0
- package/dist/dates/object.d.ts +28 -0
- package/dist/dates/time-units.d.ts +6 -0
- package/dist/index.cjs +482 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +6 -219
- package/dist/index.js +349 -481
- package/dist/index.js.map +1 -1
- package/dist/shared/phrases.d.ts +2 -0
- package/dist/time/time-diff.d.ts +12 -0
- package/dist/time/time.d.ts +7 -0
- package/package.json +29 -24
- package/.eslintignore +0 -3
- package/.eslintrc.cjs +0 -4
- package/CHANGELOG.md +0 -141
- package/dist/esm/index.js +0 -573
- package/dist/esm/index.js.map +0 -1
- package/dist/index.d.cts +0 -219
- package/tsup.config.ts +0 -14
package/dist/esm/index.js
DELETED
|
@@ -1,573 +0,0 @@
|
|
|
1
|
-
var __accessCheck = (obj, member, msg) => {
|
|
2
|
-
if (!member.has(obj))
|
|
3
|
-
throw TypeError("Cannot " + msg);
|
|
4
|
-
};
|
|
5
|
-
var __privateGet = (obj, member, getter) => {
|
|
6
|
-
__accessCheck(obj, member, "read from private field");
|
|
7
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
8
|
-
};
|
|
9
|
-
var __privateAdd = (obj, member, value) => {
|
|
10
|
-
if (member.has(obj))
|
|
11
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
12
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
13
|
-
};
|
|
14
|
-
var __privateMethod = (obj, member, method) => {
|
|
15
|
-
__accessCheck(obj, member, "access private method");
|
|
16
|
-
return method;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// src/dates/date-factory.ts
|
|
20
|
-
import { camel, convertPhrase, collapse } from "@autometa/phrases";
|
|
21
|
-
|
|
22
|
-
// src/dates/midnight.ts
|
|
23
|
-
function midnight() {
|
|
24
|
-
const date = /* @__PURE__ */ new Date();
|
|
25
|
-
date.setDate(date.getDate() + 1);
|
|
26
|
-
date.setHours(0, 0, 0, 0);
|
|
27
|
-
return date;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// src/dates/date-factory.ts
|
|
31
|
-
import { AutomationError, raise } from "@autometa/errors";
|
|
32
|
-
import { ConfirmDefined, ConfirmLengthAtLeast } from "@autometa/asserters";
|
|
33
|
-
import { isValidDate, isValidISODateString, isValidTime, isValidYearMonth } from "iso-datestring-validator";
|
|
34
|
-
function isTimeShortcut(text) {
|
|
35
|
-
const converted = convertPhrase(text, camel);
|
|
36
|
-
const includes = [
|
|
37
|
-
"now",
|
|
38
|
-
"beforeYesterday",
|
|
39
|
-
"yesterday",
|
|
40
|
-
"today",
|
|
41
|
-
"tomorrow",
|
|
42
|
-
"afterTomorrow",
|
|
43
|
-
"midnight",
|
|
44
|
-
"lastWeek",
|
|
45
|
-
"nextWeek",
|
|
46
|
-
"lastFortnight",
|
|
47
|
-
"nextFortnight"
|
|
48
|
-
].includes(converted);
|
|
49
|
-
if (!includes) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
var _extractTimeFromPhrase, extractTimeFromPhrase_fn, _extractFutureFromPhrase, extractFutureFromPhrase_fn, _extractPastFromPhrase, extractPastFromPhrase_fn, _addYears, addYears_fn, _addMonths, addMonths_fn, _addWeeks, addWeeks_fn, _addDays, addDays_fn, _addSeconds, addSeconds_fn, _addMilliseconds, addMilliseconds_fn, _addHours, addHours_fn, _addMinutes, addMinutes_fn;
|
|
55
|
-
var DateFactory = class {
|
|
56
|
-
constructor() {
|
|
57
|
-
__privateAdd(this, _extractTimeFromPhrase);
|
|
58
|
-
__privateAdd(this, _extractFutureFromPhrase);
|
|
59
|
-
__privateAdd(this, _extractPastFromPhrase);
|
|
60
|
-
__privateAdd(this, _addYears);
|
|
61
|
-
__privateAdd(this, _addMonths);
|
|
62
|
-
__privateAdd(this, _addWeeks);
|
|
63
|
-
__privateAdd(this, _addDays);
|
|
64
|
-
__privateAdd(this, _addSeconds);
|
|
65
|
-
__privateAdd(this, _addMilliseconds);
|
|
66
|
-
__privateAdd(this, _addHours);
|
|
67
|
-
__privateAdd(this, _addMinutes);
|
|
68
|
-
this.phraseMap = /* @__PURE__ */ new Map([
|
|
69
|
-
["now", () => this.make(0, "days")],
|
|
70
|
-
["beforeYesterday", () => this.make(-2, "days")],
|
|
71
|
-
["yesterday", () => this.make(-1, "days")],
|
|
72
|
-
["today", () => this.make(0, "days")],
|
|
73
|
-
["tomorrow", () => this.make(1, "days")],
|
|
74
|
-
["afterTomorrow", () => this.make(2, "days")],
|
|
75
|
-
["nextWeek", () => this.make(7, "days")],
|
|
76
|
-
["lastWeek", () => this.make(-7, "days")],
|
|
77
|
-
["nextFortnight", () => this.make(14, "days")],
|
|
78
|
-
["lastFortnight", () => this.make(-14, "days")],
|
|
79
|
-
["midnight", midnight]
|
|
80
|
-
]);
|
|
81
|
-
}
|
|
82
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
83
|
-
find(name) {
|
|
84
|
-
const result = this.phraseMap.get(name);
|
|
85
|
-
if (result) {
|
|
86
|
-
return result();
|
|
87
|
-
}
|
|
88
|
-
raise(
|
|
89
|
-
`Could not find date shortcut ${name}. Please use a valid date shortcut from the following list: ${Array.from(
|
|
90
|
-
this.phraseMap.keys()
|
|
91
|
-
).join(", ")}`
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
fromPhraseSafe(phrase) {
|
|
95
|
-
const name = convertPhrase(phrase, camel);
|
|
96
|
-
if (isTimeShortcut(name)) {
|
|
97
|
-
if (this.phraseMap.has(name)) {
|
|
98
|
-
return this.phraseMap.get(name)?.call(this);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
const matchDay = __privateMethod(this, _extractTimeFromPhrase, extractTimeFromPhrase_fn).call(this, phrase);
|
|
102
|
-
if (matchDay) {
|
|
103
|
-
return matchDay;
|
|
104
|
-
}
|
|
105
|
-
const first = isValidDate(phrase);
|
|
106
|
-
const second = isValidISODateString(phrase);
|
|
107
|
-
const third = isValidTime(phrase);
|
|
108
|
-
const fourth = isValidYearMonth(phrase);
|
|
109
|
-
if (!first && !second && !third && !fourth) {
|
|
110
|
-
return /* @__PURE__ */ new Date("null");
|
|
111
|
-
}
|
|
112
|
-
const parsed = new Date(phrase);
|
|
113
|
-
if (isNaN(parsed.getTime())) {
|
|
114
|
-
return new Date(Date.parse(phrase));
|
|
115
|
-
}
|
|
116
|
-
return parsed;
|
|
117
|
-
}
|
|
118
|
-
fromPhrase(phrase) {
|
|
119
|
-
const result = this.fromPhraseSafe(phrase);
|
|
120
|
-
if (result) {
|
|
121
|
-
return result;
|
|
122
|
-
}
|
|
123
|
-
raise(
|
|
124
|
-
`Could not parse date from phrase ${phrase}. Please use a valid date string or a phrase from the following list: ${Array.from(
|
|
125
|
-
this.phraseMap.keys()
|
|
126
|
-
).join(", ")}`
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
make(timeOffset, timeunit) {
|
|
130
|
-
const unit = timeunit.endsWith("s") ? timeunit : `${timeunit}s`;
|
|
131
|
-
switch (unit) {
|
|
132
|
-
case "years":
|
|
133
|
-
return __privateMethod(this, _addYears, addYears_fn).call(this, timeOffset);
|
|
134
|
-
case "months":
|
|
135
|
-
return __privateMethod(this, _addMonths, addMonths_fn).call(this, timeOffset);
|
|
136
|
-
case "weeks":
|
|
137
|
-
return __privateMethod(this, _addWeeks, addWeeks_fn).call(this, timeOffset);
|
|
138
|
-
case "days":
|
|
139
|
-
return __privateMethod(this, _addDays, addDays_fn).call(this, timeOffset);
|
|
140
|
-
case "seconds":
|
|
141
|
-
return __privateMethod(this, _addSeconds, addSeconds_fn).call(this, timeOffset);
|
|
142
|
-
case "milliseconds":
|
|
143
|
-
return __privateMethod(this, _addMilliseconds, addMilliseconds_fn).call(this, timeOffset);
|
|
144
|
-
case "hours":
|
|
145
|
-
return __privateMethod(this, _addHours, addHours_fn).call(this, timeOffset);
|
|
146
|
-
case "minutes":
|
|
147
|
-
return __privateMethod(this, _addMinutes, addMinutes_fn).call(this, timeOffset);
|
|
148
|
-
default:
|
|
149
|
-
throw new AutomationError(
|
|
150
|
-
`Invalid timeunit ${timeunit}, options are 'days', 'seconds', 'milliseconds', 'hours', 'minutes'. Non plural equivalents such as 'day' or 'week' are also accepted.`
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
_extractTimeFromPhrase = new WeakSet();
|
|
156
|
-
extractTimeFromPhrase_fn = function(phrase) {
|
|
157
|
-
return __privateMethod(this, _extractFutureFromPhrase, extractFutureFromPhrase_fn).call(this, phrase) ?? __privateMethod(this, _extractPastFromPhrase, extractPastFromPhrase_fn).call(this, phrase);
|
|
158
|
-
};
|
|
159
|
-
_extractFutureFromPhrase = new WeakSet();
|
|
160
|
-
extractFutureFromPhrase_fn = function(phrase) {
|
|
161
|
-
const pastPattern = /^(\d+) (.*)s? from now?/;
|
|
162
|
-
const pastMatch = pastPattern.exec(phrase);
|
|
163
|
-
if (ConfirmDefined(pastMatch) && ConfirmLengthAtLeast(pastMatch, 3)) {
|
|
164
|
-
const [_, value, unit] = pastMatch;
|
|
165
|
-
const timeunit = convertPhrase(unit, collapse);
|
|
166
|
-
return this.make(Number(value), timeunit);
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
_extractPastFromPhrase = new WeakSet();
|
|
170
|
-
extractPastFromPhrase_fn = function(phrase) {
|
|
171
|
-
const pastPattern = /^(\d+) (.*)(s)? ago?/gm;
|
|
172
|
-
const pastMatch = pastPattern.exec(phrase);
|
|
173
|
-
if (ConfirmDefined(pastMatch) && ConfirmLengthAtLeast(pastMatch, 3)) {
|
|
174
|
-
const [_, value, unit] = pastMatch;
|
|
175
|
-
const timeunit = convertPhrase(unit, camel);
|
|
176
|
-
return this.make(-Number(value), timeunit);
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
_addYears = new WeakSet();
|
|
180
|
-
addYears_fn = function(yearsOffset) {
|
|
181
|
-
const date = /* @__PURE__ */ new Date();
|
|
182
|
-
date.setFullYear(date.getFullYear() + yearsOffset);
|
|
183
|
-
return date;
|
|
184
|
-
};
|
|
185
|
-
_addMonths = new WeakSet();
|
|
186
|
-
addMonths_fn = function(monthOffset) {
|
|
187
|
-
const date = /* @__PURE__ */ new Date();
|
|
188
|
-
date.setMonth(date.getMonth() + monthOffset);
|
|
189
|
-
return date;
|
|
190
|
-
};
|
|
191
|
-
_addWeeks = new WeakSet();
|
|
192
|
-
addWeeks_fn = function(weekOffset) {
|
|
193
|
-
const date = /* @__PURE__ */ new Date();
|
|
194
|
-
date.setMonth(date.getMonth() + weekOffset / 4);
|
|
195
|
-
return date;
|
|
196
|
-
};
|
|
197
|
-
_addDays = new WeakSet();
|
|
198
|
-
addDays_fn = function(daysOffset) {
|
|
199
|
-
const date = /* @__PURE__ */ new Date();
|
|
200
|
-
date.setDate(date.getDate() + daysOffset);
|
|
201
|
-
return date;
|
|
202
|
-
};
|
|
203
|
-
_addSeconds = new WeakSet();
|
|
204
|
-
addSeconds_fn = function(secondsOffset) {
|
|
205
|
-
const date = /* @__PURE__ */ new Date();
|
|
206
|
-
date.setSeconds(date.getSeconds() + secondsOffset);
|
|
207
|
-
return date;
|
|
208
|
-
};
|
|
209
|
-
_addMilliseconds = new WeakSet();
|
|
210
|
-
addMilliseconds_fn = function(millisecondsOffset) {
|
|
211
|
-
const date = /* @__PURE__ */ new Date();
|
|
212
|
-
date.setMilliseconds(date.getMilliseconds() + millisecondsOffset);
|
|
213
|
-
return date;
|
|
214
|
-
};
|
|
215
|
-
_addHours = new WeakSet();
|
|
216
|
-
addHours_fn = function(hoursOffset) {
|
|
217
|
-
const date = /* @__PURE__ */ new Date();
|
|
218
|
-
date.setHours(date.getHours() + hoursOffset);
|
|
219
|
-
return date;
|
|
220
|
-
};
|
|
221
|
-
_addMinutes = new WeakSet();
|
|
222
|
-
addMinutes_fn = function(minutesOffset) {
|
|
223
|
-
const date = /* @__PURE__ */ new Date();
|
|
224
|
-
date.setMinutes(date.getMinutes() + minutesOffset);
|
|
225
|
-
return date;
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
// src/dates/iso-date-factory.ts
|
|
229
|
-
var IsoDateFactory = class {
|
|
230
|
-
constructor(dateFactory) {
|
|
231
|
-
this.dateFactory = dateFactory;
|
|
232
|
-
this.phraseMap = /* @__PURE__ */ new Map([
|
|
233
|
-
["beforeYesterday", this.make(-2, "days")],
|
|
234
|
-
["yesterday", this.make(-1, "days")],
|
|
235
|
-
["today", this.make(0, "days")],
|
|
236
|
-
["tomorrow", this.make(1, "days")],
|
|
237
|
-
["afterTomorrow", this.make(2, "days")],
|
|
238
|
-
["nextWeek", this.make(7, "days")],
|
|
239
|
-
["lastWeek", this.make(-7, "days")],
|
|
240
|
-
["nextFortnight", this.make(14, "days")],
|
|
241
|
-
["lastFortnight", this.make(-14, "days")],
|
|
242
|
-
["midnight", midnight().toISOString()]
|
|
243
|
-
]);
|
|
244
|
-
}
|
|
245
|
-
make(daysOffset, timeunit) {
|
|
246
|
-
return this.dateFactory.make(daysOffset, timeunit).toISOString();
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Attempts to parse a phrase into a date.
|
|
250
|
-
* @param phrase
|
|
251
|
-
* @returns
|
|
252
|
-
*/
|
|
253
|
-
fromPhrase(phrase) {
|
|
254
|
-
return this.dateFactory.fromPhrase(phrase)?.toISOString();
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Returns the date and time of the day before yesterday
|
|
258
|
-
*/
|
|
259
|
-
get beforeYesterday() {
|
|
260
|
-
return this.phraseMap.get("beforeYesterday");
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Returns the date and time of yesterday
|
|
264
|
-
*/
|
|
265
|
-
get yesterday() {
|
|
266
|
-
return this.phraseMap.get("yesterday");
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Returns the date and time of today
|
|
270
|
-
*/
|
|
271
|
-
get today() {
|
|
272
|
-
return this.phraseMap.get("today");
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Returns the date and time of tomorrow
|
|
276
|
-
*/
|
|
277
|
-
get tomorrow() {
|
|
278
|
-
return this.phraseMap.get("tomorrow");
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Returns the date and time of the day after tomorrow
|
|
282
|
-
*/
|
|
283
|
-
get afterTomorrow() {
|
|
284
|
-
return this.phraseMap.get("afterTomorrow");
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Returns the date and time of midnight today
|
|
288
|
-
*/
|
|
289
|
-
get midnight() {
|
|
290
|
-
return this.phraseMap.get("midnight");
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Returns the date and time of today 1 week ago
|
|
294
|
-
*/
|
|
295
|
-
get lastWeek() {
|
|
296
|
-
return this.phraseMap.get("lastWeek");
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Returns the date and time of today 1 week from now
|
|
300
|
-
*/
|
|
301
|
-
get nextWeek() {
|
|
302
|
-
return this.phraseMap.get("nextWeek");
|
|
303
|
-
}
|
|
304
|
-
get lastFortnight() {
|
|
305
|
-
return this.phraseMap.get("lastFortnight");
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* Returns the date and time of today 1 fortnight from now
|
|
309
|
-
*/
|
|
310
|
-
get nextFortnight() {
|
|
311
|
-
return this.phraseMap.get("nextFortnight");
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
// src/dates/formatted-date-factory.ts
|
|
316
|
-
var FmtDateFactory = class {
|
|
317
|
-
constructor(dateFactory) {
|
|
318
|
-
this.dateFactory = dateFactory;
|
|
319
|
-
this.phraseMap = /* @__PURE__ */ new Map([
|
|
320
|
-
["beforeYesterday", this.make(-2, "days")],
|
|
321
|
-
["yesterday", this.make(-1, "days")],
|
|
322
|
-
["today", this.make(0, "days")],
|
|
323
|
-
["tomorrow", this.make(1, "days")],
|
|
324
|
-
["afterTomorrow", this.make(2, "days")],
|
|
325
|
-
["nextWeek", this.make(7, "days")],
|
|
326
|
-
["lastWeek", this.make(-7, "days")],
|
|
327
|
-
["nextFortnight", this.make(14, "days")],
|
|
328
|
-
["lastFortnight", this.make(-14, "days")],
|
|
329
|
-
["midnight", midnight().toISOString()]
|
|
330
|
-
]);
|
|
331
|
-
}
|
|
332
|
-
make(daysOffset, timeunit) {
|
|
333
|
-
return this.dateFactory.make(daysOffset, timeunit).toISOString().split("T")[0];
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Attempts to parse a phrase into a date.
|
|
337
|
-
* @param phrase
|
|
338
|
-
* @returns
|
|
339
|
-
*/
|
|
340
|
-
fromPhrase(phrase) {
|
|
341
|
-
return this.dateFactory.fromPhrase(phrase)?.toISOString().split("T")[0];
|
|
342
|
-
}
|
|
343
|
-
/**
|
|
344
|
-
* Returns the date and time of the day before yesterday
|
|
345
|
-
*/
|
|
346
|
-
get beforeYesterday() {
|
|
347
|
-
return this.phraseMap.get("beforeYesterday");
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* Returns the date and time of yesterday
|
|
351
|
-
*/
|
|
352
|
-
get yesterday() {
|
|
353
|
-
return this.phraseMap.get("yesterday");
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Returns the date and time of today
|
|
357
|
-
*/
|
|
358
|
-
get today() {
|
|
359
|
-
return this.phraseMap.get("today");
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* Returns the date and time of tomorrow
|
|
363
|
-
*/
|
|
364
|
-
get tomorrow() {
|
|
365
|
-
return this.phraseMap.get("tomorrow");
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* Returns the date and time of the day after tomorrow
|
|
369
|
-
*/
|
|
370
|
-
get afterTomorrow() {
|
|
371
|
-
return this.phraseMap.get("afterTomorrow");
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* Returns the date and time of midnight today
|
|
375
|
-
*/
|
|
376
|
-
get midnight() {
|
|
377
|
-
return this.phraseMap.get("midnight");
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* Returns the date and time of today 1 week ago
|
|
381
|
-
*/
|
|
382
|
-
get lastWeek() {
|
|
383
|
-
return this.phraseMap.get("lastWeek");
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Returns the date and time of today 1 week from now
|
|
387
|
-
*/
|
|
388
|
-
get nextWeek() {
|
|
389
|
-
return this.phraseMap.get("nextWeek");
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* Returns the date and time of today 1 fortnight ago
|
|
393
|
-
*/
|
|
394
|
-
get lastFortnight() {
|
|
395
|
-
return this.phraseMap.get("lastFortnight");
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* Returns the date and time of today 1 fortnight from now
|
|
399
|
-
*/
|
|
400
|
-
get nextFortnight() {
|
|
401
|
-
return this.phraseMap.get("nextFortnight");
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
|
|
405
|
-
// src/dates/dates.ts
|
|
406
|
-
var _factory, _iso, _fmt;
|
|
407
|
-
var DatesObject = class {
|
|
408
|
-
constructor() {
|
|
409
|
-
__privateAdd(this, _factory, new DateFactory());
|
|
410
|
-
__privateAdd(this, _iso, new IsoDateFactory(__privateGet(this, _factory)));
|
|
411
|
-
__privateAdd(this, _fmt, new FmtDateFactory(__privateGet(this, _factory)));
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* Switches to the ISO factory, which offers an identical interface
|
|
415
|
-
* but returns ISO strings instead of Date objects.
|
|
416
|
-
*
|
|
417
|
-
* Example: `2020-01-01T00:00:00.000Z`
|
|
418
|
-
*/
|
|
419
|
-
get iso() {
|
|
420
|
-
return __privateGet(this, _iso);
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* Switches to the formatted factory, which offers an identical interface
|
|
424
|
-
* but returns formatted strings instead of Date objects.
|
|
425
|
-
*
|
|
426
|
-
* Example: `2020-01-01`
|
|
427
|
-
*/
|
|
428
|
-
get fmt() {
|
|
429
|
-
return __privateGet(this, _fmt);
|
|
430
|
-
}
|
|
431
|
-
/**
|
|
432
|
-
* Returns the current date and time.
|
|
433
|
-
*/
|
|
434
|
-
get now() {
|
|
435
|
-
return __privateGet(this, _factory).find("now");
|
|
436
|
-
}
|
|
437
|
-
/**
|
|
438
|
-
* Returns the date and time of the day before yesterday
|
|
439
|
-
*/
|
|
440
|
-
get beforeYesterday() {
|
|
441
|
-
return __privateGet(this, _factory).find("beforeYesterday");
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* Returns the date and time of yesterday
|
|
445
|
-
*/
|
|
446
|
-
get yesterday() {
|
|
447
|
-
return __privateGet(this, _factory).find("yesterday");
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* Returns the date and time of today
|
|
451
|
-
*/
|
|
452
|
-
get today() {
|
|
453
|
-
return __privateGet(this, _factory).find("today");
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* Returns the date and time of tomorrow
|
|
457
|
-
*/
|
|
458
|
-
get tomorrow() {
|
|
459
|
-
return __privateGet(this, _factory).find("tomorrow");
|
|
460
|
-
}
|
|
461
|
-
/**
|
|
462
|
-
* Returns the date and time of the day after tomorrow
|
|
463
|
-
*/
|
|
464
|
-
get afterTomorrow() {
|
|
465
|
-
return __privateGet(this, _factory).find("afterTomorrow");
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* Returns the date and time of midnight today
|
|
469
|
-
*/
|
|
470
|
-
get midnight() {
|
|
471
|
-
return __privateGet(this, _factory).find("midnight");
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* Returns the date and time of today 1 week ago
|
|
475
|
-
*/
|
|
476
|
-
get lastWeek() {
|
|
477
|
-
return __privateGet(this, _factory).find("lastWeek");
|
|
478
|
-
}
|
|
479
|
-
/**
|
|
480
|
-
* Returns the date and time of today 1 week from now
|
|
481
|
-
*/
|
|
482
|
-
get nextWeek() {
|
|
483
|
-
return __privateGet(this, _factory).find("nextWeek");
|
|
484
|
-
}
|
|
485
|
-
/**
|
|
486
|
-
* Returns the date and time of today 2 weeks ago
|
|
487
|
-
*/
|
|
488
|
-
get lastFortnight() {
|
|
489
|
-
return __privateGet(this, _factory).find("lastFortnight");
|
|
490
|
-
}
|
|
491
|
-
/**
|
|
492
|
-
* Returns the date and time of today 2 weeks from now
|
|
493
|
-
*/
|
|
494
|
-
get nextFortnight() {
|
|
495
|
-
return __privateGet(this, _factory).find("nextFortnight");
|
|
496
|
-
}
|
|
497
|
-
/**
|
|
498
|
-
* Attempts to parse a phrase into a date.
|
|
499
|
-
* @param phrase
|
|
500
|
-
* @returns
|
|
501
|
-
*/
|
|
502
|
-
fromPhrase(phrase) {
|
|
503
|
-
return __privateGet(this, _factory).fromPhrase(phrase);
|
|
504
|
-
}
|
|
505
|
-
/**
|
|
506
|
-
* Attempts to parse a phrase into a date.
|
|
507
|
-
* If the phrase is invalid, it will return an invalid date instead of throwing.
|
|
508
|
-
* @param phrase
|
|
509
|
-
* @returns
|
|
510
|
-
*/
|
|
511
|
-
fromPhraseSafe(phrase) {
|
|
512
|
-
return __privateGet(this, _factory).fromPhraseSafe(phrase);
|
|
513
|
-
}
|
|
514
|
-
make(timeOffset, timeUnit) {
|
|
515
|
-
return __privateGet(this, _factory).make(timeOffset, timeUnit);
|
|
516
|
-
}
|
|
517
|
-
};
|
|
518
|
-
_factory = new WeakMap();
|
|
519
|
-
_iso = new WeakMap();
|
|
520
|
-
_fmt = new WeakMap();
|
|
521
|
-
var Dates = new DatesObject();
|
|
522
|
-
|
|
523
|
-
// src/time/time.ts
|
|
524
|
-
import { AssertKey } from "@autometa/asserters";
|
|
525
|
-
import { convertPhrase as convertPhrase2, lower } from "@autometa/phrases";
|
|
526
|
-
var TimeDiff = class {
|
|
527
|
-
minutes(date1, date2) {
|
|
528
|
-
return this.millis(date1, date2) / 6e4;
|
|
529
|
-
}
|
|
530
|
-
seconds(date1, date2) {
|
|
531
|
-
return this.millis(date1, date2) / 1e3;
|
|
532
|
-
}
|
|
533
|
-
millis(date1, date2) {
|
|
534
|
-
const d1 = new Date(date1).getTime();
|
|
535
|
-
const d2 = new Date(date2).getTime();
|
|
536
|
-
return Math.abs(Math.round(d2 - d1));
|
|
537
|
-
}
|
|
538
|
-
days(date1, date2) {
|
|
539
|
-
return this.millis(date1, date2) / 864e5;
|
|
540
|
-
}
|
|
541
|
-
hours(date1, date2) {
|
|
542
|
-
return this.millis(date1, date2) / 36e5;
|
|
543
|
-
}
|
|
544
|
-
weeks(date1, date2) {
|
|
545
|
-
return this.millis(date1, date2) / 6048e5;
|
|
546
|
-
}
|
|
547
|
-
fromPhrase(phrase) {
|
|
548
|
-
const propertyKey = convertPhrase2(phrase, lower);
|
|
549
|
-
AssertKey(this, propertyKey);
|
|
550
|
-
return this[propertyKey].bind(this);
|
|
551
|
-
}
|
|
552
|
-
};
|
|
553
|
-
var _diff;
|
|
554
|
-
var TimeObject = class {
|
|
555
|
-
constructor() {
|
|
556
|
-
__privateAdd(this, _diff, new TimeDiff());
|
|
557
|
-
}
|
|
558
|
-
get diff() {
|
|
559
|
-
return __privateGet(this, _diff);
|
|
560
|
-
}
|
|
561
|
-
};
|
|
562
|
-
_diff = new WeakMap();
|
|
563
|
-
var Time = new TimeObject();
|
|
564
|
-
export {
|
|
565
|
-
DateFactory,
|
|
566
|
-
Dates,
|
|
567
|
-
FmtDateFactory,
|
|
568
|
-
IsoDateFactory,
|
|
569
|
-
Time,
|
|
570
|
-
TimeDiff,
|
|
571
|
-
TimeObject
|
|
572
|
-
};
|
|
573
|
-
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/dates/date-factory.ts","../../src/dates/midnight.ts","../../src/dates/iso-date-factory.ts","../../src/dates/formatted-date-factory.ts","../../src/dates/dates.ts","../../src/time/time.ts"],"sourcesContent":["import { TimeUnit, camel, convertPhrase, collapse } from \"@autometa/phrases\";\nimport { midnight } from \"./midnight\";\nimport { AutomationError, raise } from \"@autometa/errors\";\nimport { ConfirmDefined, ConfirmLengthAtLeast } from \"@autometa/asserters\";\nimport { isValidDate, isValidISODateString, isValidTime, isValidYearMonth } from \"iso-datestring-validator\";\ntype TimeShortcut =\n | \"now\"\n | \"beforeYesterday\"\n | \"yesterday\"\n | \"today\"\n | \"tomorrow\"\n | \"afterTomorrow\"\n | \"midnight\"\n | \"lastWeek\"\n | \"nextWeek\"\n | \"lastFortnight\"\n | \"nextFortnight\";\n\nfunction isTimeShortcut(text: string): text is TimeShortcut {\n const converted = convertPhrase(text, camel);\n const includes = [\n \"now\",\n \"beforeYesterday\",\n \"yesterday\",\n \"today\",\n \"tomorrow\",\n \"afterTomorrow\",\n \"midnight\",\n \"lastWeek\",\n \"nextWeek\",\n \"lastFortnight\",\n \"nextFortnight\"\n ].includes(converted);\n if (!includes) {\n return false;\n }\n return true;\n}\nexport class DateFactory {\n phraseMap = new Map<TimeShortcut, () => Date>([\n [\"now\", () => this.make(0, \"days\")],\n [\"beforeYesterday\", () => this.make(-2, \"days\")],\n [\"yesterday\", () => this.make(-1, \"days\")],\n [\"today\", () => this.make(0, \"days\")],\n [\"tomorrow\", () => this.make(1, \"days\")],\n [\"afterTomorrow\", () => this.make(2, \"days\")],\n [\"nextWeek\", () => this.make(7, \"days\")],\n [\"lastWeek\", () => this.make(-7, \"days\")],\n [\"nextFortnight\", () => this.make(14, \"days\")],\n [\"lastFortnight\", () => this.make(-14, \"days\")],\n [\"midnight\", midnight]\n ]);\n\n // eslint-disable-next-line @typescript-eslint/ban-types\n find(name: TimeShortcut): Date {\n const result = this.phraseMap.get(name);\n if (result) {\n return result();\n }\n raise(\n `Could not find date shortcut ${name}. Please use a valid date shortcut from the following list: ${Array.from(\n this.phraseMap.keys()\n ).join(\", \")}`\n );\n }\n\n fromPhraseSafe(phrase: string) {\n const name = convertPhrase(phrase, camel);\n if (isTimeShortcut(name)) {\n if (this.phraseMap.has(name)) {\n return this.phraseMap.get(name)?.call(this);\n }\n }\n \n const matchDay = this.#extractTimeFromPhrase(phrase);\n if (matchDay) {\n return matchDay;\n }\n const first = isValidDate(phrase);\n const second = isValidISODateString(phrase);\n const third = isValidTime(phrase);\n const fourth = isValidYearMonth(phrase);\n if (!first && !second && !third && !fourth) {\n return new Date(\"null\");\n }\n const parsed = new Date(phrase);\n if (isNaN(parsed.getTime())) {\n return new Date(Date.parse(phrase));\n }\n return parsed;\n }\n fromPhrase(phrase: string) {\n const result = this.fromPhraseSafe(phrase);\n if (result) {\n return result;\n }\n raise(\n `Could not parse date from phrase ${phrase}. Please use a valid date string or a phrase from the following list: ${Array.from(\n this.phraseMap.keys()\n ).join(\", \")}`\n );\n }\n make(timeOffset: number, timeunit: TimeUnit) {\n const unit = timeunit.endsWith(\"s\") ? timeunit : `${timeunit}s`;\n switch (unit) {\n case \"years\":\n return this.#addYears(timeOffset);\n case \"months\":\n return this.#addMonths(timeOffset);\n case \"weeks\":\n return this.#addWeeks(timeOffset);\n case \"days\":\n return this.#addDays(timeOffset);\n case \"seconds\":\n return this.#addSeconds(timeOffset);\n case \"milliseconds\":\n return this.#addMilliseconds(timeOffset);\n case \"hours\":\n return this.#addHours(timeOffset);\n case \"minutes\":\n return this.#addMinutes(timeOffset);\n default:\n throw new AutomationError(\n `Invalid timeunit ${timeunit}, options are 'days', 'seconds', 'milliseconds', 'hours', 'minutes'. Non plural equivalents such as 'day' or 'week' are also accepted.`\n );\n }\n }\n #extractTimeFromPhrase(phrase: string) {\n return (\n this.#extractFutureFromPhrase(phrase) ??\n this.#extractPastFromPhrase(phrase)\n );\n }\n #extractFutureFromPhrase(phrase: string) {\n const pastPattern = /^(\\d+) (.*)s? from now?/;\n const pastMatch = pastPattern.exec(phrase);\n\n if (ConfirmDefined(pastMatch) && ConfirmLengthAtLeast(pastMatch, 3)) {\n const [_, value, unit] = pastMatch;\n const timeunit = convertPhrase(unit, collapse) as TimeUnit;\n return this.make(Number(value), timeunit);\n }\n }\n #extractPastFromPhrase(phrase: string) {\n const pastPattern = /^(\\d+) (.*)(s)? ago?/gm;\n const pastMatch = pastPattern.exec(phrase);\n if (ConfirmDefined(pastMatch) && ConfirmLengthAtLeast(pastMatch, 3)) {\n const [_, value, unit] = pastMatch;\n const timeunit = convertPhrase(unit, camel) as TimeUnit;\n return this.make(-Number(value), timeunit);\n }\n }\n #addYears(yearsOffset: number) {\n const date = new Date();\n date.setFullYear(date.getFullYear() + yearsOffset);\n return date;\n }\n #addMonths(monthOffset: number) {\n const date = new Date();\n date.setMonth(date.getMonth() + monthOffset);\n return date;\n }\n #addWeeks(weekOffset: number) {\n const date = new Date();\n date.setMonth(date.getMonth() + weekOffset / 4);\n return date;\n }\n #addDays(daysOffset: number) {\n const date = new Date();\n date.setDate(date.getDate() + daysOffset);\n return date;\n }\n\n #addSeconds(secondsOffset: number) {\n const date = new Date();\n date.setSeconds(date.getSeconds() + secondsOffset);\n return date;\n }\n\n #addMilliseconds(millisecondsOffset: number) {\n const date = new Date();\n date.setMilliseconds(date.getMilliseconds() + millisecondsOffset);\n return date;\n }\n #addHours(hoursOffset: number) {\n const date = new Date();\n date.setHours(date.getHours() + hoursOffset);\n return date;\n }\n #addMinutes(minutesOffset: number) {\n const date = new Date();\n date.setMinutes(date.getMinutes() + minutesOffset);\n return date;\n }\n}\n","\nexport function midnight() {\n const date = new Date();\n date.setDate(date.getDate() + 1);\n date.setHours(0, 0, 0, 0);\n return date;\n}\n","import { TimeUnit } from '@autometa/phrases';\nimport { midnight } from './midnight';\nimport { DateFactory } from './date-factory';\n\n\nexport class IsoDateFactory {\n constructor(readonly dateFactory: DateFactory) { }\n phraseMap = new Map<string, string>([\n ['beforeYesterday', this.make(-2, 'days')],\n ['yesterday', this.make(-1, 'days')],\n ['today', this.make(0, 'days')],\n ['tomorrow', this.make(1, 'days')],\n ['afterTomorrow', this.make(2, 'days')],\n ['nextWeek', this.make(7, 'days')],\n ['lastWeek', this.make(-7, 'days')],\n ['nextFortnight', this.make(14, 'days')],\n ['lastFortnight', this.make(-14, 'days')],\n ['midnight', midnight().toISOString()],\n ]);\n make(daysOffset: number, timeunit: TimeUnit) {\n return this.dateFactory.make(daysOffset, timeunit).toISOString();\n }\n\n /**\n * Attempts to parse a phrase into a date.\n * @param phrase\n * @returns\n */\n fromPhrase(phrase: string) {\n return this.dateFactory.fromPhrase(phrase)?.toISOString();\n }\n\n /**\n * Returns the date and time of the day before yesterday\n */\n get beforeYesterday() {\n return this.phraseMap.get('beforeYesterday');\n }\n\n /**\n * Returns the date and time of yesterday\n */\n get yesterday() {\n return this.phraseMap.get('yesterday');\n }\n\n /**\n * Returns the date and time of today\n */\n get today() {\n return this.phraseMap.get('today');\n }\n\n /**\n * Returns the date and time of tomorrow\n */\n get tomorrow() {\n return this.phraseMap.get('tomorrow');\n }\n\n /**\n * Returns the date and time of the day after tomorrow\n */\n get afterTomorrow() {\n return this.phraseMap.get('afterTomorrow');\n }\n\n /**\n * Returns the date and time of midnight today\n */\n get midnight() {\n return this.phraseMap.get('midnight');\n }\n\n /**\n * Returns the date and time of today 1 week ago\n */\n get lastWeek() {\n return this.phraseMap.get('lastWeek');\n }\n\n /**\n * Returns the date and time of today 1 week from now\n */\n get nextWeek() {\n return this.phraseMap.get('nextWeek');\n }\n get lastFortnight() {\n return this.phraseMap.get('lastFortnight');\n }\n\n /**\n * Returns the date and time of today 1 fortnight from now\n */\n get nextFortnight() {\n return this.phraseMap.get('nextFortnight');\n }\n}\n","import { TimeUnit } from '@autometa/phrases';\nimport { DateFactory } from './date-factory';\nimport { midnight } from './midnight';\n\nexport class FmtDateFactory {\n constructor(readonly dateFactory: DateFactory) { }\n phraseMap = new Map<string, string>([\n ['beforeYesterday', this.make(-2, 'days')],\n ['yesterday', this.make(-1, 'days')],\n ['today', this.make(0, 'days')],\n ['tomorrow', this.make(1, 'days')],\n ['afterTomorrow', this.make(2, 'days')],\n ['nextWeek', this.make(7, 'days')],\n ['lastWeek', this.make(-7, 'days')],\n ['nextFortnight', this.make(14, 'days')],\n ['lastFortnight', this.make(-14, 'days')],\n ['midnight', midnight().toISOString()],\n ]);\n\n make(daysOffset: number, timeunit: TimeUnit) {\n return this.dateFactory\n .make(daysOffset, timeunit)\n .toISOString()\n .split('T')[0];\n }\n \n /**\n * Attempts to parse a phrase into a date.\n * @param phrase\n * @returns\n */\n fromPhrase(phrase: string) {\n return this.dateFactory.fromPhrase(phrase)?.toISOString().split('T')[0];\n }\n\n /**\n * Returns the date and time of the day before yesterday\n */\n get beforeYesterday() {\n return this.phraseMap.get('beforeYesterday');\n }\n\n /**\n * Returns the date and time of yesterday\n */\n get yesterday() {\n return this.phraseMap.get('yesterday');\n }\n\n /**\n * Returns the date and time of today\n */\n get today() {\n return this.phraseMap.get('today');\n }\n\n /**\n * Returns the date and time of tomorrow\n */\n get tomorrow() {\n return this.phraseMap.get('tomorrow');\n }\n\n /**\n * Returns the date and time of the day after tomorrow\n */\n get afterTomorrow() {\n return this.phraseMap.get('afterTomorrow');\n }\n\n /**\n * Returns the date and time of midnight today\n */\n get midnight() {\n return this.phraseMap.get('midnight');\n }\n\n /**\n * Returns the date and time of today 1 week ago\n */\n get lastWeek() {\n return this.phraseMap.get('lastWeek');\n }\n\n /**\n * Returns the date and time of today 1 week from now\n */\n get nextWeek() {\n return this.phraseMap.get('nextWeek');\n }\n\n /**\n * Returns the date and time of today 1 fortnight ago\n */\n get lastFortnight() {\n return this.phraseMap.get('lastFortnight');\n }\n\n /**\n * Returns the date and time of today 1 fortnight from now\n */\n get nextFortnight() {\n return this.phraseMap.get('nextFortnight');\n }\n}\n","import { DateFactory } from \"./date-factory\";\nimport { IsoDateFactory } from \"./iso-date-factory\";\nimport { FmtDateFactory } from \"./formatted-date-factory\";\nimport { TimeUnit } from \"@autometa/phrases\";\n\nexport class DatesObject {\n #factory: DateFactory = new DateFactory();\n #iso = new IsoDateFactory(this.#factory);\n #fmt = new FmtDateFactory(this.#factory);\n /**\n * Switches to the ISO factory, which offers an identical interface\n * but returns ISO strings instead of Date objects.\n * \n * Example: `2020-01-01T00:00:00.000Z`\n */\n get iso() {\n return this.#iso;\n }\n\n /**\n * Switches to the formatted factory, which offers an identical interface\n * but returns formatted strings instead of Date objects.\n * \n * Example: `2020-01-01`\n */\n get fmt() {\n return this.#fmt;\n }\n\n /**\n * Returns the current date and time.\n */\n get now() {\n return this.#factory.find(\"now\");\n }\n\n /**\n * Returns the date and time of the day before yesterday\n */\n get beforeYesterday(): Date {\n return this.#factory.find(\"beforeYesterday\");\n }\n \n /**\n * Returns the date and time of yesterday\n */\n get yesterday(): Date {\n return this.#factory.find(\"yesterday\");\n }\n\n /**\n * Returns the date and time of today\n */\n get today(): Date {\n return this.#factory.find(\"today\");\n }\n\n /**\n * Returns the date and time of tomorrow\n */\n get tomorrow(): Date {\n return this.#factory.find(\"tomorrow\");\n }\n\n /**\n * Returns the date and time of the day after tomorrow\n */\n get afterTomorrow(): Date {\n return this.#factory.find(\"afterTomorrow\");\n }\n\n /**\n * Returns the date and time of midnight today\n */\n get midnight(): Date {\n return this.#factory.find(\"midnight\");\n }\n\n /**\n * Returns the date and time of today 1 week ago\n */\n get lastWeek(): Date {\n return this.#factory.find(\"lastWeek\");\n }\n\n /**\n * Returns the date and time of today 1 week from now\n */\n get nextWeek(): Date {\n return this.#factory.find(\"nextWeek\");\n }\n\n /**\n * Returns the date and time of today 2 weeks ago\n */\n get lastFortnight(): Date {\n return this.#factory.find(\"lastFortnight\");\n }\n\n /**\n * Returns the date and time of today 2 weeks from now\n */\n get nextFortnight(): Date {\n return this.#factory.find(\"nextFortnight\");\n }\n\n /**\n * Attempts to parse a phrase into a date.\n * @param phrase \n * @returns \n */\n fromPhrase(phrase: string) {\n return this.#factory.fromPhrase(phrase);\n }\n\n /**\n * Attempts to parse a phrase into a date.\n * If the phrase is invalid, it will return an invalid date instead of throwing.\n * @param phrase \n * @returns \n */\n fromPhraseSafe(phrase: string) {\n return this.#factory.fromPhraseSafe(phrase);\n }\n\n make(timeOffset: number, timeUnit: TimeUnit) {\n return this.#factory.make(timeOffset, timeUnit);\n }\n}\n\n/**\n * Date utility option to easily generate common\n * dates around the current date, like 'today', 'midnight',\n * 'tomorrow', 'nextWeek', etc.\n * \n * The Dates utility also supports certain language phrases\n * that might be natural in Cucumber's gherkin syntax, like\n * 'next week', 'last week', 'next fortnight', etc. as well\n * as more dynamic phrases like `1 day ago`, `2 weeks from now`,\n */\nexport const Dates = new DatesObject();\n","import { AssertKey } from \"@autometa/asserters\";\nimport { convertPhrase, lower } from \"@autometa/phrases\";\ntype TimeDiffFn = (date1: Date, date2: Date) => number;\n\nexport class TimeDiff {\n minutes(date1: Date, date2: Date) {\n return this.millis(date1, date2) / 60000;\n }\n seconds(date1: Date, date2: Date) {\n return this.millis(date1, date2) / 1000;\n }\n millis(date1: Date, date2: Date) {\n const d1 = new Date(date1).getTime();\n const d2 = new Date(date2).getTime();\n return Math.abs(Math.round(d2 - d1));\n }\n days(date1: Date, date2: Date) {\n return this.millis(date1, date2) / 86400000;\n }\n hours(date1: Date, date2: Date) {\n return this.millis(date1, date2) / 3600000;\n }\n weeks(date1: Date, date2: Date) {\n return this.millis(date1, date2) / 604800000;\n }\n fromPhrase(phrase: string): TimeDiffFn {\n const propertyKey = convertPhrase(phrase, lower);\n AssertKey(this, propertyKey);\n return (this[propertyKey] as TimeDiffFn).bind(this);\n }\n}\n\nexport class TimeObject {\n #diff = new TimeDiff();\n get diff() {\n return this.#diff;\n }\n}\n\nexport const Time = new TimeObject();\n"],"m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