1 | (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.chrono = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
2 | "use strict";
|
3 | Object.defineProperty(exports, "__esModule", { value: true });
|
4 | exports.mergeDateTimeComponent = exports.mergeDateTimeResult = void 0;
|
5 | const index_1 = require("../index");
|
6 | function mergeDateTimeResult(dateResult, timeResult) {
|
7 | const result = dateResult.clone();
|
8 | const beginDate = dateResult.start;
|
9 | const beginTime = timeResult.start;
|
10 | result.start = mergeDateTimeComponent(beginDate, beginTime);
|
11 | if (dateResult.end != null || timeResult.end != null) {
|
12 | const endDate = dateResult.end == null ? dateResult.start : dateResult.end;
|
13 | const endTime = timeResult.end == null ? timeResult.start : timeResult.end;
|
14 | const endDateTime = mergeDateTimeComponent(endDate, endTime);
|
15 | if (dateResult.end == null && endDateTime.date().getTime() < result.start.date().getTime()) {
|
16 | if (endDateTime.isCertain("day")) {
|
17 | endDateTime.assign("day", endDateTime.get("day") + 1);
|
18 | }
|
19 | else {
|
20 | endDateTime.imply("day", endDateTime.get("day") + 1);
|
21 | }
|
22 | }
|
23 | result.end = endDateTime;
|
24 | }
|
25 | return result;
|
26 | }
|
27 | exports.mergeDateTimeResult = mergeDateTimeResult;
|
28 | function mergeDateTimeComponent(dateComponent, timeComponent) {
|
29 | const dateTimeComponent = dateComponent.clone();
|
30 | if (timeComponent.isCertain("hour")) {
|
31 | dateTimeComponent.assign("hour", timeComponent.get("hour"));
|
32 | dateTimeComponent.assign("minute", timeComponent.get("minute"));
|
33 | if (timeComponent.isCertain("second")) {
|
34 | dateTimeComponent.assign("second", timeComponent.get("second"));
|
35 | if (timeComponent.isCertain("millisecond")) {
|
36 | dateTimeComponent.assign("millisecond", timeComponent.get("millisecond"));
|
37 | }
|
38 | else {
|
39 | dateTimeComponent.imply("millisecond", timeComponent.get("millisecond"));
|
40 | }
|
41 | }
|
42 | else {
|
43 | dateTimeComponent.imply("second", timeComponent.get("second"));
|
44 | dateTimeComponent.imply("millisecond", timeComponent.get("millisecond"));
|
45 | }
|
46 | }
|
47 | else {
|
48 | dateTimeComponent.imply("hour", timeComponent.get("hour"));
|
49 | dateTimeComponent.imply("minute", timeComponent.get("minute"));
|
50 | dateTimeComponent.imply("second", timeComponent.get("second"));
|
51 | dateTimeComponent.imply("millisecond", timeComponent.get("millisecond"));
|
52 | }
|
53 | if (timeComponent.isCertain("timezoneOffset")) {
|
54 | dateTimeComponent.assign("timezoneOffset", timeComponent.get("timezoneOffset"));
|
55 | }
|
56 | if (timeComponent.isCertain("meridiem")) {
|
57 | dateTimeComponent.assign("meridiem", timeComponent.get("meridiem"));
|
58 | }
|
59 | else if (timeComponent.get("meridiem") != null && dateTimeComponent.get("meridiem") == null) {
|
60 | dateTimeComponent.imply("meridiem", timeComponent.get("meridiem"));
|
61 | }
|
62 | if (dateTimeComponent.get("meridiem") == index_1.Meridiem.PM && dateTimeComponent.get("hour") < 12) {
|
63 | if (timeComponent.isCertain("hour")) {
|
64 | dateTimeComponent.assign("hour", dateTimeComponent.get("hour") + 12);
|
65 | }
|
66 | else {
|
67 | dateTimeComponent.imply("hour", dateTimeComponent.get("hour") + 12);
|
68 | }
|
69 | }
|
70 | return dateTimeComponent;
|
71 | }
|
72 | exports.mergeDateTimeComponent = mergeDateTimeComponent;
|
73 |
|
74 | },{"../index":20}],2:[function(require,module,exports){
|
75 | "use strict";
|
76 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
77 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
78 | };
|
79 | Object.defineProperty(exports, "__esModule", { value: true });
|
80 | exports.toDayJSClosestWeekday = exports.toDayJSWeekday = void 0;
|
81 | const dayjs_1 = __importDefault(require("dayjs"));
|
82 | function toDayJSWeekday(refDate, offset, modifier) {
|
83 | if (!modifier) {
|
84 | return toDayJSClosestWeekday(refDate, offset);
|
85 | }
|
86 | let date = dayjs_1.default(refDate);
|
87 | switch (modifier) {
|
88 | case "this":
|
89 | date = date.day(offset);
|
90 | break;
|
91 | case "next":
|
92 | date = date.day(offset + 7);
|
93 | break;
|
94 | case "last":
|
95 | date = date.day(offset - 7);
|
96 | break;
|
97 | }
|
98 | return date;
|
99 | }
|
100 | exports.toDayJSWeekday = toDayJSWeekday;
|
101 | function toDayJSClosestWeekday(refDate, offset) {
|
102 | let date = dayjs_1.default(refDate);
|
103 | const refOffset = date.day();
|
104 | if (Math.abs(offset - 7 - refOffset) < Math.abs(offset - refOffset)) {
|
105 | date = date.day(offset - 7);
|
106 | }
|
107 | else if (Math.abs(offset + 7 - refOffset) < Math.abs(offset - refOffset)) {
|
108 | date = date.day(offset + 7);
|
109 | }
|
110 | else {
|
111 | date = date.day(offset);
|
112 | }
|
113 | return date;
|
114 | }
|
115 | exports.toDayJSClosestWeekday = toDayJSClosestWeekday;
|
116 |
|
117 | },{"dayjs":93}],3:[function(require,module,exports){
|
118 | "use strict";
|
119 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
120 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
121 | };
|
122 | Object.defineProperty(exports, "__esModule", { value: true });
|
123 | exports.findYearClosestToRef = exports.findMostLikelyADYear = void 0;
|
124 | const dayjs_1 = __importDefault(require("dayjs"));
|
125 | function findMostLikelyADYear(yearNumber) {
|
126 | if (yearNumber < 100) {
|
127 | if (yearNumber > 50) {
|
128 | yearNumber = yearNumber + 1900;
|
129 | }
|
130 | else {
|
131 | yearNumber = yearNumber + 2000;
|
132 | }
|
133 | }
|
134 | return yearNumber;
|
135 | }
|
136 | exports.findMostLikelyADYear = findMostLikelyADYear;
|
137 | function findYearClosestToRef(refDate, day, month) {
|
138 | const refMoment = dayjs_1.default(refDate);
|
139 | let dateMoment = refMoment;
|
140 | dateMoment = dateMoment.month(month - 1);
|
141 | dateMoment = dateMoment.date(day);
|
142 | dateMoment = dateMoment.year(refMoment.year());
|
143 | const nextYear = dateMoment.add(1, "y");
|
144 | const lastYear = dateMoment.add(-1, "y");
|
145 | if (Math.abs(nextYear.diff(refMoment)) < Math.abs(dateMoment.diff(refMoment))) {
|
146 | dateMoment = nextYear;
|
147 | }
|
148 | else if (Math.abs(lastYear.diff(refMoment)) < Math.abs(dateMoment.diff(refMoment))) {
|
149 | dateMoment = lastYear;
|
150 | }
|
151 | return dateMoment.year();
|
152 | }
|
153 | exports.findYearClosestToRef = findYearClosestToRef;
|
154 |
|
155 | },{"dayjs":93}],4:[function(require,module,exports){
|
156 | "use strict";
|
157 | Object.defineProperty(exports, "__esModule", { value: true });
|
158 | exports.ParsingContext = exports.Chrono = void 0;
|
159 | const results_1 = require("./results");
|
160 | const en_1 = require("./locales/en");
|
161 | class Chrono {
|
162 | constructor(configuration) {
|
163 | configuration = configuration || en_1.createCasualConfiguration();
|
164 | this.parsers = [...configuration.parsers];
|
165 | this.refiners = [...configuration.refiners];
|
166 | }
|
167 | clone() {
|
168 | return new Chrono({
|
169 | parsers: [...this.parsers],
|
170 | refiners: [...this.refiners],
|
171 | });
|
172 | }
|
173 | parseDate(text, referenceDate, option) {
|
174 | const results = this.parse(text, referenceDate, option);
|
175 | return results.length > 0 ? results[0].start.date() : null;
|
176 | }
|
177 | parse(text, referenceDate, option) {
|
178 | const context = new ParsingContext(text, referenceDate || new Date(), option || {});
|
179 | let results = [];
|
180 | this.parsers.forEach((parser) => {
|
181 | const parsedResults = Chrono.executeParser(context, parser);
|
182 | results = results.concat(parsedResults);
|
183 | });
|
184 | results.sort((a, b) => {
|
185 | return a.index - b.index;
|
186 | });
|
187 | this.refiners.forEach(function (refiner) {
|
188 | results = refiner.refine(context, results);
|
189 | });
|
190 | return results;
|
191 | }
|
192 | static executeParser(context, parser) {
|
193 | const results = [];
|
194 | const pattern = parser.pattern(context);
|
195 | const originalText = context.text;
|
196 | let remainingText = context.text;
|
197 | let match = pattern.exec(remainingText);
|
198 | while (match) {
|
199 | const index = match.index + originalText.length - remainingText.length;
|
200 | match.index = index;
|
201 | const result = parser.extract(context, match);
|
202 | if (!result) {
|
203 | remainingText = originalText.substring(match.index + 1);
|
204 | match = pattern.exec(remainingText);
|
205 | continue;
|
206 | }
|
207 | let parsedResult = null;
|
208 | if (result instanceof results_1.ParsingResult) {
|
209 | parsedResult = result;
|
210 | }
|
211 | else if (result instanceof results_1.ParsingComponents) {
|
212 | parsedResult = context.createParsingResult(match.index, match[0]);
|
213 | parsedResult.start = result;
|
214 | }
|
215 | else {
|
216 | parsedResult = context.createParsingResult(match.index, match[0], result);
|
217 | }
|
218 | context.debug(() => console.log(`${parser.constructor.name} extracted result ${parsedResult}`));
|
219 | results.push(parsedResult);
|
220 | remainingText = originalText.substring(index + parsedResult.text.length);
|
221 | match = pattern.exec(remainingText);
|
222 | }
|
223 | return results;
|
224 | }
|
225 | }
|
226 | exports.Chrono = Chrono;
|
227 | class ParsingContext {
|
228 | constructor(text, refDate, option) {
|
229 | this.text = text;
|
230 | this.refDate = refDate;
|
231 | this.option = option;
|
232 | }
|
233 | createParsingComponents(components) {
|
234 | if (components instanceof results_1.ParsingComponents) {
|
235 | return components;
|
236 | }
|
237 | return new results_1.ParsingComponents(this.refDate, components);
|
238 | }
|
239 | createParsingResult(index, textOrEndIndex, startComponents, endComponents) {
|
240 | const text = typeof textOrEndIndex === "string" ? textOrEndIndex : this.text.substring(index, textOrEndIndex);
|
241 | const start = startComponents ? this.createParsingComponents(startComponents) : null;
|
242 | const end = endComponents ? this.createParsingComponents(endComponents) : null;
|
243 | return new results_1.ParsingResult(this.refDate, index, text, start, end);
|
244 | }
|
245 | debug(block) {
|
246 | if (this.option.debug) {
|
247 | if (this.option.debug instanceof Function) {
|
248 | this.option.debug(block);
|
249 | }
|
250 | else {
|
251 | const handler = this.option.debug;
|
252 | handler.debug(block);
|
253 | }
|
254 | }
|
255 | }
|
256 | }
|
257 | exports.ParsingContext = ParsingContext;
|
258 |
|
259 | },{"./locales/en":31,"./results":89}],5:[function(require,module,exports){
|
260 | "use strict";
|
261 | Object.defineProperty(exports, "__esModule", { value: true });
|
262 | exports.MergingRefiner = exports.Filter = void 0;
|
263 | class Filter {
|
264 | refine(context, results) {
|
265 | return results.filter((r) => this.isValid(context, r));
|
266 | }
|
267 | }
|
268 | exports.Filter = Filter;
|
269 | class MergingRefiner {
|
270 | refine(context, results) {
|
271 | if (results.length < 2) {
|
272 | return results;
|
273 | }
|
274 | const mergedResults = [];
|
275 | let curResult = results[0];
|
276 | let nextResult = null;
|
277 | for (let i = 1; i < results.length; i++) {
|
278 | nextResult = results[i];
|
279 | const textBetween = context.text.substring(curResult.index + curResult.text.length, nextResult.index);
|
280 | if (!this.shouldMergeResults(textBetween, curResult, nextResult, context)) {
|
281 | mergedResults.push(curResult);
|
282 | curResult = nextResult;
|
283 | }
|
284 | else {
|
285 | const left = curResult;
|
286 | const right = nextResult;
|
287 | const mergedResult = this.mergeResults(textBetween, left, right, context);
|
288 | context.debug(() => {
|
289 | console.log(`${this.constructor.name} merged ${left} and ${right} into ${mergedResult}`);
|
290 | });
|
291 | curResult = mergedResult;
|
292 | }
|
293 | }
|
294 | if (curResult != null) {
|
295 | mergedResults.push(curResult);
|
296 | }
|
297 | return mergedResults;
|
298 | }
|
299 | }
|
300 | exports.MergingRefiner = MergingRefiner;
|
301 |
|
302 | },{}],6:[function(require,module,exports){
|
303 | "use strict";
|
304 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
305 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
306 | };
|
307 | Object.defineProperty(exports, "__esModule", { value: true });
|
308 | exports.tonight = exports.tomorrow = exports.yesterday = exports.today = exports.now = void 0;
|
309 | const results_1 = require("../results");
|
310 | const dayjs_1 = __importDefault(require("dayjs"));
|
311 | const dayjs_2 = require("../utils/dayjs");
|
312 | const index_1 = require("../index");
|
313 | function now(refDate) {
|
314 | const targetDate = dayjs_1.default(refDate);
|
315 | const component = new results_1.ParsingComponents(refDate, {});
|
316 | dayjs_2.assignSimilarDate(component, targetDate);
|
317 | dayjs_2.assignSimilarTime(component, targetDate);
|
318 | return component;
|
319 | }
|
320 | exports.now = now;
|
321 | function today(refDate) {
|
322 | const targetDate = dayjs_1.default(refDate);
|
323 | const component = new results_1.ParsingComponents(refDate, {});
|
324 | dayjs_2.assignSimilarDate(component, targetDate);
|
325 | dayjs_2.implySimilarTime(component, targetDate);
|
326 | return component;
|
327 | }
|
328 | exports.today = today;
|
329 | function yesterday(refDate) {
|
330 | let targetDate = dayjs_1.default(refDate);
|
331 | const component = new results_1.ParsingComponents(refDate, {});
|
332 | targetDate = targetDate.add(-1, "day");
|
333 | dayjs_2.assignSimilarDate(component, targetDate);
|
334 | dayjs_2.implySimilarTime(component, targetDate);
|
335 | return component;
|
336 | }
|
337 | exports.yesterday = yesterday;
|
338 | function tomorrow(refDate) {
|
339 | const targetDate = dayjs_1.default(refDate);
|
340 | const component = new results_1.ParsingComponents(refDate, {});
|
341 | dayjs_2.assignTheNextDay(component, targetDate);
|
342 | return component;
|
343 | }
|
344 | exports.tomorrow = tomorrow;
|
345 | function tonight(refDate, implyHour = 22) {
|
346 | const targetDate = dayjs_1.default(refDate);
|
347 | const component = new results_1.ParsingComponents(refDate, {});
|
348 | component.imply("hour", implyHour);
|
349 | component.imply("meridiem", index_1.Meridiem.PM);
|
350 | dayjs_2.assignSimilarDate(component, targetDate);
|
351 | return component;
|
352 | }
|
353 | exports.tonight = tonight;
|
354 |
|
355 | },{"../index":20,"../results":89,"../utils/dayjs":90,"dayjs":93}],7:[function(require,module,exports){
|
356 | "use strict";
|
357 | Object.defineProperty(exports, "__esModule", { value: true });
|
358 | exports.AbstractParserWithWordBoundaryChecking = void 0;
|
359 | class AbstractParserWithWordBoundaryChecking {
|
360 | constructor() {
|
361 | this.cachedInnerPattern = null;
|
362 | this.cachedPattern = null;
|
363 | }
|
364 | pattern(context) {
|
365 | const innerPattern = this.innerPattern(context);
|
366 | if (innerPattern == this.cachedInnerPattern) {
|
367 | return this.cachedPattern;
|
368 | }
|
369 | this.cachedPattern = new RegExp(`(\\W|^)${innerPattern.source}`, innerPattern.flags);
|
370 | this.cachedInnerPattern = innerPattern;
|
371 | return this.cachedPattern;
|
372 | }
|
373 | extract(context, match) {
|
374 | const header = match[1];
|
375 | match.index = match.index + header.length;
|
376 | match[0] = match[0].substring(header.length);
|
377 | for (let i = 2; i < match.length; i++) {
|
378 | match[i - 1] = match[i];
|
379 | }
|
380 | return this.innerExtract(context, match);
|
381 | }
|
382 | }
|
383 | exports.AbstractParserWithWordBoundaryChecking = AbstractParserWithWordBoundaryChecking;
|
384 |
|
385 | },{}],8:[function(require,module,exports){
|
386 | "use strict";
|
387 | Object.defineProperty(exports, "__esModule", { value: true });
|
388 | exports.AbstractTimeExpressionParser = void 0;
|
389 | const index_1 = require("../../index");
|
390 | function primaryTimePattern(primaryPrefix, primarySuffix) {
|
391 | return new RegExp("(^|\\s|T|\\b)" +
|
392 | `${primaryPrefix}` +
|
393 | "(\\d{1,4})" +
|
394 | "(?:" +
|
395 | "(?:\\.|\\:|\\:)" +
|
396 | "(\\d{1,2})" +
|
397 | "(?:" +
|
398 | "(?:\\:|\\:)" +
|
399 | "(\\d{2})" +
|
400 | "(?:\\.(\\d{1,6}))?" +
|
401 | ")?" +
|
402 | ")?" +
|
403 | "(?:\\s*(a\\.m\\.|p\\.m\\.|am?|pm?))?" +
|
404 | `${primarySuffix}`, "i");
|
405 | }
|
406 | function followingTimePatten(followingPhase, followingSuffix) {
|
407 | return new RegExp(`^(${followingPhase})` +
|
408 | "(\\d{1,4})" +
|
409 | "(?:" +
|
410 | "(?:\\.|\\:|\\:)" +
|
411 | "(\\d{1,2})" +
|
412 | "(?:" +
|
413 | "(?:\\.|\\:|\\:)" +
|
414 | "(\\d{1,2})(?:\\.(\\d{1,6}))?" +
|
415 | ")?" +
|
416 | ")?" +
|
417 | "(?:\\s*(a\\.m\\.|p\\.m\\.|am?|pm?))?" +
|
418 | `${followingSuffix}`, "i");
|
419 | }
|
420 | const HOUR_GROUP = 2;
|
421 | const MINUTE_GROUP = 3;
|
422 | const SECOND_GROUP = 4;
|
423 | const MILLI_SECOND_GROUP = 5;
|
424 | const AM_PM_HOUR_GROUP = 6;
|
425 | class AbstractTimeExpressionParser {
|
426 | constructor(strictMode = false) {
|
427 | this.cachedPrimaryPrefix = null;
|
428 | this.cachedPrimarySuffix = null;
|
429 | this.cachedPrimaryTimePattern = null;
|
430 | this.cachedFollowingPhase = null;
|
431 | this.cachedFollowingSuffix = null;
|
432 | this.cachedFollowingTimePatten = null;
|
433 | this.strictMode = strictMode;
|
434 | }
|
435 | primarySuffix() {
|
436 | return "(?=\\W|$)";
|
437 | }
|
438 | followingSuffix() {
|
439 | return "(?=\\W|$)";
|
440 | }
|
441 | pattern(context) {
|
442 | return this.getPrimaryTimePatternThroughCache();
|
443 | }
|
444 | extract(context, match) {
|
445 | const startComponents = this.extractPrimaryTimeComponents(context, match);
|
446 | if (!startComponents) {
|
447 | match.index += match[0].length;
|
448 | return null;
|
449 | }
|
450 | const index = match.index + match[1].length;
|
451 | const text = match[0].substring(match[1].length);
|
452 | const result = context.createParsingResult(index, text, startComponents);
|
453 | match.index += match[0].length;
|
454 | const remainingText = context.text.substring(match.index);
|
455 | const followingPattern = this.getFollowingTimePatternThroughCache();
|
456 | const followingMatch = followingPattern.exec(remainingText);
|
457 | if (!followingMatch ||
|
458 | followingMatch[0].match(/^\s*([+-])\s*\d{3,4}$/)) {
|
459 | return this.checkAndReturnWithoutFollowingPattern(result);
|
460 | }
|
461 | result.end = this.extractFollowingTimeComponents(context, followingMatch, result);
|
462 | if (result.end) {
|
463 | result.text += followingMatch[0];
|
464 | }
|
465 | return this.checkAndReturnWithFollowingPattern(result);
|
466 | }
|
467 | extractPrimaryTimeComponents(context, match, strict = false) {
|
468 | const components = context.createParsingComponents();
|
469 | let minute = 0;
|
470 | let meridiem = null;
|
471 | let hour = parseInt(match[HOUR_GROUP]);
|
472 | if (hour > 100) {
|
473 | if (this.strictMode || match[MINUTE_GROUP] != null) {
|
474 | return null;
|
475 | }
|
476 | minute = hour % 100;
|
477 | hour = Math.floor(hour / 100);
|
478 | }
|
479 | if (hour > 24) {
|
480 | return null;
|
481 | }
|
482 | if (match[MINUTE_GROUP] != null) {
|
483 | if (match[MINUTE_GROUP].length == 1 && !match[AM_PM_HOUR_GROUP]) {
|
484 | return null;
|
485 | }
|
486 | minute = parseInt(match[MINUTE_GROUP]);
|
487 | }
|
488 | if (minute >= 60) {
|
489 | return null;
|
490 | }
|
491 | if (hour > 12) {
|
492 | meridiem = index_1.Meridiem.PM;
|
493 | }
|
494 | if (match[AM_PM_HOUR_GROUP] != null) {
|
495 | if (hour > 12)
|
496 | return null;
|
497 | const ampm = match[AM_PM_HOUR_GROUP][0].toLowerCase();
|
498 | if (ampm == "a") {
|
499 | meridiem = index_1.Meridiem.AM;
|
500 | if (hour == 12) {
|
501 | hour = 0;
|
502 | }
|
503 | }
|
504 | if (ampm == "p") {
|
505 | meridiem = index_1.Meridiem.PM;
|
506 | if (hour != 12) {
|
507 | hour += 12;
|
508 | }
|
509 | }
|
510 | }
|
511 | components.assign("hour", hour);
|
512 | components.assign("minute", minute);
|
513 | if (meridiem !== null) {
|
514 | components.assign("meridiem", meridiem);
|
515 | }
|
516 | else {
|
517 | if (hour < 12) {
|
518 | components.imply("meridiem", index_1.Meridiem.AM);
|
519 | }
|
520 | else {
|
521 | components.imply("meridiem", index_1.Meridiem.PM);
|
522 | }
|
523 | }
|
524 | if (match[MILLI_SECOND_GROUP] != null) {
|
525 | const millisecond = parseInt(match[MILLI_SECOND_GROUP].substring(0, 3));
|
526 | if (millisecond >= 1000)
|
527 | return null;
|
528 | components.assign("millisecond", millisecond);
|
529 | }
|
530 | if (match[SECOND_GROUP] != null) {
|
531 | const second = parseInt(match[SECOND_GROUP]);
|
532 | if (second >= 60)
|
533 | return null;
|
534 | components.assign("second", second);
|
535 | }
|
536 | return components;
|
537 | }
|
538 | extractFollowingTimeComponents(context, match, result) {
|
539 | const components = context.createParsingComponents();
|
540 | if (match[MILLI_SECOND_GROUP] != null) {
|
541 | const millisecond = parseInt(match[MILLI_SECOND_GROUP].substring(0, 3));
|
542 | if (millisecond >= 1000)
|
543 | return null;
|
544 | components.assign("millisecond", millisecond);
|
545 | }
|
546 | if (match[SECOND_GROUP] != null) {
|
547 | const second = parseInt(match[SECOND_GROUP]);
|
548 | if (second >= 60)
|
549 | return null;
|
550 | components.assign("second", second);
|
551 | }
|
552 | let hour = parseInt(match[HOUR_GROUP]);
|
553 | let minute = 0;
|
554 | let meridiem = -1;
|
555 | if (match[MINUTE_GROUP] != null) {
|
556 | minute = parseInt(match[MINUTE_GROUP]);
|
557 | }
|
558 | else if (hour > 100) {
|
559 | minute = hour % 100;
|
560 | hour = Math.floor(hour / 100);
|
561 | }
|
562 | if (minute >= 60 || hour > 24) {
|
563 | return null;
|
564 | }
|
565 | if (hour >= 12) {
|
566 | meridiem = index_1.Meridiem.PM;
|
567 | }
|
568 | if (match[AM_PM_HOUR_GROUP] != null) {
|
569 | if (hour > 12) {
|
570 | return null;
|
571 | }
|
572 | const ampm = match[AM_PM_HOUR_GROUP][0].toLowerCase();
|
573 | if (ampm == "a") {
|
574 | meridiem = index_1.Meridiem.AM;
|
575 | if (hour == 12) {
|
576 | hour = 0;
|
577 | if (!components.isCertain("day")) {
|
578 | components.imply("day", components.get("day") + 1);
|
579 | }
|
580 | }
|
581 | }
|
582 | if (ampm == "p") {
|
583 | meridiem = index_1.Meridiem.PM;
|
584 | if (hour != 12)
|
585 | hour += 12;
|
586 | }
|
587 | if (!result.start.isCertain("meridiem")) {
|
588 | if (meridiem == index_1.Meridiem.AM) {
|
589 | result.start.imply("meridiem", index_1.Meridiem.AM);
|
590 | if (result.start.get("hour") == 12) {
|
591 | result.start.assign("hour", 0);
|
592 | }
|
593 | }
|
594 | else {
|
595 | result.start.imply("meridiem", index_1.Meridiem.PM);
|
596 | if (result.start.get("hour") != 12) {
|
597 | result.start.assign("hour", result.start.get("hour") + 12);
|
598 | }
|
599 | }
|
600 | }
|
601 | }
|
602 | components.assign("hour", hour);
|
603 | components.assign("minute", minute);
|
604 | if (meridiem >= 0) {
|
605 | components.assign("meridiem", meridiem);
|
606 | }
|
607 | else {
|
608 | const startAtPM = result.start.isCertain("meridiem") && result.start.get("hour") > 12;
|
609 | if (startAtPM) {
|
610 | if (result.start.get("hour") - 12 > hour) {
|
611 | components.imply("meridiem", index_1.Meridiem.AM);
|
612 | }
|
613 | else if (hour <= 12) {
|
614 | components.assign("hour", hour + 12);
|
615 | components.assign("meridiem", index_1.Meridiem.PM);
|
616 | }
|
617 | }
|
618 | else if (hour > 12) {
|
619 | components.imply("meridiem", index_1.Meridiem.PM);
|
620 | }
|
621 | else if (hour <= 12) {
|
622 | components.imply("meridiem", index_1.Meridiem.AM);
|
623 | }
|
624 | }
|
625 | if (components.date().getTime() < result.start.date().getTime()) {
|
626 | components.imply("day", components.get("day") + 1);
|
627 | }
|
628 | return components;
|
629 | }
|
630 | checkAndReturnWithoutFollowingPattern(result) {
|
631 | if (result.text.match(/^\d$/)) {
|
632 | return null;
|
633 | }
|
634 | if (result.text.match(/\d[apAP]$/)) {
|
635 | return null;
|
636 | }
|
637 | const endingWithNumbers = result.text.match(/[^\d:.](\d[\d.]+)$/);
|
638 | if (endingWithNumbers) {
|
639 | const endingNumbers = endingWithNumbers[1];
|
640 | if (this.strictMode) {
|
641 | return null;
|
642 | }
|
643 | if (endingNumbers.includes(".") && !endingNumbers.match(/\d(\.\d{2})+$/)) {
|
644 | return null;
|
645 | }
|
646 | const endingNumberVal = parseInt(endingNumbers);
|
647 | if (endingNumberVal > 24) {
|
648 | return null;
|
649 | }
|
650 | }
|
651 | return result;
|
652 | }
|
653 | checkAndReturnWithFollowingPattern(result) {
|
654 | if (result.text.match(/^\d+-\d+$/)) {
|
655 | return null;
|
656 | }
|
657 | const endingWithNumbers = result.text.match(/[^\d:.](\d[\d.]+)\s*-\s*(\d[\d.]+)$/);
|
658 | if (endingWithNumbers) {
|
659 | if (this.strictMode) {
|
660 | return null;
|
661 | }
|
662 | const startingNumbers = endingWithNumbers[1];
|
663 | const endingNumbers = endingWithNumbers[2];
|
664 | if (endingNumbers.includes(".") && !endingNumbers.match(/\d(\.\d{2})+$/)) {
|
665 | return null;
|
666 | }
|
667 | const endingNumberVal = parseInt(endingNumbers);
|
668 | const startingNumberVal = parseInt(startingNumbers);
|
669 | if (endingNumberVal > 24 || startingNumberVal > 24) {
|
670 | return null;
|
671 | }
|
672 | }
|
673 | return result;
|
674 | }
|
675 | getPrimaryTimePatternThroughCache() {
|
676 | const primaryPrefix = this.primaryPrefix();
|
677 | const primarySuffix = this.primarySuffix();
|
678 | if (this.cachedPrimaryPrefix === primaryPrefix && this.cachedPrimarySuffix === primarySuffix) {
|
679 | return this.cachedPrimaryTimePattern;
|
680 | }
|
681 | this.cachedPrimaryTimePattern = primaryTimePattern(primaryPrefix, primarySuffix);
|
682 | this.cachedPrimaryPrefix = primaryPrefix;
|
683 | this.cachedPrimarySuffix = primarySuffix;
|
684 | return this.cachedPrimaryTimePattern;
|
685 | }
|
686 | getFollowingTimePatternThroughCache() {
|
687 | const followingPhase = this.followingPhase();
|
688 | const followingSuffix = this.followingSuffix();
|
689 | if (this.cachedFollowingPhase === followingPhase && this.cachedFollowingSuffix === followingSuffix) {
|
690 | return this.cachedFollowingTimePatten;
|
691 | }
|
692 | this.cachedFollowingTimePatten = followingTimePatten(followingPhase, followingSuffix);
|
693 | this.cachedFollowingPhase = followingPhase;
|
694 | this.cachedFollowingSuffix = followingSuffix;
|
695 | return this.cachedFollowingTimePatten;
|
696 | }
|
697 | }
|
698 | exports.AbstractTimeExpressionParser = AbstractTimeExpressionParser;
|
699 |
|
700 | },{"../../index":20}],9:[function(require,module,exports){
|
701 | "use strict";
|
702 | Object.defineProperty(exports, "__esModule", { value: true });
|
703 | const AbstractParserWithWordBoundary_1 = require("./AbstractParserWithWordBoundary");
|
704 | const PATTERN = new RegExp("([0-9]{4})\\-([0-9]{1,2})\\-([0-9]{1,2})" +
|
705 | "(?:T" +
|
706 | "([0-9]{1,2}):([0-9]{1,2})" +
|
707 | "(?:" +
|
708 | ":([0-9]{1,2})(?:\\.(\\d{1,4}))?" +
|
709 | ")?" +
|
710 | "(?:" +
|
711 | "Z|([+-]\\d{2}):?(\\d{2})?" +
|
712 | ")?" +
|
713 | ")?" +
|
714 | "(?=\\W|$)", "i");
|
715 | const YEAR_NUMBER_GROUP = 1;
|
716 | const MONTH_NUMBER_GROUP = 2;
|
717 | const DATE_NUMBER_GROUP = 3;
|
718 | const HOUR_NUMBER_GROUP = 4;
|
719 | const MINUTE_NUMBER_GROUP = 5;
|
720 | const SECOND_NUMBER_GROUP = 6;
|
721 | const MILLISECOND_NUMBER_GROUP = 7;
|
722 | const TZD_HOUR_OFFSET_GROUP = 8;
|
723 | const TZD_MINUTE_OFFSET_GROUP = 9;
|
724 | class ISOFormatParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
725 | innerPattern() {
|
726 | return PATTERN;
|
727 | }
|
728 | innerExtract(context, match) {
|
729 | const components = {};
|
730 | components["year"] = parseInt(match[YEAR_NUMBER_GROUP]);
|
731 | components["month"] = parseInt(match[MONTH_NUMBER_GROUP]);
|
732 | components["day"] = parseInt(match[DATE_NUMBER_GROUP]);
|
733 | if (match[HOUR_NUMBER_GROUP] != null) {
|
734 | components["hour"] = parseInt(match[HOUR_NUMBER_GROUP]);
|
735 | components["minute"] = parseInt(match[MINUTE_NUMBER_GROUP]);
|
736 | if (match[SECOND_NUMBER_GROUP] != null) {
|
737 | components["second"] = parseInt(match[SECOND_NUMBER_GROUP]);
|
738 | }
|
739 | if (match[MILLISECOND_NUMBER_GROUP] != null) {
|
740 | components["millisecond"] = parseInt(match[MILLISECOND_NUMBER_GROUP]);
|
741 | }
|
742 | if (match[TZD_HOUR_OFFSET_GROUP] == null) {
|
743 | components["timezoneOffset"] = 0;
|
744 | }
|
745 | else {
|
746 | const hourOffset = parseInt(match[TZD_HOUR_OFFSET_GROUP]);
|
747 | let minuteOffset = 0;
|
748 | if (match[TZD_MINUTE_OFFSET_GROUP] != null) {
|
749 | minuteOffset = parseInt(match[TZD_MINUTE_OFFSET_GROUP]);
|
750 | }
|
751 | let offset = hourOffset * 60;
|
752 | if (offset < 0) {
|
753 | offset -= minuteOffset;
|
754 | }
|
755 | else {
|
756 | offset += minuteOffset;
|
757 | }
|
758 | components["timezoneOffset"] = offset;
|
759 | }
|
760 | }
|
761 | return components;
|
762 | }
|
763 | }
|
764 | exports.default = ISOFormatParser;
|
765 |
|
766 | },{"./AbstractParserWithWordBoundary":7}],10:[function(require,module,exports){
|
767 | "use strict";
|
768 | Object.defineProperty(exports, "__esModule", { value: true });
|
769 | const years_1 = require("../../calculation/years");
|
770 | const PATTERN = new RegExp("([^\\d]|^)" +
|
771 | "([0-3]{0,1}[0-9]{1})[\\/\\.\\-]([0-3]{0,1}[0-9]{1})" +
|
772 | "(?:[\\/\\.\\-]([0-9]{4}|[0-9]{2}))?" +
|
773 | "(\\W|$)", "i");
|
774 | const OPENING_GROUP = 1;
|
775 | const ENDING_GROUP = 5;
|
776 | const FIRST_NUMBERS_GROUP = 2;
|
777 | const SECOND_NUMBERS_GROUP = 3;
|
778 | const YEAR_GROUP = 4;
|
779 | class SlashDateFormatParser {
|
780 | constructor(littleEndian) {
|
781 | this.groupNumberMonth = littleEndian ? SECOND_NUMBERS_GROUP : FIRST_NUMBERS_GROUP;
|
782 | this.groupNumberDay = littleEndian ? FIRST_NUMBERS_GROUP : SECOND_NUMBERS_GROUP;
|
783 | }
|
784 | pattern() {
|
785 | return PATTERN;
|
786 | }
|
787 | extract(context, match) {
|
788 | if (match[OPENING_GROUP] == "/" || match[ENDING_GROUP] == "/") {
|
789 | match.index += match[0].length;
|
790 | return;
|
791 | }
|
792 | const index = match.index + match[OPENING_GROUP].length;
|
793 | const text = match[0].substr(match[OPENING_GROUP].length, match[0].length - match[OPENING_GROUP].length - match[ENDING_GROUP].length);
|
794 | if (text.match(/^\d\.\d$/) || text.match(/^\d\.\d{1,2}\.\d{1,2}\s*$/)) {
|
795 | return;
|
796 | }
|
797 | if (!match[YEAR_GROUP] && match[0].indexOf("/") < 0) {
|
798 | return;
|
799 | }
|
800 | const result = context.createParsingResult(index, text);
|
801 | let month = parseInt(match[this.groupNumberMonth]);
|
802 | let day = parseInt(match[this.groupNumberDay]);
|
803 | if (month < 1 || month > 12) {
|
804 | if (month > 12) {
|
805 | if (day >= 1 && day <= 12 && month <= 31) {
|
806 | [day, month] = [month, day];
|
807 | }
|
808 | else {
|
809 | return null;
|
810 | }
|
811 | }
|
812 | }
|
813 | if (day < 1 || day > 31) {
|
814 | return null;
|
815 | }
|
816 | result.start.assign("day", day);
|
817 | result.start.assign("month", month);
|
818 | if (match[YEAR_GROUP]) {
|
819 | const rawYearNumber = parseInt(match[YEAR_GROUP]);
|
820 | const year = years_1.findMostLikelyADYear(rawYearNumber);
|
821 | result.start.assign("year", year);
|
822 | }
|
823 | else {
|
824 | const year = years_1.findYearClosestToRef(context.refDate, day, month);
|
825 | result.start.imply("year", year);
|
826 | }
|
827 | return result;
|
828 | }
|
829 | }
|
830 | exports.default = SlashDateFormatParser;
|
831 |
|
832 | },{"../../calculation/years":3}],11:[function(require,module,exports){
|
833 | "use strict";
|
834 | Object.defineProperty(exports, "__esModule", { value: true });
|
835 | const abstractRefiners_1 = require("../abstractRefiners");
|
836 | class AbstractMergeDateRangeRefiner extends abstractRefiners_1.MergingRefiner {
|
837 | shouldMergeResults(textBetween, currentResult, nextResult) {
|
838 | return !currentResult.end && !nextResult.end && textBetween.match(this.patternBetween()) != null;
|
839 | }
|
840 | mergeResults(textBetween, fromResult, toResult) {
|
841 | if (!fromResult.start.isOnlyWeekdayComponent() && !toResult.start.isOnlyWeekdayComponent()) {
|
842 | toResult.start.getCertainComponents().forEach((key) => {
|
843 | if (!fromResult.start.isCertain(key)) {
|
844 | fromResult.start.assign(key, toResult.start.get(key));
|
845 | }
|
846 | });
|
847 | fromResult.start.getCertainComponents().forEach((key) => {
|
848 | if (!toResult.start.isCertain(key)) {
|
849 | toResult.start.assign(key, fromResult.start.get(key));
|
850 | }
|
851 | });
|
852 | }
|
853 | if (fromResult.start.date().getTime() > toResult.start.date().getTime()) {
|
854 | let fromMoment = fromResult.start.dayjs();
|
855 | let toMoment = toResult.start.dayjs();
|
856 | if (fromResult.start.isOnlyWeekdayComponent() && fromMoment.add(-7, "days").isBefore(toMoment)) {
|
857 | fromMoment = fromMoment.add(-7, "days");
|
858 | fromResult.start.imply("day", fromMoment.date());
|
859 | fromResult.start.imply("month", fromMoment.month() + 1);
|
860 | fromResult.start.imply("year", fromMoment.year());
|
861 | }
|
862 | else if (toResult.start.isOnlyWeekdayComponent() && toMoment.add(7, "days").isAfter(fromMoment)) {
|
863 | toMoment = toMoment.add(7, "days");
|
864 | toResult.start.imply("day", toMoment.date());
|
865 | toResult.start.imply("month", toMoment.month() + 1);
|
866 | toResult.start.imply("year", toMoment.year());
|
867 | }
|
868 | else {
|
869 | [toResult, fromResult] = [fromResult, toResult];
|
870 | }
|
871 | }
|
872 | const result = fromResult.clone();
|
873 | result.start = fromResult.start;
|
874 | result.end = toResult.start;
|
875 | result.index = Math.min(fromResult.index, toResult.index);
|
876 | if (fromResult.index < toResult.index) {
|
877 | result.text = fromResult.text + textBetween + toResult.text;
|
878 | }
|
879 | else {
|
880 | result.text = toResult.text + textBetween + fromResult.text;
|
881 | }
|
882 | return result;
|
883 | }
|
884 | }
|
885 | exports.default = AbstractMergeDateRangeRefiner;
|
886 |
|
887 | },{"../abstractRefiners":5}],12:[function(require,module,exports){
|
888 | "use strict";
|
889 | Object.defineProperty(exports, "__esModule", { value: true });
|
890 | const abstractRefiners_1 = require("../abstractRefiners");
|
891 | const mergingCalculation_1 = require("../../calculation/mergingCalculation");
|
892 | class ENMergeDateTimeRefiner extends abstractRefiners_1.MergingRefiner {
|
893 | shouldMergeResults(textBetween, currentResult, nextResult) {
|
894 | return (((currentResult.start.isOnlyDate() && nextResult.start.isOnlyTime()) ||
|
895 | (nextResult.start.isOnlyDate() && currentResult.start.isOnlyTime())) &&
|
896 | textBetween.match(this.patternBetween()) != null);
|
897 | }
|
898 | mergeResults(textBetween, currentResult, nextResult) {
|
899 | const result = currentResult.start.isOnlyDate()
|
900 | ? mergingCalculation_1.mergeDateTimeResult(currentResult, nextResult)
|
901 | : mergingCalculation_1.mergeDateTimeResult(nextResult, currentResult);
|
902 | result.index = currentResult.index;
|
903 | result.text = currentResult.text + textBetween + nextResult.text;
|
904 | return result;
|
905 | }
|
906 | }
|
907 | exports.default = ENMergeDateTimeRefiner;
|
908 |
|
909 | },{"../../calculation/mergingCalculation":1,"../abstractRefiners":5}],13:[function(require,module,exports){
|
910 | "use strict";
|
911 | Object.defineProperty(exports, "__esModule", { value: true });
|
912 | const TIMEZONE_NAME_PATTERN = new RegExp("^\\s*,?\\s*\\(?([A-Z]{2,4})\\)?(?=\\W|$)", "i");
|
913 | const DEFAULT_TIMEZONE_ABBR_MAP = {
|
914 | ACDT: 630,
|
915 | ACST: 570,
|
916 | ADT: -180,
|
917 | AEDT: 660,
|
918 | AEST: 600,
|
919 | AFT: 270,
|
920 | AKDT: -480,
|
921 | AKST: -540,
|
922 | ALMT: 360,
|
923 | AMST: -180,
|
924 | AMT: -240,
|
925 | ANAST: 720,
|
926 | ANAT: 720,
|
927 | AQTT: 300,
|
928 | ART: -180,
|
929 | AST: -240,
|
930 | AWDT: 540,
|
931 | AWST: 480,
|
932 | AZOST: 0,
|
933 | AZOT: -60,
|
934 | AZST: 300,
|
935 | AZT: 240,
|
936 | BNT: 480,
|
937 | BOT: -240,
|
938 | BRST: -120,
|
939 | BRT: -180,
|
940 | BST: 60,
|
941 | BTT: 360,
|
942 | CAST: 480,
|
943 | CAT: 120,
|
944 | CCT: 390,
|
945 | CDT: -300,
|
946 | CEST: 120,
|
947 | CET: 60,
|
948 | CHADT: 825,
|
949 | CHAST: 765,
|
950 | CKT: -600,
|
951 | CLST: -180,
|
952 | CLT: -240,
|
953 | COT: -300,
|
954 | CST: -360,
|
955 | CVT: -60,
|
956 | CXT: 420,
|
957 | ChST: 600,
|
958 | DAVT: 420,
|
959 | EASST: -300,
|
960 | EAST: -360,
|
961 | EAT: 180,
|
962 | ECT: -300,
|
963 | EDT: -240,
|
964 | EEST: 180,
|
965 | EET: 120,
|
966 | EGST: 0,
|
967 | EGT: -60,
|
968 | EST: -300,
|
969 | ET: -300,
|
970 | FJST: 780,
|
971 | FJT: 720,
|
972 | FKST: -180,
|
973 | FKT: -240,
|
974 | FNT: -120,
|
975 | GALT: -360,
|
976 | GAMT: -540,
|
977 | GET: 240,
|
978 | GFT: -180,
|
979 | GILT: 720,
|
980 | GMT: 0,
|
981 | GST: 240,
|
982 | GYT: -240,
|
983 | HAA: -180,
|
984 | HAC: -300,
|
985 | HADT: -540,
|
986 | HAE: -240,
|
987 | HAP: -420,
|
988 | HAR: -360,
|
989 | HAST: -600,
|
990 | HAT: -90,
|
991 | HAY: -480,
|
992 | HKT: 480,
|
993 | HLV: -210,
|
994 | HNA: -240,
|
995 | HNC: -360,
|
996 | HNE: -300,
|
997 | HNP: -480,
|
998 | HNR: -420,
|
999 | HNT: -150,
|
1000 | HNY: -540,
|
1001 | HOVT: 420,
|
1002 | ICT: 420,
|
1003 | IDT: 180,
|
1004 | IOT: 360,
|
1005 | IRDT: 270,
|
1006 | IRKST: 540,
|
1007 | IRKT: 540,
|
1008 | IRST: 210,
|
1009 | IST: 330,
|
1010 | JST: 540,
|
1011 | KGT: 360,
|
1012 | KRAST: 480,
|
1013 | KRAT: 480,
|
1014 | KST: 540,
|
1015 | KUYT: 240,
|
1016 | LHDT: 660,
|
1017 | LHST: 630,
|
1018 | LINT: 840,
|
1019 | MAGST: 720,
|
1020 | MAGT: 720,
|
1021 | MART: -510,
|
1022 | MAWT: 300,
|
1023 | MDT: -360,
|
1024 | MESZ: 120,
|
1025 | MEZ: 60,
|
1026 | MHT: 720,
|
1027 | MMT: 390,
|
1028 | MSD: 240,
|
1029 | MSK: 240,
|
1030 | MST: -420,
|
1031 | MUT: 240,
|
1032 | MVT: 300,
|
1033 | MYT: 480,
|
1034 | NCT: 660,
|
1035 | NDT: -90,
|
1036 | NFT: 690,
|
1037 | NOVST: 420,
|
1038 | NOVT: 360,
|
1039 | NPT: 345,
|
1040 | NST: -150,
|
1041 | NUT: -660,
|
1042 | NZDT: 780,
|
1043 | NZST: 720,
|
1044 | OMSST: 420,
|
1045 | OMST: 420,
|
1046 | PDT: -420,
|
1047 | PET: -300,
|
1048 | PETST: 720,
|
1049 | PETT: 720,
|
1050 | PGT: 600,
|
1051 | PHOT: 780,
|
1052 | PHT: 480,
|
1053 | PKT: 300,
|
1054 | PMDT: -120,
|
1055 | PMST: -180,
|
1056 | PONT: 660,
|
1057 | PST: -480,
|
1058 | PT: -480,
|
1059 | PWT: 540,
|
1060 | PYST: -180,
|
1061 | PYT: -240,
|
1062 | RET: 240,
|
1063 | SAMT: 240,
|
1064 | SAST: 120,
|
1065 | SBT: 660,
|
1066 | SCT: 240,
|
1067 | SGT: 480,
|
1068 | SRT: -180,
|
1069 | SST: -660,
|
1070 | TAHT: -600,
|
1071 | TFT: 300,
|
1072 | TJT: 300,
|
1073 | TKT: 780,
|
1074 | TLT: 540,
|
1075 | TMT: 300,
|
1076 | TVT: 720,
|
1077 | ULAT: 480,
|
1078 | UTC: 0,
|
1079 | UYST: -120,
|
1080 | UYT: -180,
|
1081 | UZT: 300,
|
1082 | VET: -210,
|
1083 | VLAST: 660,
|
1084 | VLAT: 660,
|
1085 | VUT: 660,
|
1086 | WAST: 120,
|
1087 | WAT: 60,
|
1088 | WEST: 60,
|
1089 | WESZ: 60,
|
1090 | WET: 0,
|
1091 | WEZ: 0,
|
1092 | WFT: 720,
|
1093 | WGST: -120,
|
1094 | WGT: -180,
|
1095 | WIB: 420,
|
1096 | WIT: 540,
|
1097 | WITA: 480,
|
1098 | WST: 780,
|
1099 | WT: 0,
|
1100 | YAKST: 600,
|
1101 | YAKT: 600,
|
1102 | YAPT: 600,
|
1103 | YEKST: 360,
|
1104 | YEKT: 360,
|
1105 | };
|
1106 | class ExtractTimezoneAbbrRefiner {
|
1107 | constructor(timezoneOverrides) {
|
1108 | this.timezone = Object.assign(Object.assign({}, DEFAULT_TIMEZONE_ABBR_MAP), timezoneOverrides);
|
1109 | }
|
1110 | refine(context, results) {
|
1111 | var _a;
|
1112 | const timezoneOverrides = (_a = context.option.timezones) !== null && _a !== void 0 ? _a : {};
|
1113 | results.forEach((result) => {
|
1114 | var _a, _b;
|
1115 | const suffix = context.text.substring(result.index + result.text.length);
|
1116 | const match = TIMEZONE_NAME_PATTERN.exec(suffix);
|
1117 | if (!match) {
|
1118 | return;
|
1119 | }
|
1120 | const timezoneAbbr = match[1].toUpperCase();
|
1121 | const extractedTimezoneOffset = (_b = (_a = timezoneOverrides[timezoneAbbr]) !== null && _a !== void 0 ? _a : this.timezone[timezoneAbbr]) !== null && _b !== void 0 ? _b : null;
|
1122 | if (extractedTimezoneOffset === null) {
|
1123 | return;
|
1124 | }
|
1125 | context.debug(() => {
|
1126 | console.log(`Extracting timezone: '${timezoneAbbr}' into : ${extractedTimezoneOffset}`);
|
1127 | });
|
1128 | const currentTimezoneOffset = result.start.get("timezoneOffset");
|
1129 | if (currentTimezoneOffset !== null && extractedTimezoneOffset != currentTimezoneOffset) {
|
1130 | if (result.start.isCertain("timezoneOffset")) {
|
1131 | return;
|
1132 | }
|
1133 | if (timezoneAbbr != match[1]) {
|
1134 | return;
|
1135 | }
|
1136 | }
|
1137 | result.text += match[0];
|
1138 | if (!result.start.isCertain("timezoneOffset")) {
|
1139 | result.start.assign("timezoneOffset", extractedTimezoneOffset);
|
1140 | }
|
1141 | if (result.end != null && !result.end.isCertain("timezoneOffset")) {
|
1142 | result.end.assign("timezoneOffset", extractedTimezoneOffset);
|
1143 | }
|
1144 | });
|
1145 | return results;
|
1146 | }
|
1147 | }
|
1148 | exports.default = ExtractTimezoneAbbrRefiner;
|
1149 |
|
1150 | },{}],14:[function(require,module,exports){
|
1151 | "use strict";
|
1152 | Object.defineProperty(exports, "__esModule", { value: true });
|
1153 | const TIMEZONE_OFFSET_PATTERN = new RegExp("^\\s*(?:(?:GMT|UTC)\\s?)?([+-])(\\d{1,2})(?::?(\\d{2}))?", "i");
|
1154 | const TIMEZONE_OFFSET_SIGN_GROUP = 1;
|
1155 | const TIMEZONE_OFFSET_HOUR_OFFSET_GROUP = 2;
|
1156 | const TIMEZONE_OFFSET_MINUTE_OFFSET_GROUP = 3;
|
1157 | class ExtractTimezoneOffsetRefiner {
|
1158 | refine(context, results) {
|
1159 | results.forEach(function (result) {
|
1160 | if (result.start.isCertain("timezoneOffset")) {
|
1161 | return;
|
1162 | }
|
1163 | const suffix = context.text.substring(result.index + result.text.length);
|
1164 | const match = TIMEZONE_OFFSET_PATTERN.exec(suffix);
|
1165 | if (!match) {
|
1166 | return;
|
1167 | }
|
1168 | context.debug(() => {
|
1169 | console.log(`Extracting timezone: '${match[0]}' into : ${result}`);
|
1170 | });
|
1171 | const hourOffset = parseInt(match[TIMEZONE_OFFSET_HOUR_OFFSET_GROUP]);
|
1172 | const minuteOffset = parseInt(match[TIMEZONE_OFFSET_MINUTE_OFFSET_GROUP] || "0");
|
1173 | let timezoneOffset = hourOffset * 60 + minuteOffset;
|
1174 | if (match[TIMEZONE_OFFSET_SIGN_GROUP] === "-") {
|
1175 | timezoneOffset = -timezoneOffset;
|
1176 | }
|
1177 | if (result.end != null) {
|
1178 | result.end.assign("timezoneOffset", timezoneOffset);
|
1179 | }
|
1180 | result.start.assign("timezoneOffset", timezoneOffset);
|
1181 | result.text += match[0];
|
1182 | });
|
1183 | return results;
|
1184 | }
|
1185 | }
|
1186 | exports.default = ExtractTimezoneOffsetRefiner;
|
1187 |
|
1188 | },{}],15:[function(require,module,exports){
|
1189 | "use strict";
|
1190 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
1191 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
1192 | };
|
1193 | Object.defineProperty(exports, "__esModule", { value: true });
|
1194 | const dayjs_1 = __importDefault(require("dayjs"));
|
1195 | class ForwardDateRefiner {
|
1196 | refine(context, results) {
|
1197 | if (!context.option.forwardDate) {
|
1198 | return results;
|
1199 | }
|
1200 | results.forEach(function (result) {
|
1201 | let refMoment = dayjs_1.default(context.refDate);
|
1202 | if (result.start.isOnlyDayMonthComponent() && refMoment.isAfter(result.start.dayjs())) {
|
1203 | for (let i = 0; i < 3 && refMoment.isAfter(result.start.dayjs()); i++) {
|
1204 | result.start.imply("year", result.start.get("year") + 1);
|
1205 | context.debug(() => {
|
1206 | console.log(`Forward yearly adjusted for ${result} (${result.start})`);
|
1207 | });
|
1208 | if (result.end && !result.end.isCertain("year")) {
|
1209 | result.end.imply("year", result.end.get("year") + 1);
|
1210 | context.debug(() => {
|
1211 | console.log(`Forward yearly adjusted for ${result} (${result.end})`);
|
1212 | });
|
1213 | }
|
1214 | }
|
1215 | }
|
1216 | if (result.start.isOnlyWeekdayComponent() && refMoment.isAfter(result.start.dayjs())) {
|
1217 | if (refMoment.day() > result.start.get("weekday")) {
|
1218 | refMoment = refMoment.day(result.start.get("weekday") + 7);
|
1219 | }
|
1220 | else {
|
1221 | refMoment = refMoment.day(result.start.get("weekday"));
|
1222 | }
|
1223 | result.start.imply("day", refMoment.date());
|
1224 | result.start.imply("month", refMoment.month() + 1);
|
1225 | result.start.imply("year", refMoment.year());
|
1226 | context.debug(() => {
|
1227 | console.log(`Forward weekly adjusted for ${result} (${result.start})`);
|
1228 | });
|
1229 | if (result.end && result.end.isOnlyWeekdayComponent()) {
|
1230 | if (refMoment.day() > result.end.get("weekday")) {
|
1231 | refMoment = refMoment.day(result.end.get("weekday") + 7);
|
1232 | }
|
1233 | else {
|
1234 | refMoment = refMoment.day(result.end.get("weekday"));
|
1235 | }
|
1236 | result.end.imply("day", refMoment.date());
|
1237 | result.end.imply("month", refMoment.month() + 1);
|
1238 | result.end.imply("year", refMoment.year());
|
1239 | context.debug(() => {
|
1240 | console.log(`Forward weekly adjusted for ${result} (${result.end})`);
|
1241 | });
|
1242 | }
|
1243 | }
|
1244 | });
|
1245 | return results;
|
1246 | }
|
1247 | }
|
1248 | exports.default = ForwardDateRefiner;
|
1249 |
|
1250 | },{"dayjs":93}],16:[function(require,module,exports){
|
1251 | "use strict";
|
1252 | Object.defineProperty(exports, "__esModule", { value: true });
|
1253 | const abstractRefiners_1 = require("../abstractRefiners");
|
1254 | class MergeWeekdayComponentRefiner extends abstractRefiners_1.MergingRefiner {
|
1255 | mergeResults(textBetween, currentResult, nextResult) {
|
1256 | const newResult = nextResult.clone();
|
1257 | newResult.index = currentResult.index;
|
1258 | newResult.text = currentResult.text + textBetween + newResult.text;
|
1259 | newResult.start.assign("weekday", currentResult.start.get("weekday"));
|
1260 | if (newResult.end) {
|
1261 | newResult.end.assign("weekday", currentResult.start.get("weekday"));
|
1262 | }
|
1263 | return newResult;
|
1264 | }
|
1265 | shouldMergeResults(textBetween, currentResult, nextResult) {
|
1266 | const weekdayThenNormalDate = currentResult.start.isOnlyWeekdayComponent() &&
|
1267 | !currentResult.start.isCertain("hour") &&
|
1268 | nextResult.start.isCertain("day");
|
1269 | return weekdayThenNormalDate && textBetween.match(/^,?\s*$/) != null;
|
1270 | }
|
1271 | }
|
1272 | exports.default = MergeWeekdayComponentRefiner;
|
1273 |
|
1274 | },{"../abstractRefiners":5}],17:[function(require,module,exports){
|
1275 | "use strict";
|
1276 | Object.defineProperty(exports, "__esModule", { value: true });
|
1277 | class OverlapRemovalRefiner {
|
1278 | refine(context, results) {
|
1279 | if (results.length < 2) {
|
1280 | return results;
|
1281 | }
|
1282 | const filteredResults = [];
|
1283 | let prevResult = results[0];
|
1284 | for (let i = 1; i < results.length; i++) {
|
1285 | const result = results[i];
|
1286 | if (result.index < prevResult.index + prevResult.text.length) {
|
1287 | if (result.text.length > prevResult.text.length) {
|
1288 | prevResult = result;
|
1289 | }
|
1290 | }
|
1291 | else {
|
1292 | filteredResults.push(prevResult);
|
1293 | prevResult = result;
|
1294 | }
|
1295 | }
|
1296 | if (prevResult != null) {
|
1297 | filteredResults.push(prevResult);
|
1298 | }
|
1299 | return filteredResults;
|
1300 | }
|
1301 | }
|
1302 | exports.default = OverlapRemovalRefiner;
|
1303 |
|
1304 | },{}],18:[function(require,module,exports){
|
1305 | "use strict";
|
1306 | Object.defineProperty(exports, "__esModule", { value: true });
|
1307 | const abstractRefiners_1 = require("../abstractRefiners");
|
1308 | class UnlikelyFormatFilter extends abstractRefiners_1.Filter {
|
1309 | constructor(strictMode) {
|
1310 | super();
|
1311 | this.strictMode = strictMode;
|
1312 | }
|
1313 | isValid(context, result) {
|
1314 | if (result.text.replace(" ", "").match(/^\d*(\.\d*)?$/)) {
|
1315 | context.debug(() => {
|
1316 | console.log(`Removing unlikely result '${result.text}'`);
|
1317 | });
|
1318 | return false;
|
1319 | }
|
1320 | if (!result.start.isValidDate()) {
|
1321 | context.debug(() => {
|
1322 | console.log(`Removing invalid result: ${result} (${result.start})`);
|
1323 | });
|
1324 | return false;
|
1325 | }
|
1326 | if (result.end && !result.end.isValidDate()) {
|
1327 | context.debug(() => {
|
1328 | console.log(`Removing invalid result: ${result} (${result.end})`);
|
1329 | });
|
1330 | return false;
|
1331 | }
|
1332 | if (this.strictMode) {
|
1333 | return this.isStrictModeValid(context, result);
|
1334 | }
|
1335 | return true;
|
1336 | }
|
1337 | isStrictModeValid(context, result) {
|
1338 | if (result.start.isOnlyWeekdayComponent()) {
|
1339 | context.debug(() => {
|
1340 | console.log(`(Strict) Removing weekday only component: ${result} (${result.end})`);
|
1341 | });
|
1342 | return false;
|
1343 | }
|
1344 | if (result.start.isOnlyTime() && (!result.start.isCertain("hour") || !result.start.isCertain("minute"))) {
|
1345 | context.debug(() => {
|
1346 | console.log(`(Strict) Removing uncertain time component: ${result} (${result.end})`);
|
1347 | });
|
1348 | return false;
|
1349 | }
|
1350 | return true;
|
1351 | }
|
1352 | }
|
1353 | exports.default = UnlikelyFormatFilter;
|
1354 |
|
1355 | },{"../abstractRefiners":5}],19:[function(require,module,exports){
|
1356 | "use strict";
|
1357 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
1358 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
1359 | };
|
1360 | Object.defineProperty(exports, "__esModule", { value: true });
|
1361 | exports.includeCommonConfiguration = void 0;
|
1362 | const ExtractTimezoneAbbrRefiner_1 = __importDefault(require("./common/refiners/ExtractTimezoneAbbrRefiner"));
|
1363 | const ExtractTimezoneOffsetRefiner_1 = __importDefault(require("./common/refiners/ExtractTimezoneOffsetRefiner"));
|
1364 | const OverlapRemovalRefiner_1 = __importDefault(require("./common/refiners/OverlapRemovalRefiner"));
|
1365 | const ForwardDateRefiner_1 = __importDefault(require("./common/refiners/ForwardDateRefiner"));
|
1366 | const UnlikelyFormatFilter_1 = __importDefault(require("./common/refiners/UnlikelyFormatFilter"));
|
1367 | const ISOFormatParser_1 = __importDefault(require("./common/parsers/ISOFormatParser"));
|
1368 | const MergeWeekdayComponentRefiner_1 = __importDefault(require("./common/refiners/MergeWeekdayComponentRefiner"));
|
1369 | function includeCommonConfiguration(configuration, strictMode = false) {
|
1370 | configuration.parsers.unshift(new ISOFormatParser_1.default());
|
1371 | configuration.refiners.unshift(new MergeWeekdayComponentRefiner_1.default());
|
1372 | configuration.refiners.unshift(new ExtractTimezoneAbbrRefiner_1.default());
|
1373 | configuration.refiners.unshift(new ExtractTimezoneOffsetRefiner_1.default());
|
1374 | configuration.refiners.unshift(new OverlapRemovalRefiner_1.default());
|
1375 | configuration.refiners.push(new OverlapRemovalRefiner_1.default());
|
1376 | configuration.refiners.push(new ForwardDateRefiner_1.default());
|
1377 | configuration.refiners.push(new UnlikelyFormatFilter_1.default(strictMode));
|
1378 | return configuration;
|
1379 | }
|
1380 | exports.includeCommonConfiguration = includeCommonConfiguration;
|
1381 |
|
1382 | },{"./common/parsers/ISOFormatParser":9,"./common/refiners/ExtractTimezoneAbbrRefiner":13,"./common/refiners/ExtractTimezoneOffsetRefiner":14,"./common/refiners/ForwardDateRefiner":15,"./common/refiners/MergeWeekdayComponentRefiner":16,"./common/refiners/OverlapRemovalRefiner":17,"./common/refiners/UnlikelyFormatFilter":18}],20:[function(require,module,exports){
|
1383 | "use strict";
|
1384 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
1385 | if (k2 === undefined) k2 = k;
|
1386 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
1387 | }) : (function(o, m, k, k2) {
|
1388 | if (k2 === undefined) k2 = k;
|
1389 | o[k2] = m[k];
|
1390 | }));
|
1391 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
1392 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
1393 | }) : function(o, v) {
|
1394 | o["default"] = v;
|
1395 | });
|
1396 | var __importStar = (this && this.__importStar) || function (mod) {
|
1397 | if (mod && mod.__esModule) return mod;
|
1398 | var result = {};
|
1399 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
1400 | __setModuleDefault(result, mod);
|
1401 | return result;
|
1402 | };
|
1403 | Object.defineProperty(exports, "__esModule", { value: true });
|
1404 | exports.parseDate = exports.parse = exports.casual = exports.strict = exports.nl = exports.pt = exports.ja = exports.fr = exports.de = exports.Meridiem = exports.Chrono = exports.en = void 0;
|
1405 | const en = __importStar(require("./locales/en"));
|
1406 | exports.en = en;
|
1407 | const chrono_1 = require("./chrono");
|
1408 | Object.defineProperty(exports, "Chrono", { enumerable: true, get: function () { return chrono_1.Chrono; } });
|
1409 | var Meridiem;
|
1410 | (function (Meridiem) {
|
1411 | Meridiem[Meridiem["AM"] = 0] = "AM";
|
1412 | Meridiem[Meridiem["PM"] = 1] = "PM";
|
1413 | })(Meridiem = exports.Meridiem || (exports.Meridiem = {}));
|
1414 | const de = __importStar(require("./locales/de"));
|
1415 | exports.de = de;
|
1416 | const fr = __importStar(require("./locales/fr"));
|
1417 | exports.fr = fr;
|
1418 | const ja = __importStar(require("./locales/ja"));
|
1419 | exports.ja = ja;
|
1420 | const pt = __importStar(require("./locales/pt"));
|
1421 | exports.pt = pt;
|
1422 | const nl = __importStar(require("./locales/nl"));
|
1423 | exports.nl = nl;
|
1424 | exports.strict = en.strict;
|
1425 | exports.casual = en.casual;
|
1426 | function parse(text, ref, option) {
|
1427 | return exports.casual.parse(text, ref, option);
|
1428 | }
|
1429 | exports.parse = parse;
|
1430 | function parseDate(text, ref, option) {
|
1431 | return exports.casual.parseDate(text, ref, option);
|
1432 | }
|
1433 | exports.parseDate = parseDate;
|
1434 |
|
1435 | },{"./chrono":4,"./locales/de":22,"./locales/en":31,"./locales/fr":49,"./locales/ja":62,"./locales/nl":67,"./locales/pt":81}],21:[function(require,module,exports){
|
1436 | "use strict";
|
1437 | Object.defineProperty(exports, "__esModule", { value: true });
|
1438 | exports.parseTimeUnits = exports.TIME_UNITS_PATTERN = exports.parseYear = exports.YEAR_PATTERN = exports.parseNumberPattern = exports.NUMBER_PATTERN = exports.TIME_UNIT_DICTIONARY = exports.INTEGER_WORD_DICTIONARY = exports.MONTH_DICTIONARY = exports.WEEKDAY_DICTIONARY = void 0;
|
1439 | const pattern_1 = require("../../utils/pattern");
|
1440 | const years_1 = require("../../calculation/years");
|
1441 | exports.WEEKDAY_DICTIONARY = {
|
1442 | "sonntag": 0,
|
1443 | "so": 0,
|
1444 | "montag": 1,
|
1445 | "mo": 1,
|
1446 | "dienstag": 2,
|
1447 | "di": 2,
|
1448 | "mittwoch": 3,
|
1449 | "mi": 3,
|
1450 | "donnerstag": 4,
|
1451 | "do": 4,
|
1452 | "freitag": 5,
|
1453 | "fr": 5,
|
1454 | "samstag": 6,
|
1455 | "sa": 6,
|
1456 | };
|
1457 | exports.MONTH_DICTIONARY = {
|
1458 | "januar": 1,
|
1459 | "jan": 1,
|
1460 | "jan.": 1,
|
1461 | "februar": 2,
|
1462 | "feb": 2,
|
1463 | "feb.": 2,
|
1464 | "märz": 3,
|
1465 | "maerz": 3,
|
1466 | "mär": 3,
|
1467 | "mär.": 3,
|
1468 | "mrz": 3,
|
1469 | "mrz.": 3,
|
1470 | "april": 4,
|
1471 | "apr": 4,
|
1472 | "apr.": 4,
|
1473 | "mai": 5,
|
1474 | "juni": 6,
|
1475 | "jun": 6,
|
1476 | "jun.": 6,
|
1477 | "juli": 7,
|
1478 | "jul": 7,
|
1479 | "jul.": 7,
|
1480 | "august": 8,
|
1481 | "aug": 8,
|
1482 | "aug.": 8,
|
1483 | "september": 9,
|
1484 | "sep": 9,
|
1485 | "sep.": 9,
|
1486 | "sept": 9,
|
1487 | "sept.": 9,
|
1488 | "oktober": 10,
|
1489 | "okt": 10,
|
1490 | "okt.": 10,
|
1491 | "november": 11,
|
1492 | "nov": 11,
|
1493 | "nov.": 11,
|
1494 | "dezember": 12,
|
1495 | "dez": 12,
|
1496 | "dez.": 12,
|
1497 | };
|
1498 | exports.INTEGER_WORD_DICTIONARY = {
|
1499 | "eins": 1,
|
1500 | "zwei": 2,
|
1501 | "drei": 3,
|
1502 | "vier": 4,
|
1503 | "fünf": 5,
|
1504 | "fuenf": 5,
|
1505 | "sechs": 6,
|
1506 | "sieben": 7,
|
1507 | "acht": 8,
|
1508 | "neun": 9,
|
1509 | "zehn": 10,
|
1510 | "elf": 11,
|
1511 | "zwölf": 12,
|
1512 | "zwoelf": 12,
|
1513 | };
|
1514 | exports.TIME_UNIT_DICTIONARY = {
|
1515 | sec: "second",
|
1516 | second: "second",
|
1517 | seconds: "second",
|
1518 | min: "minute",
|
1519 | mins: "minute",
|
1520 | minute: "minute",
|
1521 | minutes: "minute",
|
1522 | h: "hour",
|
1523 | hr: "hour",
|
1524 | hrs: "hour",
|
1525 | hour: "hour",
|
1526 | hours: "hour",
|
1527 | day: "d",
|
1528 | days: "d",
|
1529 | week: "week",
|
1530 | weeks: "week",
|
1531 | month: "month",
|
1532 | months: "month",
|
1533 | y: "year",
|
1534 | yr: "year",
|
1535 | year: "year",
|
1536 | years: "year",
|
1537 | };
|
1538 | exports.NUMBER_PATTERN = `(?:${pattern_1.matchAnyPattern(exports.INTEGER_WORD_DICTIONARY)}|[0-9]+|[0-9]+\\.[0-9]+|half(?:\\s*an?)?|an?(?:\\s*few)?|few|several|a?\\s*couple\\s*(?:of)?)`;
|
1539 | function parseNumberPattern(match) {
|
1540 | const num = match.toLowerCase();
|
1541 | if (exports.INTEGER_WORD_DICTIONARY[num] !== undefined) {
|
1542 | return exports.INTEGER_WORD_DICTIONARY[num];
|
1543 | }
|
1544 | else if (num === "a" || num === "an") {
|
1545 | return 1;
|
1546 | }
|
1547 | else if (num.match(/few/)) {
|
1548 | return 3;
|
1549 | }
|
1550 | else if (num.match(/half/)) {
|
1551 | return 0.5;
|
1552 | }
|
1553 | else if (num.match(/couple/)) {
|
1554 | return 2;
|
1555 | }
|
1556 | else if (num.match(/several/)) {
|
1557 | return 7;
|
1558 | }
|
1559 | return parseFloat(num);
|
1560 | }
|
1561 | exports.parseNumberPattern = parseNumberPattern;
|
1562 | exports.YEAR_PATTERN = `(?:[0-9]{1,4}(?:\\s*[vn]\\.?\\s*C(?:hr)?\\.?)?)`;
|
1563 | function parseYear(match) {
|
1564 | if (/v/i.test(match)) {
|
1565 | return -parseInt(match.replace(/[^0-9]+/gi, ""));
|
1566 | }
|
1567 | if (/n/i.test(match)) {
|
1568 | return parseInt(match.replace(/[^0-9]+/gi, ""));
|
1569 | }
|
1570 | const rawYearNumber = parseInt(match);
|
1571 | return years_1.findMostLikelyADYear(rawYearNumber);
|
1572 | }
|
1573 | exports.parseYear = parseYear;
|
1574 | const SINGLE_TIME_UNIT_PATTERN = `(${exports.NUMBER_PATTERN})\\s{0,5}(${pattern_1.matchAnyPattern(exports.TIME_UNIT_DICTIONARY)})\\s{0,5}`;
|
1575 | const SINGLE_TIME_UNIT_REGEX = new RegExp(SINGLE_TIME_UNIT_PATTERN, "i");
|
1576 | exports.TIME_UNITS_PATTERN = pattern_1.repeatedTimeunitPattern("", SINGLE_TIME_UNIT_PATTERN);
|
1577 | function parseTimeUnits(timeunitText) {
|
1578 | const fragments = {};
|
1579 | let remainingText = timeunitText;
|
1580 | let match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
1581 | while (match) {
|
1582 | collectDateTimeFragment(fragments, match);
|
1583 | remainingText = remainingText.substring(match[0].length);
|
1584 | match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
1585 | }
|
1586 | return fragments;
|
1587 | }
|
1588 | exports.parseTimeUnits = parseTimeUnits;
|
1589 | function collectDateTimeFragment(fragments, match) {
|
1590 | const num = parseNumberPattern(match[1]);
|
1591 | const unit = exports.TIME_UNIT_DICTIONARY[match[2].toLowerCase()];
|
1592 | fragments[unit] = num;
|
1593 | }
|
1594 |
|
1595 | },{"../../calculation/years":3,"../../utils/pattern":91}],22:[function(require,module,exports){
|
1596 | "use strict";
|
1597 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
1598 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
1599 | };
|
1600 | Object.defineProperty(exports, "__esModule", { value: true });
|
1601 | exports.createConfiguration = exports.createCasualConfiguration = exports.parseDate = exports.parse = exports.strict = exports.casual = void 0;
|
1602 | const configurations_1 = require("../../configurations");
|
1603 | const chrono_1 = require("../../chrono");
|
1604 | const SlashDateFormatParser_1 = __importDefault(require("../../common/parsers/SlashDateFormatParser"));
|
1605 | const ISOFormatParser_1 = __importDefault(require("../../common/parsers/ISOFormatParser"));
|
1606 | const DETimeExpressionParser_1 = __importDefault(require("./parsers/DETimeExpressionParser"));
|
1607 | const DEWeekdayParser_1 = __importDefault(require("./parsers/DEWeekdayParser"));
|
1608 | const DEMergeDateRangeRefiner_1 = __importDefault(require("./refiners/DEMergeDateRangeRefiner"));
|
1609 | const DEMergeDateTimeRefiner_1 = __importDefault(require("./refiners/DEMergeDateTimeRefiner"));
|
1610 | const DECasualDateParser_1 = __importDefault(require("./parsers/DECasualDateParser"));
|
1611 | const DECasualTimeParser_1 = __importDefault(require("./parsers/DECasualTimeParser"));
|
1612 | const DEMonthNameLittleEndianParser_1 = __importDefault(require("./parsers/DEMonthNameLittleEndianParser"));
|
1613 | exports.casual = new chrono_1.Chrono(createCasualConfiguration());
|
1614 | exports.strict = new chrono_1.Chrono(createConfiguration(true));
|
1615 | function parse(text, ref, option) {
|
1616 | return exports.casual.parse(text, ref, option);
|
1617 | }
|
1618 | exports.parse = parse;
|
1619 | function parseDate(text, ref, option) {
|
1620 | return exports.casual.parseDate(text, ref, option);
|
1621 | }
|
1622 | exports.parseDate = parseDate;
|
1623 | function createCasualConfiguration(littleEndian = true) {
|
1624 | const option = createConfiguration(false, littleEndian);
|
1625 | option.parsers.unshift(new DECasualTimeParser_1.default());
|
1626 | option.parsers.unshift(new DECasualDateParser_1.default());
|
1627 | return option;
|
1628 | }
|
1629 | exports.createCasualConfiguration = createCasualConfiguration;
|
1630 | function createConfiguration(strictMode = true, littleEndian = true) {
|
1631 | return configurations_1.includeCommonConfiguration({
|
1632 | parsers: [
|
1633 | new ISOFormatParser_1.default(),
|
1634 | new SlashDateFormatParser_1.default(littleEndian),
|
1635 | new DETimeExpressionParser_1.default(),
|
1636 | new DEMonthNameLittleEndianParser_1.default(),
|
1637 | new DEWeekdayParser_1.default(),
|
1638 | ],
|
1639 | refiners: [new DEMergeDateRangeRefiner_1.default(), new DEMergeDateTimeRefiner_1.default()],
|
1640 | }, strictMode);
|
1641 | }
|
1642 | exports.createConfiguration = createConfiguration;
|
1643 |
|
1644 | },{"../../chrono":4,"../../common/parsers/ISOFormatParser":9,"../../common/parsers/SlashDateFormatParser":10,"../../configurations":19,"./parsers/DECasualDateParser":23,"./parsers/DECasualTimeParser":24,"./parsers/DEMonthNameLittleEndianParser":25,"./parsers/DETimeExpressionParser":26,"./parsers/DEWeekdayParser":27,"./refiners/DEMergeDateRangeRefiner":28,"./refiners/DEMergeDateTimeRefiner":29}],23:[function(require,module,exports){
|
1645 | "use strict";
|
1646 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
1647 | if (k2 === undefined) k2 = k;
|
1648 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
1649 | }) : (function(o, m, k, k2) {
|
1650 | if (k2 === undefined) k2 = k;
|
1651 | o[k2] = m[k];
|
1652 | }));
|
1653 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
1654 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
1655 | }) : function(o, v) {
|
1656 | o["default"] = v;
|
1657 | });
|
1658 | var __importStar = (this && this.__importStar) || function (mod) {
|
1659 | if (mod && mod.__esModule) return mod;
|
1660 | var result = {};
|
1661 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
1662 | __setModuleDefault(result, mod);
|
1663 | return result;
|
1664 | };
|
1665 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
1666 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
1667 | };
|
1668 | Object.defineProperty(exports, "__esModule", { value: true });
|
1669 | const dayjs_1 = __importDefault(require("dayjs"));
|
1670 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
1671 | const dayjs_2 = require("../../../utils/dayjs");
|
1672 | const DECasualTimeParser_1 = __importDefault(require("./DECasualTimeParser"));
|
1673 | const references = __importStar(require("../../../common/casualReferences"));
|
1674 | const PATTERN = new RegExp(`(jetzt|heute|morgen|übermorgen|uebermorgen|gestern|vorgestern|letzte\\s*nacht)` +
|
1675 | `(?:\\s*(morgen|vormittag|mittags?|nachmittag|abend|nacht|mitternacht))?` +
|
1676 | `(?=\\W|$)`, "i");
|
1677 | const DATE_GROUP = 1;
|
1678 | const TIME_GROUP = 2;
|
1679 | class DECasualDateParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
1680 | innerPattern(context) {
|
1681 | return PATTERN;
|
1682 | }
|
1683 | innerExtract(context, match) {
|
1684 | let targetDate = dayjs_1.default(context.refDate);
|
1685 | const dateKeyword = (match[DATE_GROUP] || "").toLowerCase();
|
1686 | const timeKeyword = (match[TIME_GROUP] || "").toLowerCase();
|
1687 | let component = context.createParsingComponents();
|
1688 | switch (dateKeyword) {
|
1689 | case "jetzt":
|
1690 | component = references.now(context.refDate);
|
1691 | break;
|
1692 | case "heute":
|
1693 | component = references.today(context.refDate);
|
1694 | break;
|
1695 | case "morgen":
|
1696 | dayjs_2.assignTheNextDay(component, targetDate);
|
1697 | break;
|
1698 | case "übermorgen":
|
1699 | case "uebermorgen":
|
1700 | targetDate = targetDate.add(1, "day");
|
1701 | dayjs_2.assignTheNextDay(component, targetDate);
|
1702 | break;
|
1703 | case "gestern":
|
1704 | targetDate = targetDate.add(-1, "day");
|
1705 | dayjs_2.assignSimilarDate(component, targetDate);
|
1706 | dayjs_2.implySimilarTime(component, targetDate);
|
1707 | break;
|
1708 | case "vorgestern":
|
1709 | targetDate = targetDate.add(-2, "day");
|
1710 | dayjs_2.assignSimilarDate(component, targetDate);
|
1711 | dayjs_2.implySimilarTime(component, targetDate);
|
1712 | break;
|
1713 | default:
|
1714 | if (dateKeyword.match(/letzte\s*nacht/)) {
|
1715 | if (targetDate.hour() > 6) {
|
1716 | targetDate = targetDate.add(-1, "day");
|
1717 | }
|
1718 | dayjs_2.assignSimilarDate(component, targetDate);
|
1719 | component.imply("hour", 0);
|
1720 | }
|
1721 | break;
|
1722 | }
|
1723 | if (timeKeyword) {
|
1724 | component = DECasualTimeParser_1.default.extractTimeComponents(component, timeKeyword);
|
1725 | }
|
1726 | return component;
|
1727 | }
|
1728 | }
|
1729 | exports.default = DECasualDateParser;
|
1730 |
|
1731 | },{"../../../common/casualReferences":6,"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../utils/dayjs":90,"./DECasualTimeParser":24,"dayjs":93}],24:[function(require,module,exports){
|
1732 | "use strict";
|
1733 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
1734 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
1735 | };
|
1736 | Object.defineProperty(exports, "__esModule", { value: true });
|
1737 | const dayjs_1 = __importDefault(require("dayjs"));
|
1738 | const index_1 = require("../../../index");
|
1739 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
1740 | const dayjs_2 = require("../../../utils/dayjs");
|
1741 | const timeunits_1 = require("../../../utils/timeunits");
|
1742 | class DECasualTimeParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
1743 | innerPattern(context) {
|
1744 | return /(diesen)?\s*(morgen|vormittag|mittags?|nachmittag|abend|nacht|mitternacht)(?=\W|$)/i;
|
1745 | }
|
1746 | innerExtract(context, match) {
|
1747 | const targetDate = dayjs_1.default(context.refDate);
|
1748 | const timeKeywordPattern = match[2].toLowerCase();
|
1749 | const component = context.createParsingComponents();
|
1750 | dayjs_2.implySimilarTime(component, targetDate);
|
1751 | return DECasualTimeParser.extractTimeComponents(component, timeKeywordPattern);
|
1752 | }
|
1753 | static extractTimeComponents(component, timeKeywordPattern) {
|
1754 | switch (timeKeywordPattern) {
|
1755 | case "morgen":
|
1756 | component.imply("hour", 6);
|
1757 | component.imply("minute", 0);
|
1758 | component.imply("second", 0);
|
1759 | component.imply("meridiem", index_1.Meridiem.AM);
|
1760 | break;
|
1761 | case "vormittag":
|
1762 | component.imply("hour", 9);
|
1763 | component.imply("minute", 0);
|
1764 | component.imply("second", 0);
|
1765 | component.imply("meridiem", index_1.Meridiem.AM);
|
1766 | break;
|
1767 | case "mittag":
|
1768 | case "mittags":
|
1769 | component.imply("hour", 12);
|
1770 | component.imply("minute", 0);
|
1771 | component.imply("second", 0);
|
1772 | component.imply("meridiem", index_1.Meridiem.AM);
|
1773 | break;
|
1774 | case "nachmittag":
|
1775 | component.imply("hour", 15);
|
1776 | component.imply("minute", 0);
|
1777 | component.imply("second", 0);
|
1778 | component.imply("meridiem", index_1.Meridiem.PM);
|
1779 | break;
|
1780 | case "abend":
|
1781 | component.imply("hour", 18);
|
1782 | component.imply("minute", 0);
|
1783 | component.imply("second", 0);
|
1784 | component.imply("meridiem", index_1.Meridiem.PM);
|
1785 | break;
|
1786 | case "nacht":
|
1787 | component.imply("hour", 22);
|
1788 | component.imply("minute", 0);
|
1789 | component.imply("second", 0);
|
1790 | component.imply("meridiem", index_1.Meridiem.PM);
|
1791 | break;
|
1792 | case "mitternacht":
|
1793 | if (component.get("hour") > 1) {
|
1794 | component = timeunits_1.addImpliedTimeUnits(component, { "day": 1 });
|
1795 | }
|
1796 | component.imply("hour", 0);
|
1797 | component.imply("minute", 0);
|
1798 | component.imply("second", 0);
|
1799 | component.imply("meridiem", index_1.Meridiem.AM);
|
1800 | break;
|
1801 | }
|
1802 | return component;
|
1803 | }
|
1804 | }
|
1805 | exports.default = DECasualTimeParser;
|
1806 |
|
1807 | },{"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../index":20,"../../../utils/dayjs":90,"../../../utils/timeunits":92,"dayjs":93}],25:[function(require,module,exports){
|
1808 | "use strict";
|
1809 | Object.defineProperty(exports, "__esModule", { value: true });
|
1810 | const years_1 = require("../../../calculation/years");
|
1811 | const constants_1 = require("../constants");
|
1812 | const constants_2 = require("../constants");
|
1813 | const pattern_1 = require("../../../utils/pattern");
|
1814 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
1815 | const PATTERN = new RegExp("(?:am\\s*?)?" +
|
1816 | "(?:den\\s*?)?" +
|
1817 | `([0-9]{1,2})\\.` +
|
1818 | `(?:\\s*(?:bis(?:\\s*(?:am|zum))?|\\-|\\–|\\s)\\s*([0-9]{1,2})\\.?)?\\s*` +
|
1819 | `(${pattern_1.matchAnyPattern(constants_1.MONTH_DICTIONARY)})` +
|
1820 | `(?:(?:-|/|,?\\s*)(${constants_2.YEAR_PATTERN}(?![^\\s]\\d)))?` +
|
1821 | `(?=\\W|$)`, "i");
|
1822 | const DATE_GROUP = 1;
|
1823 | const DATE_TO_GROUP = 2;
|
1824 | const MONTH_NAME_GROUP = 3;
|
1825 | const YEAR_GROUP = 4;
|
1826 | class DEMonthNameLittleEndianParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
1827 | innerPattern() {
|
1828 | return PATTERN;
|
1829 | }
|
1830 | innerExtract(context, match) {
|
1831 | const result = context.createParsingResult(match.index, match[0]);
|
1832 | const month = constants_1.MONTH_DICTIONARY[match[MONTH_NAME_GROUP].toLowerCase()];
|
1833 | const day = parseInt(match[DATE_GROUP]);
|
1834 | if (day > 31) {
|
1835 | match.index = match.index + match[DATE_GROUP].length;
|
1836 | return null;
|
1837 | }
|
1838 | result.start.assign("month", month);
|
1839 | result.start.assign("day", day);
|
1840 | if (match[YEAR_GROUP]) {
|
1841 | const yearNumber = constants_2.parseYear(match[YEAR_GROUP]);
|
1842 | result.start.assign("year", yearNumber);
|
1843 | }
|
1844 | else {
|
1845 | const year = years_1.findYearClosestToRef(context.refDate, day, month);
|
1846 | result.start.imply("year", year);
|
1847 | }
|
1848 | if (match[DATE_TO_GROUP]) {
|
1849 | const endDate = parseInt(match[DATE_TO_GROUP]);
|
1850 | result.end = result.start.clone();
|
1851 | result.end.assign("day", endDate);
|
1852 | }
|
1853 | return result;
|
1854 | }
|
1855 | }
|
1856 | exports.default = DEMonthNameLittleEndianParser;
|
1857 |
|
1858 | },{"../../../calculation/years":3,"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../utils/pattern":91,"../constants":21}],26:[function(require,module,exports){
|
1859 | "use strict";
|
1860 | Object.defineProperty(exports, "__esModule", { value: true });
|
1861 | const AbstractTimeExpressionParser_1 = require("../../../common/parsers/AbstractTimeExpressionParser");
|
1862 | const index_1 = require("../../../index");
|
1863 | class DETimeExpressionParser extends AbstractTimeExpressionParser_1.AbstractTimeExpressionParser {
|
1864 | primaryPrefix() {
|
1865 | return "(?:(?:um|von)\\s*)?";
|
1866 | }
|
1867 | followingPhase() {
|
1868 | return "\\s*(?:\\-|\\–|\\~|\\〜|bis)\\s*";
|
1869 | }
|
1870 | primarySuffix() {
|
1871 | return "(?:\\s*uhr)?(?:\\s*(?:morgens|vormittags|nachmittags|abends|nachts))?(?=\\W|$)";
|
1872 | }
|
1873 | extractPrimaryTimeComponents(context, match) {
|
1874 | const components = super.extractPrimaryTimeComponents(context, match);
|
1875 | if (components) {
|
1876 | if (match[0].endsWith("morgens") || match[0].endsWith("vormittags")) {
|
1877 | components.assign("meridiem", index_1.Meridiem.AM);
|
1878 | const hour = components.get("hour");
|
1879 | if (hour < 12) {
|
1880 | components.assign("hour", components.get("hour"));
|
1881 | }
|
1882 | }
|
1883 | if (match[0].endsWith("nachmittags") || match[0].endsWith("abends") || match[0].endsWith("nachts")) {
|
1884 | components.assign("meridiem", index_1.Meridiem.PM);
|
1885 | const hour = components.get("hour");
|
1886 | if (hour < 12) {
|
1887 | components.assign("hour", components.get("hour") + 12);
|
1888 | }
|
1889 | }
|
1890 | }
|
1891 | return components;
|
1892 | }
|
1893 | }
|
1894 | exports.default = DETimeExpressionParser;
|
1895 |
|
1896 | },{"../../../common/parsers/AbstractTimeExpressionParser":8,"../../../index":20}],27:[function(require,module,exports){
|
1897 | "use strict";
|
1898 | Object.defineProperty(exports, "__esModule", { value: true });
|
1899 | const constants_1 = require("../constants");
|
1900 | const pattern_1 = require("../../../utils/pattern");
|
1901 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
1902 | const weeks_1 = require("../../../calculation/weeks");
|
1903 | const PATTERN = new RegExp("(?:(?:\\,|\\(|\\()\\s*)?" +
|
1904 | "(?:a[mn]\\s*?)?" +
|
1905 | "(?:(diese[mn]|letzte[mn]|n(?:ä|ae)chste[mn])\\s*)?" +
|
1906 | `(${pattern_1.matchAnyPattern(constants_1.WEEKDAY_DICTIONARY)})` +
|
1907 | "(?:\\s*(?:\\,|\\)|\\)))?" +
|
1908 | "(?:\\s*(diese|letzte|n(?:ä|ae)chste)\\s*woche)?" +
|
1909 | "(?=\\W|$)", "i");
|
1910 | const PREFIX_GROUP = 1;
|
1911 | const SUFFIX_GROUP = 3;
|
1912 | const WEEKDAY_GROUP = 2;
|
1913 | class DEWeekdayParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
1914 | innerPattern() {
|
1915 | return PATTERN;
|
1916 | }
|
1917 | innerExtract(context, match) {
|
1918 | const dayOfWeek = match[WEEKDAY_GROUP].toLowerCase();
|
1919 | const offset = constants_1.WEEKDAY_DICTIONARY[dayOfWeek];
|
1920 | const prefix = match[PREFIX_GROUP];
|
1921 | const postfix = match[SUFFIX_GROUP];
|
1922 | let modifierWord = prefix || postfix;
|
1923 | modifierWord = modifierWord || "";
|
1924 | modifierWord = modifierWord.toLowerCase();
|
1925 | let modifier = null;
|
1926 | if (modifierWord.match(/letzte/)) {
|
1927 | modifier = "last";
|
1928 | }
|
1929 | else if (modifierWord.match(/chste/)) {
|
1930 | modifier = "next";
|
1931 | }
|
1932 | else if (modifierWord.match(/diese/)) {
|
1933 | modifier = "this";
|
1934 | }
|
1935 | const date = weeks_1.toDayJSWeekday(context.refDate, offset, modifier);
|
1936 | return context
|
1937 | .createParsingComponents()
|
1938 | .assign("weekday", offset)
|
1939 | .imply("day", date.date())
|
1940 | .imply("month", date.month() + 1)
|
1941 | .imply("year", date.year());
|
1942 | }
|
1943 | }
|
1944 | exports.default = DEWeekdayParser;
|
1945 |
|
1946 | },{"../../../calculation/weeks":2,"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../utils/pattern":91,"../constants":21}],28:[function(require,module,exports){
|
1947 | "use strict";
|
1948 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
1949 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
1950 | };
|
1951 | Object.defineProperty(exports, "__esModule", { value: true });
|
1952 | const AbstractMergeDateRangeRefiner_1 = __importDefault(require("../../../common/refiners/AbstractMergeDateRangeRefiner"));
|
1953 | class DEMergeDateRangeRefiner extends AbstractMergeDateRangeRefiner_1.default {
|
1954 | patternBetween() {
|
1955 | return /^\s*(bis(?:\s*(?:am|zum))?|-)\s*$/i;
|
1956 | }
|
1957 | }
|
1958 | exports.default = DEMergeDateRangeRefiner;
|
1959 |
|
1960 | },{"../../../common/refiners/AbstractMergeDateRangeRefiner":11}],29:[function(require,module,exports){
|
1961 | "use strict";
|
1962 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
1963 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
1964 | };
|
1965 | Object.defineProperty(exports, "__esModule", { value: true });
|
1966 | const AbstractMergeDateTimeRefiner_1 = __importDefault(require("../../../common/refiners/AbstractMergeDateTimeRefiner"));
|
1967 | class DEMergeDateTimeRefiner extends AbstractMergeDateTimeRefiner_1.default {
|
1968 | patternBetween() {
|
1969 | return new RegExp("^\\s*(T|um|am|,|-)?\\s*$");
|
1970 | }
|
1971 | }
|
1972 | exports.default = DEMergeDateTimeRefiner;
|
1973 |
|
1974 | },{"../../../common/refiners/AbstractMergeDateTimeRefiner":12}],30:[function(require,module,exports){
|
1975 | "use strict";
|
1976 | Object.defineProperty(exports, "__esModule", { value: true });
|
1977 | exports.parseTimeUnits = exports.TIME_UNITS_PATTERN = exports.parseYear = exports.YEAR_PATTERN = exports.parseOrdinalNumberPattern = exports.ORDINAL_NUMBER_PATTERN = exports.parseNumberPattern = exports.NUMBER_PATTERN = exports.TIME_UNIT_DICTIONARY = exports.ORDINAL_WORD_DICTIONARY = exports.INTEGER_WORD_DICTIONARY = exports.MONTH_DICTIONARY = exports.FULL_MONTH_NAME_DICTIONARY = exports.WEEKDAY_DICTIONARY = void 0;
|
1978 | const pattern_1 = require("../../utils/pattern");
|
1979 | const years_1 = require("../../calculation/years");
|
1980 | exports.WEEKDAY_DICTIONARY = {
|
1981 | sunday: 0,
|
1982 | sun: 0,
|
1983 | "sun.": 0,
|
1984 | monday: 1,
|
1985 | mon: 1,
|
1986 | "mon.": 1,
|
1987 | tuesday: 2,
|
1988 | tue: 2,
|
1989 | "tue.": 2,
|
1990 | wednesday: 3,
|
1991 | wed: 3,
|
1992 | "wed.": 3,
|
1993 | thursday: 4,
|
1994 | thurs: 4,
|
1995 | "thurs.": 4,
|
1996 | thur: 4,
|
1997 | "thur.": 4,
|
1998 | thu: 4,
|
1999 | "thu.": 4,
|
2000 | friday: 5,
|
2001 | fri: 5,
|
2002 | "fri.": 5,
|
2003 | saturday: 6,
|
2004 | sat: 6,
|
2005 | "sat.": 6,
|
2006 | };
|
2007 | exports.FULL_MONTH_NAME_DICTIONARY = {
|
2008 | january: 1,
|
2009 | february: 2,
|
2010 | march: 3,
|
2011 | april: 4,
|
2012 | may: 5,
|
2013 | june: 6,
|
2014 | july: 7,
|
2015 | august: 8,
|
2016 | september: 9,
|
2017 | october: 10,
|
2018 | november: 11,
|
2019 | december: 12,
|
2020 | };
|
2021 | exports.MONTH_DICTIONARY = Object.assign(Object.assign({}, exports.FULL_MONTH_NAME_DICTIONARY), { jan: 1, "jan.": 1, feb: 2, "feb.": 2, mar: 3, "mar.": 3, apr: 4, "apr.": 4, jun: 6, "jun.": 6, jul: 7, "jul.": 7, aug: 8, "aug.": 8, sep: 9, "sep.": 9, sept: 9, "sept.": 9, oct: 10, "oct.": 10, nov: 11, "nov.": 11, dec: 12, "dec.": 12 });
|
2022 | exports.INTEGER_WORD_DICTIONARY = {
|
2023 | one: 1,
|
2024 | two: 2,
|
2025 | three: 3,
|
2026 | four: 4,
|
2027 | five: 5,
|
2028 | six: 6,
|
2029 | seven: 7,
|
2030 | eight: 8,
|
2031 | nine: 9,
|
2032 | ten: 10,
|
2033 | eleven: 11,
|
2034 | twelve: 12,
|
2035 | };
|
2036 | exports.ORDINAL_WORD_DICTIONARY = {
|
2037 | first: 1,
|
2038 | second: 2,
|
2039 | third: 3,
|
2040 | fourth: 4,
|
2041 | fifth: 5,
|
2042 | sixth: 6,
|
2043 | seventh: 7,
|
2044 | eighth: 8,
|
2045 | ninth: 9,
|
2046 | tenth: 10,
|
2047 | eleventh: 11,
|
2048 | twelfth: 12,
|
2049 | thirteenth: 13,
|
2050 | fourteenth: 14,
|
2051 | fifteenth: 15,
|
2052 | sixteenth: 16,
|
2053 | seventeenth: 17,
|
2054 | eighteenth: 18,
|
2055 | nineteenth: 19,
|
2056 | twentieth: 20,
|
2057 | "twenty first": 21,
|
2058 | "twenty-first": 21,
|
2059 | "twenty second": 22,
|
2060 | "twenty-second": 22,
|
2061 | "twenty third": 23,
|
2062 | "twenty-third": 23,
|
2063 | "twenty fourth": 24,
|
2064 | "twenty-fourth": 24,
|
2065 | "twenty fifth": 25,
|
2066 | "twenty-fifth": 25,
|
2067 | "twenty sixth": 26,
|
2068 | "twenty-sixth": 26,
|
2069 | "twenty seventh": 27,
|
2070 | "twenty-seventh": 27,
|
2071 | "twenty eighth": 28,
|
2072 | "twenty-eighth": 28,
|
2073 | "twenty ninth": 29,
|
2074 | "twenty-ninth": 29,
|
2075 | "thirtieth": 30,
|
2076 | "thirty first": 31,
|
2077 | "thirty-first": 31,
|
2078 | };
|
2079 | exports.TIME_UNIT_DICTIONARY = {
|
2080 | sec: "second",
|
2081 | second: "second",
|
2082 | seconds: "second",
|
2083 | min: "minute",
|
2084 | mins: "minute",
|
2085 | minute: "minute",
|
2086 | minutes: "minute",
|
2087 | h: "hour",
|
2088 | hr: "hour",
|
2089 | hrs: "hour",
|
2090 | hour: "hour",
|
2091 | hours: "hour",
|
2092 | day: "d",
|
2093 | days: "d",
|
2094 | week: "week",
|
2095 | weeks: "week",
|
2096 | month: "month",
|
2097 | months: "month",
|
2098 | y: "year",
|
2099 | yr: "year",
|
2100 | year: "year",
|
2101 | years: "year",
|
2102 | };
|
2103 | exports.NUMBER_PATTERN = `(?:${pattern_1.matchAnyPattern(exports.INTEGER_WORD_DICTIONARY)}|[0-9]+|[0-9]+\\.[0-9]+|half(?:\\s*an?)?|an?(?:\\s*few)?|few|several|a?\\s*couple\\s*(?:of)?)`;
|
2104 | function parseNumberPattern(match) {
|
2105 | const num = match.toLowerCase();
|
2106 | if (exports.INTEGER_WORD_DICTIONARY[num] !== undefined) {
|
2107 | return exports.INTEGER_WORD_DICTIONARY[num];
|
2108 | }
|
2109 | else if (num === "a" || num === "an") {
|
2110 | return 1;
|
2111 | }
|
2112 | else if (num.match(/few/)) {
|
2113 | return 3;
|
2114 | }
|
2115 | else if (num.match(/half/)) {
|
2116 | return 0.5;
|
2117 | }
|
2118 | else if (num.match(/couple/)) {
|
2119 | return 2;
|
2120 | }
|
2121 | else if (num.match(/several/)) {
|
2122 | return 7;
|
2123 | }
|
2124 | return parseFloat(num);
|
2125 | }
|
2126 | exports.parseNumberPattern = parseNumberPattern;
|
2127 | exports.ORDINAL_NUMBER_PATTERN = `(?:${pattern_1.matchAnyPattern(exports.ORDINAL_WORD_DICTIONARY)}|[0-9]{1,2}(?:st|nd|rd|th)?)`;
|
2128 | function parseOrdinalNumberPattern(match) {
|
2129 | let num = match.toLowerCase();
|
2130 | if (exports.ORDINAL_WORD_DICTIONARY[num] !== undefined) {
|
2131 | return exports.ORDINAL_WORD_DICTIONARY[num];
|
2132 | }
|
2133 | num = num.replace(/(?:st|nd|rd|th)$/i, "");
|
2134 | return parseInt(num);
|
2135 | }
|
2136 | exports.parseOrdinalNumberPattern = parseOrdinalNumberPattern;
|
2137 | exports.YEAR_PATTERN = `(?:[1-9][0-9]{0,3}\\s*(?:BE|AD|BC|BCE|CE)|[1-2][0-9]{3}|[5-9][0-9])`;
|
2138 | function parseYear(match) {
|
2139 | if (/BE/i.test(match)) {
|
2140 | match = match.replace(/BE/i, "");
|
2141 | return parseInt(match) - 543;
|
2142 | }
|
2143 | if (/BCE?/i.test(match)) {
|
2144 | match = match.replace(/BCE?/i, "");
|
2145 | return -parseInt(match);
|
2146 | }
|
2147 | if (/(AD|CE)/i.test(match)) {
|
2148 | match = match.replace(/(AD|CE)/i, "");
|
2149 | return parseInt(match);
|
2150 | }
|
2151 | const rawYearNumber = parseInt(match);
|
2152 | return years_1.findMostLikelyADYear(rawYearNumber);
|
2153 | }
|
2154 | exports.parseYear = parseYear;
|
2155 | const SINGLE_TIME_UNIT_PATTERN = `(${exports.NUMBER_PATTERN})\\s{0,5}(${pattern_1.matchAnyPattern(exports.TIME_UNIT_DICTIONARY)})\\s{0,5}`;
|
2156 | const SINGLE_TIME_UNIT_REGEX = new RegExp(SINGLE_TIME_UNIT_PATTERN, "i");
|
2157 | exports.TIME_UNITS_PATTERN = pattern_1.repeatedTimeunitPattern(`(?:(?:about|around)\\s*)?`, SINGLE_TIME_UNIT_PATTERN);
|
2158 | function parseTimeUnits(timeunitText) {
|
2159 | const fragments = {};
|
2160 | let remainingText = timeunitText;
|
2161 | let match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
2162 | while (match) {
|
2163 | collectDateTimeFragment(fragments, match);
|
2164 | remainingText = remainingText.substring(match[0].length);
|
2165 | match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
2166 | }
|
2167 | return fragments;
|
2168 | }
|
2169 | exports.parseTimeUnits = parseTimeUnits;
|
2170 | function collectDateTimeFragment(fragments, match) {
|
2171 | const num = parseNumberPattern(match[1]);
|
2172 | const unit = exports.TIME_UNIT_DICTIONARY[match[2].toLowerCase()];
|
2173 | fragments[unit] = num;
|
2174 | }
|
2175 |
|
2176 | },{"../../calculation/years":3,"../../utils/pattern":91}],31:[function(require,module,exports){
|
2177 | "use strict";
|
2178 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
2179 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
2180 | };
|
2181 | Object.defineProperty(exports, "__esModule", { value: true });
|
2182 | exports.createConfiguration = exports.createCasualConfiguration = exports.parseDate = exports.parse = exports.GB = exports.strict = exports.casual = void 0;
|
2183 | const ENTimeUnitWithinFormatParser_1 = __importDefault(require("./parsers/ENTimeUnitWithinFormatParser"));
|
2184 | const ENMonthNameLittleEndianParser_1 = __importDefault(require("./parsers/ENMonthNameLittleEndianParser"));
|
2185 | const ENMonthNameMiddleEndianParser_1 = __importDefault(require("./parsers/ENMonthNameMiddleEndianParser"));
|
2186 | const ENMonthNameParser_1 = __importDefault(require("./parsers/ENMonthNameParser"));
|
2187 | const ENCasualYearMonthDayParser_1 = __importDefault(require("./parsers/ENCasualYearMonthDayParser"));
|
2188 | const ENSlashMonthFormatParser_1 = __importDefault(require("./parsers/ENSlashMonthFormatParser"));
|
2189 | const ENTimeExpressionParser_1 = __importDefault(require("./parsers/ENTimeExpressionParser"));
|
2190 | const ENTimeUnitAgoFormatParser_1 = __importDefault(require("./parsers/ENTimeUnitAgoFormatParser"));
|
2191 | const ENTimeUnitLaterFormatParser_1 = __importDefault(require("./parsers/ENTimeUnitLaterFormatParser"));
|
2192 | const ENMergeDateRangeRefiner_1 = __importDefault(require("./refiners/ENMergeDateRangeRefiner"));
|
2193 | const ENMergeDateTimeRefiner_1 = __importDefault(require("./refiners/ENMergeDateTimeRefiner"));
|
2194 | const configurations_1 = require("../../configurations");
|
2195 | const ENCasualDateParser_1 = __importDefault(require("./parsers/ENCasualDateParser"));
|
2196 | const ENCasualTimeParser_1 = __importDefault(require("./parsers/ENCasualTimeParser"));
|
2197 | const ENWeekdayParser_1 = __importDefault(require("./parsers/ENWeekdayParser"));
|
2198 | const ENRelativeDateFormatParser_1 = __importDefault(require("./parsers/ENRelativeDateFormatParser"));
|
2199 | const chrono_1 = require("../../chrono");
|
2200 | const SlashDateFormatParser_1 = __importDefault(require("../../common/parsers/SlashDateFormatParser"));
|
2201 | const ENTimeUnitCasualRelativeFormatParser_1 = __importDefault(require("./parsers/ENTimeUnitCasualRelativeFormatParser"));
|
2202 | exports.casual = new chrono_1.Chrono(createCasualConfiguration(false));
|
2203 | exports.strict = new chrono_1.Chrono(createConfiguration(true, false));
|
2204 | exports.GB = new chrono_1.Chrono(createConfiguration(false, true));
|
2205 | function parse(text, ref, option) {
|
2206 | return exports.casual.parse(text, ref, option);
|
2207 | }
|
2208 | exports.parse = parse;
|
2209 | function parseDate(text, ref, option) {
|
2210 | return exports.casual.parseDate(text, ref, option);
|
2211 | }
|
2212 | exports.parseDate = parseDate;
|
2213 | function createCasualConfiguration(littleEndian = false) {
|
2214 | const option = createConfiguration(false, littleEndian);
|
2215 | option.parsers.unshift(new ENCasualDateParser_1.default());
|
2216 | option.parsers.unshift(new ENCasualTimeParser_1.default());
|
2217 | option.parsers.unshift(new ENMonthNameParser_1.default());
|
2218 | option.parsers.unshift(new ENRelativeDateFormatParser_1.default());
|
2219 | option.parsers.unshift(new ENTimeUnitCasualRelativeFormatParser_1.default());
|
2220 | return option;
|
2221 | }
|
2222 | exports.createCasualConfiguration = createCasualConfiguration;
|
2223 | function createConfiguration(strictMode = true, littleEndian = false) {
|
2224 | return configurations_1.includeCommonConfiguration({
|
2225 | parsers: [
|
2226 | new SlashDateFormatParser_1.default(littleEndian),
|
2227 | new ENTimeUnitWithinFormatParser_1.default(),
|
2228 | new ENMonthNameLittleEndianParser_1.default(),
|
2229 | new ENMonthNameMiddleEndianParser_1.default(),
|
2230 | new ENWeekdayParser_1.default(),
|
2231 | new ENCasualYearMonthDayParser_1.default(),
|
2232 | new ENSlashMonthFormatParser_1.default(),
|
2233 | new ENTimeExpressionParser_1.default(strictMode),
|
2234 | new ENTimeUnitAgoFormatParser_1.default(strictMode),
|
2235 | new ENTimeUnitLaterFormatParser_1.default(strictMode),
|
2236 | ],
|
2237 | refiners: [new ENMergeDateTimeRefiner_1.default(), new ENMergeDateRangeRefiner_1.default()],
|
2238 | }, strictMode);
|
2239 | }
|
2240 | exports.createConfiguration = createConfiguration;
|
2241 |
|
2242 | },{"../../chrono":4,"../../common/parsers/SlashDateFormatParser":10,"../../configurations":19,"./parsers/ENCasualDateParser":32,"./parsers/ENCasualTimeParser":33,"./parsers/ENCasualYearMonthDayParser":34,"./parsers/ENMonthNameLittleEndianParser":35,"./parsers/ENMonthNameMiddleEndianParser":36,"./parsers/ENMonthNameParser":37,"./parsers/ENRelativeDateFormatParser":38,"./parsers/ENSlashMonthFormatParser":39,"./parsers/ENTimeExpressionParser":40,"./parsers/ENTimeUnitAgoFormatParser":41,"./parsers/ENTimeUnitCasualRelativeFormatParser":42,"./parsers/ENTimeUnitLaterFormatParser":43,"./parsers/ENTimeUnitWithinFormatParser":44,"./parsers/ENWeekdayParser":45,"./refiners/ENMergeDateRangeRefiner":46,"./refiners/ENMergeDateTimeRefiner":47}],32:[function(require,module,exports){
|
2243 | "use strict";
|
2244 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
2245 | if (k2 === undefined) k2 = k;
|
2246 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
2247 | }) : (function(o, m, k, k2) {
|
2248 | if (k2 === undefined) k2 = k;
|
2249 | o[k2] = m[k];
|
2250 | }));
|
2251 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
2252 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
2253 | }) : function(o, v) {
|
2254 | o["default"] = v;
|
2255 | });
|
2256 | var __importStar = (this && this.__importStar) || function (mod) {
|
2257 | if (mod && mod.__esModule) return mod;
|
2258 | var result = {};
|
2259 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
2260 | __setModuleDefault(result, mod);
|
2261 | return result;
|
2262 | };
|
2263 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
2264 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
2265 | };
|
2266 | Object.defineProperty(exports, "__esModule", { value: true });
|
2267 | const dayjs_1 = __importDefault(require("dayjs"));
|
2268 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
2269 | const dayjs_2 = require("../../../utils/dayjs");
|
2270 | const references = __importStar(require("../../../common/casualReferences"));
|
2271 | const PATTERN = /(now|today|tonight|tomorrow|tmr|tmrw|yesterday|last\s*night)(?=\W|$)/i;
|
2272 | class ENCasualDateParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
2273 | innerPattern(context) {
|
2274 | return PATTERN;
|
2275 | }
|
2276 | innerExtract(context, match) {
|
2277 | let targetDate = dayjs_1.default(context.refDate);
|
2278 | const lowerText = match[0].toLowerCase();
|
2279 | const component = context.createParsingComponents();
|
2280 | switch (lowerText) {
|
2281 | case "now":
|
2282 | return references.now(context.refDate);
|
2283 | case "today":
|
2284 | return references.today(context.refDate);
|
2285 | case "yesterday":
|
2286 | return references.yesterday(context.refDate);
|
2287 | case "tomorrow":
|
2288 | case "tmr":
|
2289 | case "tmrw":
|
2290 | return references.tomorrow(context.refDate);
|
2291 | case "tonight":
|
2292 | return references.tonight(context.refDate);
|
2293 | default:
|
2294 | if (lowerText.match(/last\s*night/)) {
|
2295 | if (targetDate.hour() > 6) {
|
2296 | targetDate = targetDate.add(-1, "day");
|
2297 | }
|
2298 | dayjs_2.assignSimilarDate(component, targetDate);
|
2299 | component.imply("hour", 0);
|
2300 | }
|
2301 | break;
|
2302 | }
|
2303 | return component;
|
2304 | }
|
2305 | }
|
2306 | exports.default = ENCasualDateParser;
|
2307 |
|
2308 | },{"../../../common/casualReferences":6,"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../utils/dayjs":90,"dayjs":93}],33:[function(require,module,exports){
|
2309 | "use strict";
|
2310 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
2311 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
2312 | };
|
2313 | Object.defineProperty(exports, "__esModule", { value: true });
|
2314 | const index_1 = require("../../../index");
|
2315 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
2316 | const dayjs_1 = __importDefault(require("dayjs"));
|
2317 | const dayjs_2 = require("../../../utils/dayjs");
|
2318 | const PATTERN = /(?:this)?\s*(morning|afternoon|evening|night|midnight|noon)(?=\W|$)/i;
|
2319 | class ENCasualTimeParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
2320 | innerPattern() {
|
2321 | return PATTERN;
|
2322 | }
|
2323 | innerExtract(context, match) {
|
2324 | const targetDate = dayjs_1.default(context.refDate);
|
2325 | const component = context.createParsingComponents();
|
2326 | switch (match[1].toLowerCase()) {
|
2327 | case "afternoon":
|
2328 | component.imply("meridiem", index_1.Meridiem.PM);
|
2329 | component.imply("hour", 15);
|
2330 | break;
|
2331 | case "evening":
|
2332 | case "night":
|
2333 | component.imply("meridiem", index_1.Meridiem.PM);
|
2334 | component.imply("hour", 20);
|
2335 | break;
|
2336 | case "midnight":
|
2337 | dayjs_2.assignTheNextDay(component, targetDate);
|
2338 | component.imply("hour", 0);
|
2339 | component.imply("minute", 0);
|
2340 | component.imply("second", 0);
|
2341 | break;
|
2342 | case "morning":
|
2343 | component.imply("meridiem", index_1.Meridiem.AM);
|
2344 | component.imply("hour", 6);
|
2345 | break;
|
2346 | case "noon":
|
2347 | component.imply("meridiem", index_1.Meridiem.AM);
|
2348 | component.imply("hour", 12);
|
2349 | break;
|
2350 | }
|
2351 | return component;
|
2352 | }
|
2353 | }
|
2354 | exports.default = ENCasualTimeParser;
|
2355 |
|
2356 | },{"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../index":20,"../../../utils/dayjs":90,"dayjs":93}],34:[function(require,module,exports){
|
2357 | "use strict";
|
2358 | Object.defineProperty(exports, "__esModule", { value: true });
|
2359 | const constants_1 = require("../constants");
|
2360 | const pattern_1 = require("../../../utils/pattern");
|
2361 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
2362 | const PATTERN = new RegExp(`([0-9]{4})[\\.\\/\\s]` +
|
2363 | `(?:(${pattern_1.matchAnyPattern(constants_1.MONTH_DICTIONARY)})|([0-9]{1,2}))[\\.\\/\\s]` +
|
2364 | `([0-9]{1,2})` +
|
2365 | "(?=\\W|$)", "i");
|
2366 | const YEAR_NUMBER_GROUP = 1;
|
2367 | const MONTH_NAME_GROUP = 2;
|
2368 | const MONTH_NUMBER_GROUP = 3;
|
2369 | const DATE_NUMBER_GROUP = 4;
|
2370 | class ENCasualYearMonthDayParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
2371 | innerPattern() {
|
2372 | return PATTERN;
|
2373 | }
|
2374 | innerExtract(context, match) {
|
2375 | const month = match[MONTH_NUMBER_GROUP]
|
2376 | ? parseInt(match[MONTH_NUMBER_GROUP])
|
2377 | : constants_1.MONTH_DICTIONARY[match[MONTH_NAME_GROUP].toLowerCase()];
|
2378 | if (month < 1 || month > 12) {
|
2379 | return null;
|
2380 | }
|
2381 | const year = parseInt(match[YEAR_NUMBER_GROUP]);
|
2382 | const day = parseInt(match[DATE_NUMBER_GROUP]);
|
2383 | return {
|
2384 | day: day,
|
2385 | month: month,
|
2386 | year: year,
|
2387 | };
|
2388 | }
|
2389 | }
|
2390 | exports.default = ENCasualYearMonthDayParser;
|
2391 |
|
2392 | },{"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../utils/pattern":91,"../constants":30}],35:[function(require,module,exports){
|
2393 | "use strict";
|
2394 | Object.defineProperty(exports, "__esModule", { value: true });
|
2395 | const years_1 = require("../../../calculation/years");
|
2396 | const constants_1 = require("../constants");
|
2397 | const constants_2 = require("../constants");
|
2398 | const constants_3 = require("../constants");
|
2399 | const pattern_1 = require("../../../utils/pattern");
|
2400 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
2401 | const PATTERN = new RegExp("(?:on\\s*?)?" +
|
2402 | `(${constants_3.ORDINAL_NUMBER_PATTERN})` +
|
2403 | "(?:\\s*" +
|
2404 | "(?:to|\\-|\\–|until|through|till|\\s)\\s*" +
|
2405 | `(${constants_3.ORDINAL_NUMBER_PATTERN})` +
|
2406 | ")?" +
|
2407 | "(?:-|/|\\s*(?:of)?\\s*)" +
|
2408 | "(" +
|
2409 | pattern_1.matchAnyPattern(constants_1.MONTH_DICTIONARY) +
|
2410 | ")" +
|
2411 | "(?:" +
|
2412 | "(?:-|/|,?\\s*)" +
|
2413 | `(${constants_2.YEAR_PATTERN}(?![^\\s]\\d))` +
|
2414 | ")?" +
|
2415 | "(?=\\W|$)", "i");
|
2416 | const DATE_GROUP = 1;
|
2417 | const DATE_TO_GROUP = 2;
|
2418 | const MONTH_NAME_GROUP = 3;
|
2419 | const YEAR_GROUP = 4;
|
2420 | class ENMonthNameLittleEndianParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
2421 | innerPattern() {
|
2422 | return PATTERN;
|
2423 | }
|
2424 | innerExtract(context, match) {
|
2425 | const result = context.createParsingResult(match.index, match[0]);
|
2426 | const month = constants_1.MONTH_DICTIONARY[match[MONTH_NAME_GROUP].toLowerCase()];
|
2427 | const day = constants_3.parseOrdinalNumberPattern(match[DATE_GROUP]);
|
2428 | if (day > 31) {
|
2429 | match.index = match.index + match[DATE_GROUP].length;
|
2430 | return null;
|
2431 | }
|
2432 | result.start.assign("month", month);
|
2433 | result.start.assign("day", day);
|
2434 | if (match[YEAR_GROUP]) {
|
2435 | const yearNumber = constants_2.parseYear(match[YEAR_GROUP]);
|
2436 | result.start.assign("year", yearNumber);
|
2437 | }
|
2438 | else {
|
2439 | const year = years_1.findYearClosestToRef(context.refDate, day, month);
|
2440 | result.start.imply("year", year);
|
2441 | }
|
2442 | if (match[DATE_TO_GROUP]) {
|
2443 | const endDate = constants_3.parseOrdinalNumberPattern(match[DATE_TO_GROUP]);
|
2444 | result.end = result.start.clone();
|
2445 | result.end.assign("day", endDate);
|
2446 | }
|
2447 | return result;
|
2448 | }
|
2449 | }
|
2450 | exports.default = ENMonthNameLittleEndianParser;
|
2451 |
|
2452 | },{"../../../calculation/years":3,"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../utils/pattern":91,"../constants":30}],36:[function(require,module,exports){
|
2453 | "use strict";
|
2454 | Object.defineProperty(exports, "__esModule", { value: true });
|
2455 | const years_1 = require("../../../calculation/years");
|
2456 | const constants_1 = require("../constants");
|
2457 | const constants_2 = require("../constants");
|
2458 | const constants_3 = require("../constants");
|
2459 | const pattern_1 = require("../../../utils/pattern");
|
2460 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
2461 | const PATTERN = new RegExp(`(${pattern_1.matchAnyPattern(constants_1.MONTH_DICTIONARY)})` +
|
2462 | "(?:-|/|\\s*,?\\s*)" +
|
2463 | `(${constants_2.ORDINAL_NUMBER_PATTERN})(?!\\s*(?:am|pm))\\s*` +
|
2464 | "(?:" +
|
2465 | "(?:to|\\-)\\s*" +
|
2466 | `(${constants_2.ORDINAL_NUMBER_PATTERN})\\s*` +
|
2467 | ")?" +
|
2468 | "(?:" +
|
2469 | "(?:-|/|\\s*,?\\s*)" +
|
2470 | `(${constants_3.YEAR_PATTERN})` +
|
2471 | ")?" +
|
2472 | "(?=\\W|$)(?!\\:\\d)", "i");
|
2473 | const MONTH_NAME_GROUP = 1;
|
2474 | const DATE_GROUP = 2;
|
2475 | const DATE_TO_GROUP = 3;
|
2476 | const YEAR_GROUP = 4;
|
2477 | class ENMonthNameMiddleEndianParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
2478 | innerPattern() {
|
2479 | return PATTERN;
|
2480 | }
|
2481 | innerExtract(context, match) {
|
2482 | const month = constants_1.MONTH_DICTIONARY[match[MONTH_NAME_GROUP].toLowerCase()];
|
2483 | const day = constants_2.parseOrdinalNumberPattern(match[DATE_GROUP]);
|
2484 | if (day > 31) {
|
2485 | return null;
|
2486 | }
|
2487 | const components = context.createParsingComponents({
|
2488 | day: day,
|
2489 | month: month,
|
2490 | });
|
2491 | if (match[YEAR_GROUP]) {
|
2492 | const year = constants_3.parseYear(match[YEAR_GROUP]);
|
2493 | components.assign("year", year);
|
2494 | }
|
2495 | else {
|
2496 | const year = years_1.findYearClosestToRef(context.refDate, day, month);
|
2497 | components.imply("year", year);
|
2498 | }
|
2499 | if (!match[DATE_TO_GROUP]) {
|
2500 | return components;
|
2501 | }
|
2502 | const endDate = constants_2.parseOrdinalNumberPattern(match[DATE_TO_GROUP]);
|
2503 | const result = context.createParsingResult(match.index, match[0]);
|
2504 | result.start = components;
|
2505 | result.end = components.clone();
|
2506 | result.end.assign("day", endDate);
|
2507 | return result;
|
2508 | }
|
2509 | }
|
2510 | exports.default = ENMonthNameMiddleEndianParser;
|
2511 |
|
2512 | },{"../../../calculation/years":3,"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../utils/pattern":91,"../constants":30}],37:[function(require,module,exports){
|
2513 | "use strict";
|
2514 | Object.defineProperty(exports, "__esModule", { value: true });
|
2515 | const constants_1 = require("../constants");
|
2516 | const years_1 = require("../../../calculation/years");
|
2517 | const pattern_1 = require("../../../utils/pattern");
|
2518 | const constants_2 = require("../constants");
|
2519 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
2520 | const PATTERN = new RegExp(`((?:in)\\s*)?` +
|
2521 | `(${pattern_1.matchAnyPattern(constants_1.MONTH_DICTIONARY)})` +
|
2522 | `\\s*` +
|
2523 | `(?:` +
|
2524 | `[,-]?\\s*(${constants_2.YEAR_PATTERN})?` +
|
2525 | ")?" +
|
2526 | "(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)", "i");
|
2527 | const PREFIX_GROUP = 1;
|
2528 | const MONTH_NAME_GROUP = 2;
|
2529 | const YEAR_GROUP = 3;
|
2530 | class ENMonthNameParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
2531 | innerPattern() {
|
2532 | return PATTERN;
|
2533 | }
|
2534 | innerExtract(context, match) {
|
2535 | const monthName = match[MONTH_NAME_GROUP].toLowerCase();
|
2536 | if (match[0].length <= 3 && !constants_1.FULL_MONTH_NAME_DICTIONARY[monthName]) {
|
2537 | return null;
|
2538 | }
|
2539 | const result = context.createParsingResult(match.index + (match[PREFIX_GROUP] || "").length, match.index + match[0].length);
|
2540 | result.start.imply("day", 1);
|
2541 | const month = constants_1.MONTH_DICTIONARY[monthName];
|
2542 | result.start.assign("month", month);
|
2543 | if (match[YEAR_GROUP]) {
|
2544 | const year = constants_2.parseYear(match[YEAR_GROUP]);
|
2545 | result.start.assign("year", year);
|
2546 | }
|
2547 | else {
|
2548 | const year = years_1.findYearClosestToRef(context.refDate, 1, month);
|
2549 | result.start.imply("year", year);
|
2550 | }
|
2551 | return result;
|
2552 | }
|
2553 | }
|
2554 | exports.default = ENMonthNameParser;
|
2555 |
|
2556 | },{"../../../calculation/years":3,"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../utils/pattern":91,"../constants":30}],38:[function(require,module,exports){
|
2557 | "use strict";
|
2558 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
2559 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
2560 | };
|
2561 | Object.defineProperty(exports, "__esModule", { value: true });
|
2562 | const constants_1 = require("../constants");
|
2563 | const results_1 = require("../../../results");
|
2564 | const dayjs_1 = __importDefault(require("dayjs"));
|
2565 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
2566 | const pattern_1 = require("../../../utils/pattern");
|
2567 | const PATTERN = new RegExp(`(this|next|last|past)\\s*(${pattern_1.matchAnyPattern(constants_1.TIME_UNIT_DICTIONARY)})(?=\\s*)` + "(?=\\W|$)", "i");
|
2568 | const MODIFIER_WORD_GROUP = 1;
|
2569 | const RELATIVE_WORD_GROUP = 2;
|
2570 | class ENRelativeDateFormatParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
2571 | innerPattern() {
|
2572 | return PATTERN;
|
2573 | }
|
2574 | innerExtract(context, match) {
|
2575 | const modifier = match[MODIFIER_WORD_GROUP].toLowerCase();
|
2576 | const unitWord = match[RELATIVE_WORD_GROUP].toLowerCase();
|
2577 | const timeunit = constants_1.TIME_UNIT_DICTIONARY[unitWord];
|
2578 | if (modifier == "next") {
|
2579 | const timeUnits = {};
|
2580 | timeUnits[timeunit] = 1;
|
2581 | return results_1.ParsingComponents.createRelativeFromRefDate(context.refDate, timeUnits);
|
2582 | }
|
2583 | if (modifier == "last" || modifier == "past") {
|
2584 | const timeUnits = {};
|
2585 | timeUnits[timeunit] = -1;
|
2586 | return results_1.ParsingComponents.createRelativeFromRefDate(context.refDate, timeUnits);
|
2587 | }
|
2588 | const components = context.createParsingComponents();
|
2589 | let date = dayjs_1.default(context.refDate);
|
2590 | if (unitWord.match(/week/i)) {
|
2591 | date = date.add(-date.get("d"), "d");
|
2592 | components.imply("day", date.date());
|
2593 | components.imply("month", date.month() + 1);
|
2594 | components.imply("year", date.year());
|
2595 | }
|
2596 | else if (unitWord.match(/month/i)) {
|
2597 | date = date.add(-date.date() + 1, "d");
|
2598 | components.imply("day", date.date());
|
2599 | components.assign("year", date.year());
|
2600 | components.assign("month", date.month() + 1);
|
2601 | }
|
2602 | else if (unitWord.match(/year/i)) {
|
2603 | date = date.add(-date.date() + 1, "d");
|
2604 | date = date.add(-date.month(), "month");
|
2605 | components.imply("day", date.date());
|
2606 | components.imply("month", date.month() + 1);
|
2607 | components.assign("year", date.year());
|
2608 | }
|
2609 | return components;
|
2610 | }
|
2611 | }
|
2612 | exports.default = ENRelativeDateFormatParser;
|
2613 |
|
2614 | },{"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../results":89,"../../../utils/pattern":91,"../constants":30,"dayjs":93}],39:[function(require,module,exports){
|
2615 | "use strict";
|
2616 | Object.defineProperty(exports, "__esModule", { value: true });
|
2617 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
2618 | const PATTERN = new RegExp("([0-9]|0[1-9]|1[012])/([0-9]{4})" + "", "i");
|
2619 | const MONTH_GROUP = 1;
|
2620 | const YEAR_GROUP = 2;
|
2621 | class ENSlashMonthFormatParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
2622 | innerPattern() {
|
2623 | return PATTERN;
|
2624 | }
|
2625 | innerExtract(context, match) {
|
2626 | const year = parseInt(match[YEAR_GROUP]);
|
2627 | const month = parseInt(match[MONTH_GROUP]);
|
2628 | return context.createParsingComponents().imply("day", 1).assign("month", month).assign("year", year);
|
2629 | }
|
2630 | }
|
2631 | exports.default = ENSlashMonthFormatParser;
|
2632 |
|
2633 | },{"../../../common/parsers/AbstractParserWithWordBoundary":7}],40:[function(require,module,exports){
|
2634 | "use strict";
|
2635 | Object.defineProperty(exports, "__esModule", { value: true });
|
2636 | const index_1 = require("../../../index");
|
2637 | const AbstractTimeExpressionParser_1 = require("../../../common/parsers/AbstractTimeExpressionParser");
|
2638 | class ENTimeExpressionParser extends AbstractTimeExpressionParser_1.AbstractTimeExpressionParser {
|
2639 | constructor(strictMode) {
|
2640 | super(strictMode);
|
2641 | }
|
2642 | followingPhase() {
|
2643 | return "\\s*(?:\\-|\\–|\\~|\\〜|to|\\?)\\s*";
|
2644 | }
|
2645 | primaryPrefix() {
|
2646 | return "(?:(?:at|from)\\s*)??";
|
2647 | }
|
2648 | primarySuffix() {
|
2649 | return "(?:\\s*(?:o\\W*clock|at\\s*night|in\\s*the\\s*(?:morning|afternoon)))?(?!/)(?=\\W|$)";
|
2650 | }
|
2651 | extractPrimaryTimeComponents(context, match) {
|
2652 | const components = super.extractPrimaryTimeComponents(context, match);
|
2653 | if (components) {
|
2654 | if (match[0].endsWith("night")) {
|
2655 | const hour = components.get("hour");
|
2656 | if (hour >= 6 && hour < 12) {
|
2657 | components.assign("hour", components.get("hour") + 12);
|
2658 | components.assign("meridiem", index_1.Meridiem.PM);
|
2659 | }
|
2660 | else if (hour < 6) {
|
2661 | components.assign("meridiem", index_1.Meridiem.AM);
|
2662 | }
|
2663 | }
|
2664 | if (match[0].endsWith("afternoon")) {
|
2665 | components.assign("meridiem", index_1.Meridiem.PM);
|
2666 | const hour = components.get("hour");
|
2667 | if (hour >= 0 && hour <= 6) {
|
2668 | components.assign("hour", components.get("hour") + 12);
|
2669 | }
|
2670 | }
|
2671 | if (match[0].endsWith("morning")) {
|
2672 | components.assign("meridiem", index_1.Meridiem.AM);
|
2673 | const hour = components.get("hour");
|
2674 | if (hour < 12) {
|
2675 | components.assign("hour", components.get("hour"));
|
2676 | }
|
2677 | }
|
2678 | }
|
2679 | return components;
|
2680 | }
|
2681 | }
|
2682 | exports.default = ENTimeExpressionParser;
|
2683 |
|
2684 | },{"../../../common/parsers/AbstractTimeExpressionParser":8,"../../../index":20}],41:[function(require,module,exports){
|
2685 | "use strict";
|
2686 | Object.defineProperty(exports, "__esModule", { value: true });
|
2687 | const constants_1 = require("../constants");
|
2688 | const results_1 = require("../../../results");
|
2689 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
2690 | const timeunits_1 = require("../../../utils/timeunits");
|
2691 | const PATTERN = new RegExp("" + "(" + constants_1.TIME_UNITS_PATTERN + ")" + "(?:ago|before|earlier)(?=(?:\\W|$))", "i");
|
2692 | const STRICT_PATTERN = new RegExp("" + "(" + constants_1.TIME_UNITS_PATTERN + ")" + "ago(?=(?:\\W|$))", "i");
|
2693 | class ENTimeUnitAgoFormatParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
2694 | constructor(strictMode) {
|
2695 | super();
|
2696 | this.strictMode = strictMode;
|
2697 | }
|
2698 | innerPattern() {
|
2699 | return this.strictMode ? STRICT_PATTERN : PATTERN;
|
2700 | }
|
2701 | innerExtract(context, match) {
|
2702 | const timeUnits = constants_1.parseTimeUnits(match[1]);
|
2703 | const outputTimeUnits = timeunits_1.reverseTimeUnits(timeUnits);
|
2704 | return results_1.ParsingComponents.createRelativeFromRefDate(context.refDate, outputTimeUnits);
|
2705 | }
|
2706 | }
|
2707 | exports.default = ENTimeUnitAgoFormatParser;
|
2708 |
|
2709 | },{"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../results":89,"../../../utils/timeunits":92,"../constants":30}],42:[function(require,module,exports){
|
2710 | "use strict";
|
2711 | Object.defineProperty(exports, "__esModule", { value: true });
|
2712 | const constants_1 = require("../constants");
|
2713 | const results_1 = require("../../../results");
|
2714 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
2715 | const timeunits_1 = require("../../../utils/timeunits");
|
2716 | const PATTERN = new RegExp(`(this|last|past|next|\\+|-)\\s*(${constants_1.TIME_UNITS_PATTERN})(?=\\W|$)`, "i");
|
2717 | class ENTimeUnitCasualRelativeFormatParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
2718 | innerPattern() {
|
2719 | return PATTERN;
|
2720 | }
|
2721 | innerExtract(context, match) {
|
2722 | const prefix = match[1].toLowerCase();
|
2723 | let timeUnits = constants_1.parseTimeUnits(match[2]);
|
2724 | switch (prefix) {
|
2725 | case "last":
|
2726 | case "past":
|
2727 | case "-":
|
2728 | timeUnits = timeunits_1.reverseTimeUnits(timeUnits);
|
2729 | break;
|
2730 | }
|
2731 | return results_1.ParsingComponents.createRelativeFromRefDate(context.refDate, timeUnits);
|
2732 | }
|
2733 | }
|
2734 | exports.default = ENTimeUnitCasualRelativeFormatParser;
|
2735 |
|
2736 | },{"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../results":89,"../../../utils/timeunits":92,"../constants":30}],43:[function(require,module,exports){
|
2737 | "use strict";
|
2738 | Object.defineProperty(exports, "__esModule", { value: true });
|
2739 | const constants_1 = require("../constants");
|
2740 | const results_1 = require("../../../results");
|
2741 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
2742 | const PATTERN = new RegExp("" + "(" + constants_1.TIME_UNITS_PATTERN + ")" + "(later|after|from now|henceforth|forward|out)" + "(?=(?:\\W|$))", "i");
|
2743 | const STRICT_PATTERN = new RegExp("" + "(" + constants_1.TIME_UNITS_PATTERN + ")" + "(later|from now)" + "(?=(?:\\W|$))", "i");
|
2744 | const GROUP_NUM_TIMEUNITS = 1;
|
2745 | class ENTimeUnitLaterFormatParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
2746 | constructor(strictMode) {
|
2747 | super();
|
2748 | this.strictMode = strictMode;
|
2749 | }
|
2750 | innerPattern() {
|
2751 | return this.strictMode ? STRICT_PATTERN : PATTERN;
|
2752 | }
|
2753 | innerExtract(context, match) {
|
2754 | const fragments = constants_1.parseTimeUnits(match[GROUP_NUM_TIMEUNITS]);
|
2755 | return results_1.ParsingComponents.createRelativeFromRefDate(context.refDate, fragments);
|
2756 | }
|
2757 | }
|
2758 | exports.default = ENTimeUnitLaterFormatParser;
|
2759 |
|
2760 | },{"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../results":89,"../constants":30}],44:[function(require,module,exports){
|
2761 | "use strict";
|
2762 | Object.defineProperty(exports, "__esModule", { value: true });
|
2763 | const constants_1 = require("../constants");
|
2764 | const results_1 = require("../../../results");
|
2765 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
2766 | const PATTERN_WITH_PREFIX = new RegExp(`(?:within|in|for)\\s*` +
|
2767 | `(?:(?:about|around|roughly|approximately|just)\\s*(?:~\\s*)?)?(${constants_1.TIME_UNITS_PATTERN})(?=\\W|$)`, "i");
|
2768 | const PATTERN_WITHOUT_PREFIX = new RegExp(`(?:(?:about|around|roughly|approximately|just)\\s*(?:~\\s*)?)?(${constants_1.TIME_UNITS_PATTERN})(?=\\W|$)`, "i");
|
2769 | class ENTimeUnitWithinFormatParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
2770 | innerPattern(context) {
|
2771 | return context.option.forwardDate ? PATTERN_WITHOUT_PREFIX : PATTERN_WITH_PREFIX;
|
2772 | }
|
2773 | innerExtract(context, match) {
|
2774 | const timeUnits = constants_1.parseTimeUnits(match[1]);
|
2775 | return results_1.ParsingComponents.createRelativeFromRefDate(context.refDate, timeUnits);
|
2776 | }
|
2777 | }
|
2778 | exports.default = ENTimeUnitWithinFormatParser;
|
2779 |
|
2780 | },{"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../results":89,"../constants":30}],45:[function(require,module,exports){
|
2781 | "use strict";
|
2782 | Object.defineProperty(exports, "__esModule", { value: true });
|
2783 | const constants_1 = require("../constants");
|
2784 | const pattern_1 = require("../../../utils/pattern");
|
2785 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
2786 | const weeks_1 = require("../../../calculation/weeks");
|
2787 | const PATTERN = new RegExp("(?:(?:\\,|\\(|\\()\\s*)?" +
|
2788 | "(?:on\\s*?)?" +
|
2789 | "(?:(this|last|past|next)\\s*)?" +
|
2790 | `(${pattern_1.matchAnyPattern(constants_1.WEEKDAY_DICTIONARY)})` +
|
2791 | "(?:\\s*(?:\\,|\\)|\\)))?" +
|
2792 | "(?:\\s*(this|last|past|next)\\s*week)?" +
|
2793 | "(?=\\W|$)", "i");
|
2794 | const PREFIX_GROUP = 1;
|
2795 | const WEEKDAY_GROUP = 2;
|
2796 | const POSTFIX_GROUP = 3;
|
2797 | class ENWeekdayParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
2798 | innerPattern() {
|
2799 | return PATTERN;
|
2800 | }
|
2801 | innerExtract(context, match) {
|
2802 | const dayOfWeek = match[WEEKDAY_GROUP].toLowerCase();
|
2803 | const offset = constants_1.WEEKDAY_DICTIONARY[dayOfWeek];
|
2804 | const prefix = match[PREFIX_GROUP];
|
2805 | const postfix = match[POSTFIX_GROUP];
|
2806 | let modifierWord = prefix || postfix;
|
2807 | modifierWord = modifierWord || "";
|
2808 | modifierWord = modifierWord.toLowerCase();
|
2809 | let modifier = null;
|
2810 | if (modifierWord == "last" || modifierWord == "past") {
|
2811 | modifier = "last";
|
2812 | }
|
2813 | else if (modifierWord == "next") {
|
2814 | modifier = "next";
|
2815 | }
|
2816 | else if (modifierWord == "this") {
|
2817 | modifier = "this";
|
2818 | }
|
2819 | const date = weeks_1.toDayJSWeekday(context.refDate, offset, modifier);
|
2820 | return context
|
2821 | .createParsingComponents()
|
2822 | .assign("weekday", offset)
|
2823 | .imply("day", date.date())
|
2824 | .imply("month", date.month() + 1)
|
2825 | .imply("year", date.year());
|
2826 | }
|
2827 | }
|
2828 | exports.default = ENWeekdayParser;
|
2829 |
|
2830 | },{"../../../calculation/weeks":2,"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../utils/pattern":91,"../constants":30}],46:[function(require,module,exports){
|
2831 | "use strict";
|
2832 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
2833 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
2834 | };
|
2835 | Object.defineProperty(exports, "__esModule", { value: true });
|
2836 | const AbstractMergeDateRangeRefiner_1 = __importDefault(require("../../../common/refiners/AbstractMergeDateRangeRefiner"));
|
2837 | class ENMergeDateRangeRefiner extends AbstractMergeDateRangeRefiner_1.default {
|
2838 | patternBetween() {
|
2839 | return /^\s*(to|-)\s*$/i;
|
2840 | }
|
2841 | }
|
2842 | exports.default = ENMergeDateRangeRefiner;
|
2843 |
|
2844 | },{"../../../common/refiners/AbstractMergeDateRangeRefiner":11}],47:[function(require,module,exports){
|
2845 | "use strict";
|
2846 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
2847 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
2848 | };
|
2849 | Object.defineProperty(exports, "__esModule", { value: true });
|
2850 | const AbstractMergeDateTimeRefiner_1 = __importDefault(require("../../../common/refiners/AbstractMergeDateTimeRefiner"));
|
2851 | class ENMergeDateTimeRefiner extends AbstractMergeDateTimeRefiner_1.default {
|
2852 | patternBetween() {
|
2853 | return new RegExp("^\\s*(T|at|after|before|on|of|,|-)?\\s*$");
|
2854 | }
|
2855 | }
|
2856 | exports.default = ENMergeDateTimeRefiner;
|
2857 |
|
2858 | },{"../../../common/refiners/AbstractMergeDateTimeRefiner":12}],48:[function(require,module,exports){
|
2859 | "use strict";
|
2860 | Object.defineProperty(exports, "__esModule", { value: true });
|
2861 | exports.parseTimeUnits = exports.TIME_UNITS_PATTERN = exports.parseYear = exports.YEAR_PATTERN = exports.parseOrdinalNumberPattern = exports.ORDINAL_NUMBER_PATTERN = exports.parseNumberPattern = exports.NUMBER_PATTERN = exports.TIME_UNIT_DICTIONARY = exports.INTEGER_WORD_DICTIONARY = exports.MONTH_DICTIONARY = exports.WEEKDAY_DICTIONARY = void 0;
|
2862 | const pattern_1 = require("../../utils/pattern");
|
2863 | exports.WEEKDAY_DICTIONARY = {
|
2864 | "dimanche": 0,
|
2865 | "dim": 0,
|
2866 | "lundi": 1,
|
2867 | "lun": 1,
|
2868 | "mardi": 2,
|
2869 | "mar": 2,
|
2870 | "mercredi": 3,
|
2871 | "mer": 3,
|
2872 | "jeudi": 4,
|
2873 | "jeu": 4,
|
2874 | "vendredi": 5,
|
2875 | "ven": 5,
|
2876 | "samedi": 6,
|
2877 | "sam": 6,
|
2878 | };
|
2879 | exports.MONTH_DICTIONARY = {
|
2880 | "janvier": 1,
|
2881 | "jan": 1,
|
2882 | "jan.": 1,
|
2883 | "février": 2,
|
2884 | "fév": 2,
|
2885 | "fév.": 2,
|
2886 | "fevrier": 2,
|
2887 | "fev": 2,
|
2888 | "fev.": 2,
|
2889 | "mars": 3,
|
2890 | "mar": 3,
|
2891 | "mar.": 3,
|
2892 | "avril": 4,
|
2893 | "avr": 4,
|
2894 | "avr.": 4,
|
2895 | "mai": 5,
|
2896 | "juin": 6,
|
2897 | "jun": 6,
|
2898 | "juillet": 7,
|
2899 | "juil": 7,
|
2900 | "jul": 7,
|
2901 | "jul.": 7,
|
2902 | "août": 8,
|
2903 | "aout": 8,
|
2904 | "septembre": 9,
|
2905 | "sep": 9,
|
2906 | "sep.": 9,
|
2907 | "sept": 9,
|
2908 | "sept.": 9,
|
2909 | "octobre": 10,
|
2910 | "oct": 10,
|
2911 | "oct.": 10,
|
2912 | "novembre": 11,
|
2913 | "nov": 11,
|
2914 | "nov.": 11,
|
2915 | "décembre": 12,
|
2916 | "decembre": 12,
|
2917 | "dec": 12,
|
2918 | "dec.": 12,
|
2919 | };
|
2920 | exports.INTEGER_WORD_DICTIONARY = {
|
2921 | "un": 1,
|
2922 | "deux": 2,
|
2923 | "trois": 3,
|
2924 | "quatre": 4,
|
2925 | "cinq": 5,
|
2926 | "six": 6,
|
2927 | "sept": 7,
|
2928 | "huit": 8,
|
2929 | "neuf": 9,
|
2930 | "dix": 10,
|
2931 | "onze": 11,
|
2932 | "douze": 12,
|
2933 | "treize": 13,
|
2934 | };
|
2935 | exports.TIME_UNIT_DICTIONARY = {
|
2936 | "sec": "second",
|
2937 | "seconde": "second",
|
2938 | "secondes": "second",
|
2939 | "min": "minute",
|
2940 | "mins": "minute",
|
2941 | "minute": "minute",
|
2942 | "minutes": "minute",
|
2943 | "h": "hour",
|
2944 | "hr": "hour",
|
2945 | "hrs": "hour",
|
2946 | "heure": "hour",
|
2947 | "heures": "hour",
|
2948 | "jour": "d",
|
2949 | "jours": "d",
|
2950 | "semaine": "week",
|
2951 | "semaines": "week",
|
2952 | "mois": "month",
|
2953 | "trimestre": "quarter",
|
2954 | "trimestres": "quarter",
|
2955 | "ans": "year",
|
2956 | "année": "year",
|
2957 | "années": "year",
|
2958 | };
|
2959 | exports.NUMBER_PATTERN = `(?:${pattern_1.matchAnyPattern(exports.INTEGER_WORD_DICTIONARY)}|[0-9]+|[0-9]+\\.[0-9]+|une?|quelques?|demi-?)`;
|
2960 | function parseNumberPattern(match) {
|
2961 | const num = match.toLowerCase();
|
2962 | if (exports.INTEGER_WORD_DICTIONARY[num] !== undefined) {
|
2963 | return exports.INTEGER_WORD_DICTIONARY[num];
|
2964 | }
|
2965 | else if (num === "une" || num === "un") {
|
2966 | return 1;
|
2967 | }
|
2968 | else if (num.match(/quelques?/)) {
|
2969 | return 3;
|
2970 | }
|
2971 | else if (num.match(/demi-?/)) {
|
2972 | return 0.5;
|
2973 | }
|
2974 | return parseFloat(num);
|
2975 | }
|
2976 | exports.parseNumberPattern = parseNumberPattern;
|
2977 | exports.ORDINAL_NUMBER_PATTERN = `(?:[0-9]{1,2}(?:er)?)`;
|
2978 | function parseOrdinalNumberPattern(match) {
|
2979 | let num = match.toLowerCase();
|
2980 | num = num.replace(/(?:er)$/i, "");
|
2981 | return parseInt(num);
|
2982 | }
|
2983 | exports.parseOrdinalNumberPattern = parseOrdinalNumberPattern;
|
2984 | exports.YEAR_PATTERN = `(?:[1-9][0-9]{0,3}\\s*(?:AC|AD|p\\.\\s*C(?:hr?)?\\.\\s*n\\.)|[1-2][0-9]{3}|[5-9][0-9])`;
|
2985 | function parseYear(match) {
|
2986 | if (/AC/i.test(match)) {
|
2987 | match = match.replace(/BC/i, "");
|
2988 | return -parseInt(match);
|
2989 | }
|
2990 | if (/AD/i.test(match) || /C/i.test(match)) {
|
2991 | match = match.replace(/[^\d]+/i, "");
|
2992 | return parseInt(match);
|
2993 | }
|
2994 | let yearNumber = parseInt(match);
|
2995 | if (yearNumber < 100) {
|
2996 | if (yearNumber > 50) {
|
2997 | yearNumber = yearNumber + 1900;
|
2998 | }
|
2999 | else {
|
3000 | yearNumber = yearNumber + 2000;
|
3001 | }
|
3002 | }
|
3003 | return yearNumber;
|
3004 | }
|
3005 | exports.parseYear = parseYear;
|
3006 | const SINGLE_TIME_UNIT_PATTERN = `(${exports.NUMBER_PATTERN})\\s{0,5}(${pattern_1.matchAnyPattern(exports.TIME_UNIT_DICTIONARY)})\\s{0,5}`;
|
3007 | const SINGLE_TIME_UNIT_REGEX = new RegExp(SINGLE_TIME_UNIT_PATTERN, "i");
|
3008 | exports.TIME_UNITS_PATTERN = pattern_1.repeatedTimeunitPattern("", SINGLE_TIME_UNIT_PATTERN);
|
3009 | function parseTimeUnits(timeunitText) {
|
3010 | const fragments = {};
|
3011 | let remainingText = timeunitText;
|
3012 | let match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
3013 | while (match) {
|
3014 | collectDateTimeFragment(fragments, match);
|
3015 | remainingText = remainingText.substring(match[0].length);
|
3016 | match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
3017 | }
|
3018 | return fragments;
|
3019 | }
|
3020 | exports.parseTimeUnits = parseTimeUnits;
|
3021 | function collectDateTimeFragment(fragments, match) {
|
3022 | const num = parseNumberPattern(match[1]);
|
3023 | const unit = exports.TIME_UNIT_DICTIONARY[match[2].toLowerCase()];
|
3024 | fragments[unit] = num;
|
3025 | }
|
3026 |
|
3027 | },{"../../utils/pattern":91}],49:[function(require,module,exports){
|
3028 | "use strict";
|
3029 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3030 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
3031 | };
|
3032 | Object.defineProperty(exports, "__esModule", { value: true });
|
3033 | exports.createConfiguration = exports.createCasualConfiguration = exports.parseDate = exports.parse = exports.strict = exports.casual = void 0;
|
3034 | const configurations_1 = require("../../configurations");
|
3035 | const chrono_1 = require("../../chrono");
|
3036 | const FRCasualDateParser_1 = __importDefault(require("./parsers/FRCasualDateParser"));
|
3037 | const FRCasualTimeParser_1 = __importDefault(require("./parsers/FRCasualTimeParser"));
|
3038 | const SlashDateFormatParser_1 = __importDefault(require("../../common/parsers/SlashDateFormatParser"));
|
3039 | const FRTimeExpressionParser_1 = __importDefault(require("./parsers/FRTimeExpressionParser"));
|
3040 | const FRMergeDateTimeRefiner_1 = __importDefault(require("./refiners/FRMergeDateTimeRefiner"));
|
3041 | const FRMergeDateRangeRefiner_1 = __importDefault(require("./refiners/FRMergeDateRangeRefiner"));
|
3042 | const FRWeekdayParser_1 = __importDefault(require("./parsers/FRWeekdayParser"));
|
3043 | const FRSpecificTimeExpressionParser_1 = __importDefault(require("./parsers/FRSpecificTimeExpressionParser"));
|
3044 | const FRMonthNameLittleEndianParser_1 = __importDefault(require("./parsers/FRMonthNameLittleEndianParser"));
|
3045 | const FRTimeUnitAgoFormatParser_1 = __importDefault(require("./parsers/FRTimeUnitAgoFormatParser"));
|
3046 | const FRTimeUnitWithinFormatParser_1 = __importDefault(require("./parsers/FRTimeUnitWithinFormatParser"));
|
3047 | const FRTimeUnitRelativeFormatParser_1 = __importDefault(require("./parsers/FRTimeUnitRelativeFormatParser"));
|
3048 | exports.casual = new chrono_1.Chrono(createCasualConfiguration());
|
3049 | exports.strict = new chrono_1.Chrono(createConfiguration(true));
|
3050 | function parse(text, ref, option) {
|
3051 | return exports.casual.parse(text, ref, option);
|
3052 | }
|
3053 | exports.parse = parse;
|
3054 | function parseDate(text, ref, option) {
|
3055 | return exports.casual.parseDate(text, ref, option);
|
3056 | }
|
3057 | exports.parseDate = parseDate;
|
3058 | function createCasualConfiguration(littleEndian = true) {
|
3059 | const option = createConfiguration(false, littleEndian);
|
3060 | option.parsers.unshift(new FRCasualDateParser_1.default());
|
3061 | option.parsers.unshift(new FRCasualTimeParser_1.default());
|
3062 | option.parsers.unshift(new FRTimeUnitRelativeFormatParser_1.default());
|
3063 | return option;
|
3064 | }
|
3065 | exports.createCasualConfiguration = createCasualConfiguration;
|
3066 | function createConfiguration(strictMode = true, littleEndian = true) {
|
3067 | return configurations_1.includeCommonConfiguration({
|
3068 | parsers: [
|
3069 | new SlashDateFormatParser_1.default(littleEndian),
|
3070 | new FRMonthNameLittleEndianParser_1.default(),
|
3071 | new FRTimeExpressionParser_1.default(),
|
3072 | new FRSpecificTimeExpressionParser_1.default(),
|
3073 | new FRTimeUnitAgoFormatParser_1.default(),
|
3074 | new FRTimeUnitWithinFormatParser_1.default(),
|
3075 | new FRWeekdayParser_1.default(),
|
3076 | ],
|
3077 | refiners: [new FRMergeDateTimeRefiner_1.default(), new FRMergeDateRangeRefiner_1.default()],
|
3078 | }, strictMode);
|
3079 | }
|
3080 | exports.createConfiguration = createConfiguration;
|
3081 |
|
3082 | },{"../../chrono":4,"../../common/parsers/SlashDateFormatParser":10,"../../configurations":19,"./parsers/FRCasualDateParser":50,"./parsers/FRCasualTimeParser":51,"./parsers/FRMonthNameLittleEndianParser":52,"./parsers/FRSpecificTimeExpressionParser":53,"./parsers/FRTimeExpressionParser":54,"./parsers/FRTimeUnitAgoFormatParser":55,"./parsers/FRTimeUnitRelativeFormatParser":56,"./parsers/FRTimeUnitWithinFormatParser":57,"./parsers/FRWeekdayParser":58,"./refiners/FRMergeDateRangeRefiner":59,"./refiners/FRMergeDateTimeRefiner":60}],50:[function(require,module,exports){
|
3083 | "use strict";
|
3084 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3085 | if (k2 === undefined) k2 = k;
|
3086 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
3087 | }) : (function(o, m, k, k2) {
|
3088 | if (k2 === undefined) k2 = k;
|
3089 | o[k2] = m[k];
|
3090 | }));
|
3091 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
3092 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
3093 | }) : function(o, v) {
|
3094 | o["default"] = v;
|
3095 | });
|
3096 | var __importStar = (this && this.__importStar) || function (mod) {
|
3097 | if (mod && mod.__esModule) return mod;
|
3098 | var result = {};
|
3099 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
3100 | __setModuleDefault(result, mod);
|
3101 | return result;
|
3102 | };
|
3103 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3104 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
3105 | };
|
3106 | Object.defineProperty(exports, "__esModule", { value: true });
|
3107 | const dayjs_1 = __importDefault(require("dayjs"));
|
3108 | const index_1 = require("../../../index");
|
3109 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
3110 | const dayjs_2 = require("../../../utils/dayjs");
|
3111 | const references = __importStar(require("../../../common/casualReferences"));
|
3112 | class FRCasualDateParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
3113 | innerPattern(context) {
|
3114 | return /(maintenant|aujourd'hui|demain|hier|cette\s*nuit|la\s*veille)(?=\W|$)/i;
|
3115 | }
|
3116 | innerExtract(context, match) {
|
3117 | let targetDate = dayjs_1.default(context.refDate);
|
3118 | const lowerText = match[0].toLowerCase();
|
3119 | const component = context.createParsingComponents();
|
3120 | switch (lowerText) {
|
3121 | case "maintenant":
|
3122 | return references.now(context.refDate);
|
3123 | case "aujourd'hui":
|
3124 | return references.today(context.refDate);
|
3125 | case "hier":
|
3126 | return references.yesterday(context.refDate);
|
3127 | case "demain":
|
3128 | return references.tomorrow(context.refDate);
|
3129 | default:
|
3130 | if (lowerText.match(/cette\s*nuit/)) {
|
3131 | dayjs_2.assignSimilarDate(component, targetDate);
|
3132 | component.imply("hour", 22);
|
3133 | component.imply("meridiem", index_1.Meridiem.PM);
|
3134 | }
|
3135 | else if (lowerText.match(/la\s*veille/)) {
|
3136 | targetDate = targetDate.add(-1, "day");
|
3137 | dayjs_2.assignSimilarDate(component, targetDate);
|
3138 | component.imply("hour", 0);
|
3139 | }
|
3140 | }
|
3141 | return component;
|
3142 | }
|
3143 | }
|
3144 | exports.default = FRCasualDateParser;
|
3145 |
|
3146 | },{"../../../common/casualReferences":6,"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../index":20,"../../../utils/dayjs":90,"dayjs":93}],51:[function(require,module,exports){
|
3147 | "use strict";
|
3148 | Object.defineProperty(exports, "__esModule", { value: true });
|
3149 | const index_1 = require("../../../index");
|
3150 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
3151 | class FRCasualTimeParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
3152 | innerPattern(context) {
|
3153 | return /(cet?)?\s*(matin|soir|après-midi|aprem|a midi|à minuit)(?=\W|$)/i;
|
3154 | }
|
3155 | innerExtract(context, match) {
|
3156 | const suffixLower = match[2].toLowerCase();
|
3157 | const component = context.createParsingComponents();
|
3158 | switch (suffixLower) {
|
3159 | case "après-midi":
|
3160 | case "aprem":
|
3161 | component.imply("hour", 14);
|
3162 | component.imply("minute", 0);
|
3163 | component.imply("meridiem", index_1.Meridiem.PM);
|
3164 | break;
|
3165 | case "soir":
|
3166 | component.imply("hour", 18);
|
3167 | component.imply("minute", 0);
|
3168 | component.imply("meridiem", index_1.Meridiem.PM);
|
3169 | break;
|
3170 | case "matin":
|
3171 | component.imply("hour", 8);
|
3172 | component.imply("minute", 0);
|
3173 | component.imply("meridiem", index_1.Meridiem.AM);
|
3174 | break;
|
3175 | case "a midi":
|
3176 | component.imply("hour", 12);
|
3177 | component.imply("minute", 0);
|
3178 | component.imply("meridiem", index_1.Meridiem.AM);
|
3179 | break;
|
3180 | case "à minuit":
|
3181 | component.imply("hour", 0);
|
3182 | component.imply("meridiem", index_1.Meridiem.AM);
|
3183 | break;
|
3184 | }
|
3185 | return component;
|
3186 | }
|
3187 | }
|
3188 | exports.default = FRCasualTimeParser;
|
3189 |
|
3190 | },{"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../index":20}],52:[function(require,module,exports){
|
3191 | "use strict";
|
3192 | Object.defineProperty(exports, "__esModule", { value: true });
|
3193 | const years_1 = require("../../../calculation/years");
|
3194 | const constants_1 = require("../constants");
|
3195 | const constants_2 = require("../constants");
|
3196 | const constants_3 = require("../constants");
|
3197 | const pattern_1 = require("../../../utils/pattern");
|
3198 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
3199 | const PATTERN = new RegExp("(?:on\\s*?)?" +
|
3200 | `(${constants_3.ORDINAL_NUMBER_PATTERN})` +
|
3201 | `(?:\\s*(?:au|\\-|\\–|jusqu'au?|\\s)\\s*(${constants_3.ORDINAL_NUMBER_PATTERN}))?` +
|
3202 | `(?:-|/|\\s*(?:de)?\\s*)` +
|
3203 | `(${pattern_1.matchAnyPattern(constants_1.MONTH_DICTIONARY)})` +
|
3204 | `(?:(?:-|/|,?\\s*)(${constants_2.YEAR_PATTERN}(?![^\\s]\\d)))?` +
|
3205 | `(?=\\W|$)`, "i");
|
3206 | const DATE_GROUP = 1;
|
3207 | const DATE_TO_GROUP = 2;
|
3208 | const MONTH_NAME_GROUP = 3;
|
3209 | const YEAR_GROUP = 4;
|
3210 | class FRMonthNameLittleEndianParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
3211 | innerPattern() {
|
3212 | return PATTERN;
|
3213 | }
|
3214 | innerExtract(context, match) {
|
3215 | const result = context.createParsingResult(match.index, match[0]);
|
3216 | const month = constants_1.MONTH_DICTIONARY[match[MONTH_NAME_GROUP].toLowerCase()];
|
3217 | const day = constants_3.parseOrdinalNumberPattern(match[DATE_GROUP]);
|
3218 | if (day > 31) {
|
3219 | match.index = match.index + match[DATE_GROUP].length;
|
3220 | return null;
|
3221 | }
|
3222 | result.start.assign("month", month);
|
3223 | result.start.assign("day", day);
|
3224 | if (match[YEAR_GROUP]) {
|
3225 | const yearNumber = constants_2.parseYear(match[YEAR_GROUP]);
|
3226 | result.start.assign("year", yearNumber);
|
3227 | }
|
3228 | else {
|
3229 | const year = years_1.findYearClosestToRef(context.refDate, day, month);
|
3230 | result.start.imply("year", year);
|
3231 | }
|
3232 | if (match[DATE_TO_GROUP]) {
|
3233 | const endDate = constants_3.parseOrdinalNumberPattern(match[DATE_TO_GROUP]);
|
3234 | result.end = result.start.clone();
|
3235 | result.end.assign("day", endDate);
|
3236 | }
|
3237 | return result;
|
3238 | }
|
3239 | }
|
3240 | exports.default = FRMonthNameLittleEndianParser;
|
3241 |
|
3242 | },{"../../../calculation/years":3,"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../utils/pattern":91,"../constants":48}],53:[function(require,module,exports){
|
3243 | "use strict";
|
3244 | Object.defineProperty(exports, "__esModule", { value: true });
|
3245 | const index_1 = require("../../../index");
|
3246 | const FIRST_REG_PATTERN = new RegExp("(^|\\s|T)" +
|
3247 | "(?:(?:[àa])\\s*)?" +
|
3248 | "(\\d{1,2})(?:h|:)?" +
|
3249 | "(?:(\\d{1,2})(?:m|:)?)?" +
|
3250 | "(?:(\\d{1,2})(?:s|:)?)?" +
|
3251 | "(?:\\s*(A\\.M\\.|P\\.M\\.|AM?|PM?))?" +
|
3252 | "(?=\\W|$)", "i");
|
3253 | const SECOND_REG_PATTERN = new RegExp("^\\s*(\\-|\\–|\\~|\\〜|[àa]|\\?)\\s*" +
|
3254 | "(\\d{1,2})(?:h|:)?" +
|
3255 | "(?:(\\d{1,2})(?:m|:)?)?" +
|
3256 | "(?:(\\d{1,2})(?:s|:)?)?" +
|
3257 | "(?:\\s*(A\\.M\\.|P\\.M\\.|AM?|PM?))?" +
|
3258 | "(?=\\W|$)", "i");
|
3259 | const HOUR_GROUP = 2;
|
3260 | const MINUTE_GROUP = 3;
|
3261 | const SECOND_GROUP = 4;
|
3262 | const AM_PM_HOUR_GROUP = 5;
|
3263 | class FRSpecificTimeExpressionParser {
|
3264 | pattern(context) {
|
3265 | return FIRST_REG_PATTERN;
|
3266 | }
|
3267 | extract(context, match) {
|
3268 | const result = context.createParsingResult(match.index + match[1].length, match[0].substring(match[1].length));
|
3269 | if (result.text.match(/^\d{4}$/)) {
|
3270 | match.index += match[0].length;
|
3271 | return null;
|
3272 | }
|
3273 | result.start = FRSpecificTimeExpressionParser.extractTimeComponent(result.start.clone(), match);
|
3274 | if (!result.start) {
|
3275 | match.index += match[0].length;
|
3276 | return null;
|
3277 | }
|
3278 | const remainingText = context.text.substring(match.index + match[0].length);
|
3279 | const secondMatch = SECOND_REG_PATTERN.exec(remainingText);
|
3280 | if (secondMatch) {
|
3281 | result.end = FRSpecificTimeExpressionParser.extractTimeComponent(result.start.clone(), secondMatch);
|
3282 | if (result.end) {
|
3283 | result.text += secondMatch[0];
|
3284 | }
|
3285 | }
|
3286 | return result;
|
3287 | }
|
3288 | static extractTimeComponent(extractingComponents, match) {
|
3289 | let hour = 0;
|
3290 | let minute = 0;
|
3291 | let meridiem = null;
|
3292 | hour = parseInt(match[HOUR_GROUP]);
|
3293 | if (match[MINUTE_GROUP] != null) {
|
3294 | minute = parseInt(match[MINUTE_GROUP]);
|
3295 | }
|
3296 | if (minute >= 60 || hour > 24) {
|
3297 | return null;
|
3298 | }
|
3299 | if (hour >= 12) {
|
3300 | meridiem = index_1.Meridiem.PM;
|
3301 | }
|
3302 | if (match[AM_PM_HOUR_GROUP] != null) {
|
3303 | if (hour > 12)
|
3304 | return null;
|
3305 | const ampm = match[AM_PM_HOUR_GROUP][0].toLowerCase();
|
3306 | if (ampm == "a") {
|
3307 | meridiem = index_1.Meridiem.AM;
|
3308 | if (hour == 12) {
|
3309 | hour = 0;
|
3310 | }
|
3311 | }
|
3312 | if (ampm == "p") {
|
3313 | meridiem = index_1.Meridiem.PM;
|
3314 | if (hour != 12) {
|
3315 | hour += 12;
|
3316 | }
|
3317 | }
|
3318 | }
|
3319 | extractingComponents.assign("hour", hour);
|
3320 | extractingComponents.assign("minute", minute);
|
3321 | if (meridiem !== null) {
|
3322 | extractingComponents.assign("meridiem", meridiem);
|
3323 | }
|
3324 | else {
|
3325 | if (hour < 12) {
|
3326 | extractingComponents.imply("meridiem", index_1.Meridiem.AM);
|
3327 | }
|
3328 | else {
|
3329 | extractingComponents.imply("meridiem", index_1.Meridiem.PM);
|
3330 | }
|
3331 | }
|
3332 | if (match[SECOND_GROUP] != null) {
|
3333 | const second = parseInt(match[SECOND_GROUP]);
|
3334 | if (second >= 60)
|
3335 | return null;
|
3336 | extractingComponents.assign("second", second);
|
3337 | }
|
3338 | return extractingComponents;
|
3339 | }
|
3340 | }
|
3341 | exports.default = FRSpecificTimeExpressionParser;
|
3342 |
|
3343 | },{"../../../index":20}],54:[function(require,module,exports){
|
3344 | "use strict";
|
3345 | Object.defineProperty(exports, "__esModule", { value: true });
|
3346 | const AbstractTimeExpressionParser_1 = require("../../../common/parsers/AbstractTimeExpressionParser");
|
3347 | class FRTimeExpressionParser extends AbstractTimeExpressionParser_1.AbstractTimeExpressionParser {
|
3348 | primaryPrefix() {
|
3349 | return "(?:(?:[àa])\\s*)?";
|
3350 | }
|
3351 | followingPhase() {
|
3352 | return "\\s*(?:\\-|\\–|\\~|\\〜|[àa]|\\?)\\s*";
|
3353 | }
|
3354 | extractPrimaryTimeComponents(context, match) {
|
3355 | if (match[0].match(/^\s*\d{4}\s*$/)) {
|
3356 | return null;
|
3357 | }
|
3358 | return super.extractPrimaryTimeComponents(context, match);
|
3359 | }
|
3360 | }
|
3361 | exports.default = FRTimeExpressionParser;
|
3362 |
|
3363 | },{"../../../common/parsers/AbstractTimeExpressionParser":8}],55:[function(require,module,exports){
|
3364 | "use strict";
|
3365 | Object.defineProperty(exports, "__esModule", { value: true });
|
3366 | const constants_1 = require("../constants");
|
3367 | const results_1 = require("../../../results");
|
3368 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
3369 | const timeunits_1 = require("../../../utils/timeunits");
|
3370 | class FRTimeUnitAgoFormatParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
3371 | constructor() {
|
3372 | super();
|
3373 | }
|
3374 | innerPattern() {
|
3375 | return new RegExp(`il y a\\s*(${constants_1.TIME_UNITS_PATTERN})(?=(?:\\W|$))`, "i");
|
3376 | }
|
3377 | innerExtract(context, match) {
|
3378 | const timeUnits = constants_1.parseTimeUnits(match[1]);
|
3379 | const outputTimeUnits = timeunits_1.reverseTimeUnits(timeUnits);
|
3380 | return results_1.ParsingComponents.createRelativeFromRefDate(context.refDate, outputTimeUnits);
|
3381 | }
|
3382 | }
|
3383 | exports.default = FRTimeUnitAgoFormatParser;
|
3384 |
|
3385 | },{"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../results":89,"../../../utils/timeunits":92,"../constants":48}],56:[function(require,module,exports){
|
3386 | "use strict";
|
3387 | Object.defineProperty(exports, "__esModule", { value: true });
|
3388 | const constants_1 = require("../constants");
|
3389 | const results_1 = require("../../../results");
|
3390 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
3391 | const timeunits_1 = require("../../../utils/timeunits");
|
3392 | const pattern_1 = require("../../../utils/pattern");
|
3393 | class FRTimeUnitAgoFormatParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
3394 | constructor() {
|
3395 | super();
|
3396 | }
|
3397 | innerPattern() {
|
3398 | return new RegExp(`(?:les?|la|l'|du|des?)\\s*` +
|
3399 | `(${constants_1.NUMBER_PATTERN})?` +
|
3400 | `(?:\\s*(prochaine?s?|derni[eè]re?s?|pass[ée]e?s?|pr[ée]c[ée]dents?|suivante?s?))?` +
|
3401 | `\\s*(${pattern_1.matchAnyPattern(constants_1.TIME_UNIT_DICTIONARY)})` +
|
3402 | `(?:\\s*(prochaine?s?|derni[eè]re?s?|pass[ée]e?s?|pr[ée]c[ée]dents?|suivante?s?))?`, "i");
|
3403 | }
|
3404 | innerExtract(context, match) {
|
3405 | const num = match[1] ? constants_1.parseNumberPattern(match[1]) : 1;
|
3406 | const unit = constants_1.TIME_UNIT_DICTIONARY[match[3].toLowerCase()];
|
3407 | let timeUnits = {};
|
3408 | timeUnits[unit] = num;
|
3409 | let modifier = match[2] || match[4] || "";
|
3410 | modifier = modifier.toLowerCase();
|
3411 | if (!modifier) {
|
3412 | return;
|
3413 | }
|
3414 | if (/derni[eè]re?s?/.test(modifier) || /pass[ée]e?s?/.test(modifier) || /pr[ée]c[ée]dents?/.test(modifier)) {
|
3415 | timeUnits = timeunits_1.reverseTimeUnits(timeUnits);
|
3416 | }
|
3417 | return results_1.ParsingComponents.createRelativeFromRefDate(context.refDate, timeUnits);
|
3418 | }
|
3419 | }
|
3420 | exports.default = FRTimeUnitAgoFormatParser;
|
3421 |
|
3422 | },{"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../results":89,"../../../utils/pattern":91,"../../../utils/timeunits":92,"../constants":48}],57:[function(require,module,exports){
|
3423 | "use strict";
|
3424 | Object.defineProperty(exports, "__esModule", { value: true });
|
3425 | const constants_1 = require("../constants");
|
3426 | const results_1 = require("../../../results");
|
3427 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
3428 | class FRTimeUnitWithinFormatParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
3429 | innerPattern() {
|
3430 | return new RegExp(`(?:dans|en|pour|pendant)\\s*(${constants_1.TIME_UNITS_PATTERN})(?=\\W|$)`, "i");
|
3431 | }
|
3432 | innerExtract(context, match) {
|
3433 | const timeUnits = constants_1.parseTimeUnits(match[1]);
|
3434 | return results_1.ParsingComponents.createRelativeFromRefDate(context.refDate, timeUnits);
|
3435 | }
|
3436 | }
|
3437 | exports.default = FRTimeUnitWithinFormatParser;
|
3438 |
|
3439 | },{"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../results":89,"../constants":48}],58:[function(require,module,exports){
|
3440 | "use strict";
|
3441 | Object.defineProperty(exports, "__esModule", { value: true });
|
3442 | const constants_1 = require("../constants");
|
3443 | const pattern_1 = require("../../../utils/pattern");
|
3444 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
3445 | const weeks_1 = require("../../../calculation/weeks");
|
3446 | const PATTERN = new RegExp("(?:(?:\\,|\\(|\\()\\s*)?" +
|
3447 | "(?:(?:ce)\\s*)?" +
|
3448 | `(${pattern_1.matchAnyPattern(constants_1.WEEKDAY_DICTIONARY)})` +
|
3449 | "(?:\\s*(?:\\,|\\)|\\)))?" +
|
3450 | "(?:\\s*(dernier|prochain)\\s*)?" +
|
3451 | "(?=\\W|\\d|$)", "i");
|
3452 | const WEEKDAY_GROUP = 1;
|
3453 | const POSTFIX_GROUP = 2;
|
3454 | class FRWeekdayParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
3455 | innerPattern() {
|
3456 | return PATTERN;
|
3457 | }
|
3458 | innerExtract(context, match) {
|
3459 | const dayOfWeek = match[WEEKDAY_GROUP].toLowerCase();
|
3460 | const offset = constants_1.WEEKDAY_DICTIONARY[dayOfWeek];
|
3461 | if (offset === undefined) {
|
3462 | return null;
|
3463 | }
|
3464 | let suffix = match[POSTFIX_GROUP];
|
3465 | suffix = suffix || "";
|
3466 | suffix = suffix.toLowerCase();
|
3467 | let modifier = null;
|
3468 | if (suffix == "dernier") {
|
3469 | modifier = "last";
|
3470 | }
|
3471 | else if (suffix == "prochain") {
|
3472 | modifier = "next";
|
3473 | }
|
3474 | const date = weeks_1.toDayJSWeekday(context.refDate, offset, modifier);
|
3475 | return context
|
3476 | .createParsingComponents()
|
3477 | .assign("weekday", offset)
|
3478 | .imply("day", date.date())
|
3479 | .imply("month", date.month() + 1)
|
3480 | .imply("year", date.year());
|
3481 | }
|
3482 | }
|
3483 | exports.default = FRWeekdayParser;
|
3484 |
|
3485 | },{"../../../calculation/weeks":2,"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../utils/pattern":91,"../constants":48}],59:[function(require,module,exports){
|
3486 | "use strict";
|
3487 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3488 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
3489 | };
|
3490 | Object.defineProperty(exports, "__esModule", { value: true });
|
3491 | const AbstractMergeDateRangeRefiner_1 = __importDefault(require("../../../common/refiners/AbstractMergeDateRangeRefiner"));
|
3492 | class FRMergeDateRangeRefiner extends AbstractMergeDateRangeRefiner_1.default {
|
3493 | patternBetween() {
|
3494 | return /^\s*(à|a|-)\s*$/i;
|
3495 | }
|
3496 | }
|
3497 | exports.default = FRMergeDateRangeRefiner;
|
3498 |
|
3499 | },{"../../../common/refiners/AbstractMergeDateRangeRefiner":11}],60:[function(require,module,exports){
|
3500 | "use strict";
|
3501 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3502 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
3503 | };
|
3504 | Object.defineProperty(exports, "__esModule", { value: true });
|
3505 | const AbstractMergeDateTimeRefiner_1 = __importDefault(require("../../../common/refiners/AbstractMergeDateTimeRefiner"));
|
3506 | class FRMergeDateTimeRefiner extends AbstractMergeDateTimeRefiner_1.default {
|
3507 | patternBetween() {
|
3508 | return new RegExp("^\\s*(T|à|a|vers|de|,|-)?\\s*$");
|
3509 | }
|
3510 | }
|
3511 | exports.default = FRMergeDateTimeRefiner;
|
3512 |
|
3513 | },{"../../../common/refiners/AbstractMergeDateTimeRefiner":12}],61:[function(require,module,exports){
|
3514 | "use strict";
|
3515 | Object.defineProperty(exports, "__esModule", { value: true });
|
3516 | exports.toHankaku = void 0;
|
3517 | function toHankaku(text) {
|
3518 | return String(text)
|
3519 | .replace(/\u2019/g, "\u0027")
|
3520 | .replace(/\u201D/g, "\u0022")
|
3521 | .replace(/\u3000/g, "\u0020")
|
3522 | .replace(/\uFFE5/g, "\u00A5")
|
3523 | .replace(/[\uFF01\uFF03-\uFF06\uFF08\uFF09\uFF0C-\uFF19\uFF1C-\uFF1F\uFF21-\uFF3B\uFF3D\uFF3F\uFF41-\uFF5B\uFF5D\uFF5E]/g, alphaNum);
|
3524 | }
|
3525 | exports.toHankaku = toHankaku;
|
3526 | function alphaNum(token) {
|
3527 | return String.fromCharCode(token.charCodeAt(0) - 65248);
|
3528 | }
|
3529 |
|
3530 | },{}],62:[function(require,module,exports){
|
3531 | "use strict";
|
3532 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3533 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
3534 | };
|
3535 | Object.defineProperty(exports, "__esModule", { value: true });
|
3536 | exports.createConfiguration = exports.createCasualConfiguration = exports.parseDate = exports.parse = exports.strict = exports.casual = void 0;
|
3537 | const JPStandardParser_1 = __importDefault(require("./parsers/JPStandardParser"));
|
3538 | const JPMergeDateRangeRefiner_1 = __importDefault(require("./refiners/JPMergeDateRangeRefiner"));
|
3539 | const JPCasualDateParser_1 = __importDefault(require("./parsers/JPCasualDateParser"));
|
3540 | const chrono_1 = require("../../chrono");
|
3541 | exports.casual = new chrono_1.Chrono(createCasualConfiguration());
|
3542 | exports.strict = new chrono_1.Chrono(createConfiguration());
|
3543 | function parse(text, ref, option) {
|
3544 | return exports.casual.parse(text, ref, option);
|
3545 | }
|
3546 | exports.parse = parse;
|
3547 | function parseDate(text, ref, option) {
|
3548 | return exports.casual.parseDate(text, ref, option);
|
3549 | }
|
3550 | exports.parseDate = parseDate;
|
3551 | function createCasualConfiguration() {
|
3552 | const option = createConfiguration();
|
3553 | option.parsers.unshift(new JPCasualDateParser_1.default());
|
3554 | return option;
|
3555 | }
|
3556 | exports.createCasualConfiguration = createCasualConfiguration;
|
3557 | function createConfiguration() {
|
3558 | return {
|
3559 | parsers: [new JPStandardParser_1.default()],
|
3560 | refiners: [new JPMergeDateRangeRefiner_1.default()],
|
3561 | };
|
3562 | }
|
3563 | exports.createConfiguration = createConfiguration;
|
3564 |
|
3565 | },{"../../chrono":4,"./parsers/JPCasualDateParser":63,"./parsers/JPStandardParser":64,"./refiners/JPMergeDateRangeRefiner":65}],63:[function(require,module,exports){
|
3566 | "use strict";
|
3567 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3568 | if (k2 === undefined) k2 = k;
|
3569 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
3570 | }) : (function(o, m, k, k2) {
|
3571 | if (k2 === undefined) k2 = k;
|
3572 | o[k2] = m[k];
|
3573 | }));
|
3574 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
3575 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
3576 | }) : function(o, v) {
|
3577 | o["default"] = v;
|
3578 | });
|
3579 | var __importStar = (this && this.__importStar) || function (mod) {
|
3580 | if (mod && mod.__esModule) return mod;
|
3581 | var result = {};
|
3582 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
3583 | __setModuleDefault(result, mod);
|
3584 | return result;
|
3585 | };
|
3586 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3587 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
3588 | };
|
3589 | Object.defineProperty(exports, "__esModule", { value: true });
|
3590 | const dayjs_1 = __importDefault(require("dayjs"));
|
3591 | const index_1 = require("../../../index");
|
3592 | const references = __importStar(require("../../../common/casualReferences"));
|
3593 | const PATTERN = /今日|当日|昨日|明日|今夜|今夕|今晩|今朝/i;
|
3594 | class JPCasualDateParser {
|
3595 | pattern() {
|
3596 | return PATTERN;
|
3597 | }
|
3598 | extract(context, match) {
|
3599 | const text = match[0];
|
3600 | const date = dayjs_1.default(context.refDate);
|
3601 | const components = context.createParsingComponents();
|
3602 | switch (text) {
|
3603 | case "昨日":
|
3604 | return references.yesterday(context.refDate);
|
3605 | case "明日":
|
3606 | return references.tomorrow(context.refDate);
|
3607 | case "今日":
|
3608 | case "当日":
|
3609 | return references.today(context.refDate);
|
3610 | }
|
3611 | if (text == "今夜" || text == "今夕" || text == "今晩") {
|
3612 | components.imply("hour", 22);
|
3613 | components.assign("meridiem", index_1.Meridiem.PM);
|
3614 | }
|
3615 | else if (text.match("今朝")) {
|
3616 | components.imply("hour", 6);
|
3617 | components.assign("meridiem", index_1.Meridiem.AM);
|
3618 | }
|
3619 | components.assign("day", date.date());
|
3620 | components.assign("month", date.month() + 1);
|
3621 | components.assign("year", date.year());
|
3622 | return components;
|
3623 | }
|
3624 | }
|
3625 | exports.default = JPCasualDateParser;
|
3626 |
|
3627 | },{"../../../common/casualReferences":6,"../../../index":20,"dayjs":93}],64:[function(require,module,exports){
|
3628 | "use strict";
|
3629 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3630 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
3631 | };
|
3632 | Object.defineProperty(exports, "__esModule", { value: true });
|
3633 | const constants_1 = require("../constants");
|
3634 | const years_1 = require("../../../calculation/years");
|
3635 | const dayjs_1 = __importDefault(require("dayjs"));
|
3636 | const PATTERN = /(?:(?:([同今本])|((昭和|平成|令和)?([0-90-9]{1,4}|元)))年\s*)?([0-90-9]{1,2})月\s*([0-90-9]{1,2})日/i;
|
3637 | const SPECIAL_YEAR_GROUP = 1;
|
3638 | const TYPICAL_YEAR_GROUP = 2;
|
3639 | const ERA_GROUP = 3;
|
3640 | const YEAR_NUMBER_GROUP = 4;
|
3641 | const MONTH_GROUP = 5;
|
3642 | const DAY_GROUP = 6;
|
3643 | class JPStandardParser {
|
3644 | pattern() {
|
3645 | return PATTERN;
|
3646 | }
|
3647 | extract(context, match) {
|
3648 | const month = parseInt(constants_1.toHankaku(match[MONTH_GROUP]));
|
3649 | const day = parseInt(constants_1.toHankaku(match[DAY_GROUP]));
|
3650 | const components = context.createParsingComponents({
|
3651 | day: day,
|
3652 | month: month,
|
3653 | });
|
3654 | if (match[SPECIAL_YEAR_GROUP] && match[SPECIAL_YEAR_GROUP].match("同|今|本")) {
|
3655 | const moment = dayjs_1.default(context.refDate);
|
3656 | components.assign("year", moment.year());
|
3657 | }
|
3658 | if (match[TYPICAL_YEAR_GROUP]) {
|
3659 | const yearNumText = match[YEAR_NUMBER_GROUP];
|
3660 | let year = yearNumText == "元" ? 1 : parseInt(constants_1.toHankaku(yearNumText));
|
3661 | if (match[ERA_GROUP] == "令和") {
|
3662 | year += 2018;
|
3663 | }
|
3664 | else if (match[ERA_GROUP] == "平成") {
|
3665 | year += 1988;
|
3666 | }
|
3667 | else if (match[ERA_GROUP] == "昭和") {
|
3668 | year += 1925;
|
3669 | }
|
3670 | components.assign("year", year);
|
3671 | }
|
3672 | else {
|
3673 | const year = years_1.findYearClosestToRef(context.refDate, day, month);
|
3674 | components.imply("year", year);
|
3675 | }
|
3676 | return components;
|
3677 | }
|
3678 | }
|
3679 | exports.default = JPStandardParser;
|
3680 |
|
3681 | },{"../../../calculation/years":3,"../constants":61,"dayjs":93}],65:[function(require,module,exports){
|
3682 | "use strict";
|
3683 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3684 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
3685 | };
|
3686 | Object.defineProperty(exports, "__esModule", { value: true });
|
3687 | const AbstractMergeDateRangeRefiner_1 = __importDefault(require("../../../common/refiners/AbstractMergeDateRangeRefiner"));
|
3688 | class JPMergeDateRangeRefiner extends AbstractMergeDateRangeRefiner_1.default {
|
3689 | patternBetween() {
|
3690 | return /^\s*(から|ー|-)\s*$/i;
|
3691 | }
|
3692 | }
|
3693 | exports.default = JPMergeDateRangeRefiner;
|
3694 |
|
3695 | },{"../../../common/refiners/AbstractMergeDateRangeRefiner":11}],66:[function(require,module,exports){
|
3696 | "use strict";
|
3697 | Object.defineProperty(exports, "__esModule", { value: true });
|
3698 | exports.parseTimeUnits = exports.TIME_UNITS_PATTERN = exports.parseYear = exports.YEAR_PATTERN = exports.parseOrdinalNumberPattern = exports.ORDINAL_NUMBER_PATTERN = exports.parseNumberPattern = exports.NUMBER_PATTERN = exports.TIME_UNIT_DICTIONARY = exports.ORDINAL_WORD_DICTIONARY = exports.INTEGER_WORD_DICTIONARY = exports.MONTH_DICTIONARY = exports.WEEKDAY_DICTIONARY = void 0;
|
3699 | const pattern_1 = require("../../utils/pattern");
|
3700 | const years_1 = require("../../calculation/years");
|
3701 | exports.WEEKDAY_DICTIONARY = {
|
3702 | zondag: 0,
|
3703 | zon: 0,
|
3704 | "zon.": 0,
|
3705 | zo: 0,
|
3706 | "zo.": 0,
|
3707 | maandag: 1,
|
3708 | ma: 1,
|
3709 | "ma.": 1,
|
3710 | dinsdag: 2,
|
3711 | din: 2,
|
3712 | "din.": 2,
|
3713 | di: 2,
|
3714 | "di.": 2,
|
3715 | woensdag: 3,
|
3716 | woe: 3,
|
3717 | "woe.": 3,
|
3718 | wo: 3,
|
3719 | "wo.": 3,
|
3720 | donderdag: 4,
|
3721 | dond: 4,
|
3722 | "dond.": 4,
|
3723 | do: 4,
|
3724 | "do.": 4,
|
3725 | vrijdag: 5,
|
3726 | vrij: 5,
|
3727 | "vrij.": 5,
|
3728 | vr: 5,
|
3729 | "vr.": 5,
|
3730 | zaterdag: 6,
|
3731 | zat: 6,
|
3732 | "zat.": 6,
|
3733 | "za": 6,
|
3734 | "za.": 6,
|
3735 | };
|
3736 | exports.MONTH_DICTIONARY = {
|
3737 | januari: 1,
|
3738 | jan: 1,
|
3739 | "jan.": 1,
|
3740 | februari: 2,
|
3741 | feb: 2,
|
3742 | "feb.": 2,
|
3743 | maart: 3,
|
3744 | mar: 3,
|
3745 | "mar.": 3,
|
3746 | april: 4,
|
3747 | apr: 4,
|
3748 | "apr.": 4,
|
3749 | mei: 5,
|
3750 | juni: 6,
|
3751 | jun: 6,
|
3752 | "jun.": 6,
|
3753 | juli: 7,
|
3754 | jul: 7,
|
3755 | "jul.": 7,
|
3756 | augustus: 8,
|
3757 | aug: 8,
|
3758 | "aug.": 8,
|
3759 | september: 9,
|
3760 | sep: 9,
|
3761 | "sep.": 9,
|
3762 | sept: 9,
|
3763 | "sept.": 9,
|
3764 | oktober: 10,
|
3765 | okt: 10,
|
3766 | "okt.": 10,
|
3767 | november: 11,
|
3768 | nov: 11,
|
3769 | "nov.": 11,
|
3770 | december: 12,
|
3771 | dec: 12,
|
3772 | "dec.": 12,
|
3773 | };
|
3774 | exports.INTEGER_WORD_DICTIONARY = {
|
3775 | een: 1,
|
3776 | twee: 2,
|
3777 | drie: 3,
|
3778 | vier: 4,
|
3779 | vijf: 5,
|
3780 | zes: 6,
|
3781 | zeven: 7,
|
3782 | acht: 8,
|
3783 | negen: 9,
|
3784 | tien: 10,
|
3785 | elf: 11,
|
3786 | twaalf: 12,
|
3787 | };
|
3788 | exports.ORDINAL_WORD_DICTIONARY = {
|
3789 | eerste: 1,
|
3790 | tweede: 2,
|
3791 | derde: 3,
|
3792 | vierde: 4,
|
3793 | vijfde: 5,
|
3794 | zesde: 6,
|
3795 | zevende: 7,
|
3796 | achtste: 8,
|
3797 | negende: 9,
|
3798 | tiende: 10,
|
3799 | elfde: 11,
|
3800 | twaalfde: 12,
|
3801 | dertiende: 13,
|
3802 | veertiende: 14,
|
3803 | vijftiende: 15,
|
3804 | zestiende: 16,
|
3805 | zeventiende: 17,
|
3806 | achttiende: 18,
|
3807 | negentiende: 19,
|
3808 | twintigste: 20,
|
3809 | "eenentwintigste": 21,
|
3810 | "tweeëntwintigste": 22,
|
3811 | "drieentwintigste": 23,
|
3812 | "vierentwintigste": 24,
|
3813 | "vijfentwintigste": 25,
|
3814 | "zesentwintigste": 26,
|
3815 | "zevenentwintigste": 27,
|
3816 | "achtentwintig": 28,
|
3817 | "negenentwintig": 29,
|
3818 | "dertigste": 30,
|
3819 | "eenendertigste": 31,
|
3820 | };
|
3821 | exports.TIME_UNIT_DICTIONARY = {
|
3822 | sec: "second",
|
3823 | second: "second",
|
3824 | seconden: "second",
|
3825 | min: "minute",
|
3826 | mins: "minute",
|
3827 | minute: "minute",
|
3828 | minuten: "minute",
|
3829 | h: "hour",
|
3830 | hr: "hour",
|
3831 | hrs: "hour",
|
3832 | uur: "hour",
|
3833 | uren: "hour",
|
3834 | dag: "d",
|
3835 | dagen: "d",
|
3836 | week: "week",
|
3837 | weken: "week",
|
3838 | maand: "month",
|
3839 | maanden: "month",
|
3840 | jaar: "year",
|
3841 | jr: "year",
|
3842 | jaren: "year",
|
3843 | };
|
3844 | exports.NUMBER_PATTERN = `(?:${pattern_1.matchAnyPattern(exports.INTEGER_WORD_DICTIONARY)}|[0-9]+|[0-9]+\\.[0-9]+|een?|halve?)`;
|
3845 | function parseNumberPattern(match) {
|
3846 | const num = match.toLowerCase();
|
3847 | if (exports.INTEGER_WORD_DICTIONARY[num] !== undefined) {
|
3848 | return exports.INTEGER_WORD_DICTIONARY[num];
|
3849 | }
|
3850 | else if (num === "een") {
|
3851 | return 1;
|
3852 | }
|
3853 | else if (num.match(/halve?/)) {
|
3854 | return 0.5;
|
3855 | }
|
3856 | return parseFloat(num);
|
3857 | }
|
3858 | exports.parseNumberPattern = parseNumberPattern;
|
3859 | exports.ORDINAL_NUMBER_PATTERN = `(?:${pattern_1.matchAnyPattern(exports.ORDINAL_WORD_DICTIONARY)}|[0-9]{1,2}(?:ste|de)?)`;
|
3860 | function parseOrdinalNumberPattern(match) {
|
3861 | let num = match.toLowerCase();
|
3862 | if (exports.ORDINAL_WORD_DICTIONARY[num] !== undefined) {
|
3863 | return exports.ORDINAL_WORD_DICTIONARY[num];
|
3864 | }
|
3865 | num = num.replace(/(?:ste|de)$/i, "");
|
3866 | return parseInt(num);
|
3867 | }
|
3868 | exports.parseOrdinalNumberPattern = parseOrdinalNumberPattern;
|
3869 | exports.YEAR_PATTERN = `(?:[1-9][0-9]{0,3}\\s*(?:voor Christus|na Christus)|[1-2][0-9]{3}|[5-9][0-9])`;
|
3870 | function parseYear(match) {
|
3871 | if (/voor Christus/i.test(match)) {
|
3872 | match = match.replace(/voor Christus/i, "");
|
3873 | return -parseInt(match);
|
3874 | }
|
3875 | if (/na Christus/i.test(match)) {
|
3876 | match = match.replace(/na Christus/i, "");
|
3877 | return parseInt(match);
|
3878 | }
|
3879 | const rawYearNumber = parseInt(match);
|
3880 | return years_1.findMostLikelyADYear(rawYearNumber);
|
3881 | }
|
3882 | exports.parseYear = parseYear;
|
3883 | const SINGLE_TIME_UNIT_PATTERN = `(${exports.NUMBER_PATTERN})\\s{0,5}(${pattern_1.matchAnyPattern(exports.TIME_UNIT_DICTIONARY)})\\s{0,5}`;
|
3884 | const SINGLE_TIME_UNIT_REGEX = new RegExp(SINGLE_TIME_UNIT_PATTERN, "i");
|
3885 | exports.TIME_UNITS_PATTERN = pattern_1.repeatedTimeunitPattern(`(?:(?:binnen|in)\\s*)?`, SINGLE_TIME_UNIT_PATTERN);
|
3886 | function parseTimeUnits(timeunitText) {
|
3887 | const fragments = {};
|
3888 | let remainingText = timeunitText;
|
3889 | let match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
3890 | while (match) {
|
3891 | collectDateTimeFragment(fragments, match);
|
3892 | remainingText = remainingText.substring(match[0].length);
|
3893 | match = SINGLE_TIME_UNIT_REGEX.exec(remainingText);
|
3894 | }
|
3895 | return fragments;
|
3896 | }
|
3897 | exports.parseTimeUnits = parseTimeUnits;
|
3898 | function collectDateTimeFragment(fragments, match) {
|
3899 | const num = parseNumberPattern(match[1]);
|
3900 | const unit = exports.TIME_UNIT_DICTIONARY[match[2].toLowerCase()];
|
3901 | fragments[unit] = num;
|
3902 | }
|
3903 |
|
3904 | },{"../../calculation/years":3,"../../utils/pattern":91}],67:[function(require,module,exports){
|
3905 | "use strict";
|
3906 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3907 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
3908 | };
|
3909 | Object.defineProperty(exports, "__esModule", { value: true });
|
3910 | exports.createConfiguration = exports.createCasualConfiguration = exports.parseDate = exports.parse = exports.strict = exports.casual = void 0;
|
3911 | const configurations_1 = require("../../configurations");
|
3912 | const chrono_1 = require("../../chrono");
|
3913 | const NLMergeDateRangeRefiner_1 = __importDefault(require("./refiners/NLMergeDateRangeRefiner"));
|
3914 | const NLMergeDateTimeRefiner_1 = __importDefault(require("./refiners/NLMergeDateTimeRefiner"));
|
3915 | const NLCasualDateParser_1 = __importDefault(require("./parsers/NLCasualDateParser"));
|
3916 | const NLCasualTimeParser_1 = __importDefault(require("./parsers/NLCasualTimeParser"));
|
3917 | const SlashDateFormatParser_1 = __importDefault(require("../../common/parsers/SlashDateFormatParser"));
|
3918 | const NLTimeUnitWithinFormatParser_1 = __importDefault(require("./parsers/NLTimeUnitWithinFormatParser"));
|
3919 | const NLWeekdayParser_1 = __importDefault(require("./parsers/NLWeekdayParser"));
|
3920 | const NLMonthNameMiddleEndianParser_1 = __importDefault(require("./parsers/NLMonthNameMiddleEndianParser"));
|
3921 | const NLMonthNameParser_1 = __importDefault(require("./parsers/NLMonthNameParser"));
|
3922 | const NLSlashMonthFormatParser_1 = __importDefault(require("./parsers/NLSlashMonthFormatParser"));
|
3923 | const NLTimeExpressionParser_1 = __importDefault(require("./parsers/NLTimeExpressionParser"));
|
3924 | const NLCasualYearMonthDayParser_1 = __importDefault(require("./parsers/NLCasualYearMonthDayParser"));
|
3925 | const NLCasualDateTimeParser_1 = __importDefault(require("./parsers/NLCasualDateTimeParser"));
|
3926 | exports.casual = new chrono_1.Chrono(createCasualConfiguration());
|
3927 | exports.strict = new chrono_1.Chrono(createConfiguration(true));
|
3928 | function parse(text, ref, option) {
|
3929 | return exports.casual.parse(text, ref, option);
|
3930 | }
|
3931 | exports.parse = parse;
|
3932 | function parseDate(text, ref, option) {
|
3933 | return exports.casual.parseDate(text, ref, option);
|
3934 | }
|
3935 | exports.parseDate = parseDate;
|
3936 | function createCasualConfiguration(littleEndian = true) {
|
3937 | const option = createConfiguration(false, littleEndian);
|
3938 | option.parsers.unshift(new NLCasualDateParser_1.default());
|
3939 | option.parsers.unshift(new NLCasualTimeParser_1.default());
|
3940 | option.parsers.unshift(new NLCasualDateTimeParser_1.default());
|
3941 | return option;
|
3942 | }
|
3943 | exports.createCasualConfiguration = createCasualConfiguration;
|
3944 | function createConfiguration(strictMode = true, littleEndian = true) {
|
3945 | return configurations_1.includeCommonConfiguration({
|
3946 | parsers: [
|
3947 | new SlashDateFormatParser_1.default(littleEndian),
|
3948 | new NLMonthNameMiddleEndianParser_1.default(),
|
3949 | new NLMonthNameParser_1.default(),
|
3950 | new NLTimeExpressionParser_1.default(),
|
3951 | new NLTimeUnitWithinFormatParser_1.default(),
|
3952 | new NLSlashMonthFormatParser_1.default(),
|
3953 | new NLWeekdayParser_1.default(),
|
3954 | new NLCasualYearMonthDayParser_1.default(),
|
3955 | ],
|
3956 | refiners: [new NLMergeDateTimeRefiner_1.default(), new NLMergeDateRangeRefiner_1.default()],
|
3957 | }, strictMode);
|
3958 | }
|
3959 | exports.createConfiguration = createConfiguration;
|
3960 |
|
3961 | },{"../../chrono":4,"../../common/parsers/SlashDateFormatParser":10,"../../configurations":19,"./parsers/NLCasualDateParser":68,"./parsers/NLCasualDateTimeParser":69,"./parsers/NLCasualTimeParser":70,"./parsers/NLCasualYearMonthDayParser":71,"./parsers/NLMonthNameMiddleEndianParser":72,"./parsers/NLMonthNameParser":73,"./parsers/NLSlashMonthFormatParser":74,"./parsers/NLTimeExpressionParser":75,"./parsers/NLTimeUnitWithinFormatParser":76,"./parsers/NLWeekdayParser":77,"./refiners/NLMergeDateRangeRefiner":78,"./refiners/NLMergeDateTimeRefiner":79}],68:[function(require,module,exports){
|
3962 | "use strict";
|
3963 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3964 | if (k2 === undefined) k2 = k;
|
3965 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
3966 | }) : (function(o, m, k, k2) {
|
3967 | if (k2 === undefined) k2 = k;
|
3968 | o[k2] = m[k];
|
3969 | }));
|
3970 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
3971 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
3972 | }) : function(o, v) {
|
3973 | o["default"] = v;
|
3974 | });
|
3975 | var __importStar = (this && this.__importStar) || function (mod) {
|
3976 | if (mod && mod.__esModule) return mod;
|
3977 | var result = {};
|
3978 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
3979 | __setModuleDefault(result, mod);
|
3980 | return result;
|
3981 | };
|
3982 | Object.defineProperty(exports, "__esModule", { value: true });
|
3983 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
3984 | const references = __importStar(require("../../../common/casualReferences"));
|
3985 | class NLCasualDateParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
3986 | innerPattern(context) {
|
3987 | return /(nu|vandaag|morgen|morgend|gisteren)(?=\W|$)/i;
|
3988 | }
|
3989 | innerExtract(context, match) {
|
3990 | const lowerText = match[0].toLowerCase();
|
3991 | const component = context.createParsingComponents();
|
3992 | switch (lowerText) {
|
3993 | case "nu":
|
3994 | return references.now(context.refDate);
|
3995 | case "vandaag":
|
3996 | return references.today(context.refDate);
|
3997 | case "morgen":
|
3998 | case "morgend":
|
3999 | return references.tomorrow(context.refDate);
|
4000 | case "gisteren":
|
4001 | return references.yesterday(context.refDate);
|
4002 | }
|
4003 | return component;
|
4004 | }
|
4005 | }
|
4006 | exports.default = NLCasualDateParser;
|
4007 |
|
4008 | },{"../../../common/casualReferences":6,"../../../common/parsers/AbstractParserWithWordBoundary":7}],69:[function(require,module,exports){
|
4009 | "use strict";
|
4010 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
4011 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4012 | };
|
4013 | Object.defineProperty(exports, "__esModule", { value: true });
|
4014 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
4015 | const index_1 = require("../../../index");
|
4016 | const dayjs_1 = require("../../../utils/dayjs");
|
4017 | const dayjs_2 = __importDefault(require("dayjs"));
|
4018 | const DATE_GROUP = 1;
|
4019 | const TIME_OF_DAY_GROUP = 2;
|
4020 | class NLCasualDateTimeParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
4021 | innerPattern(context) {
|
4022 | return /(gisteren|morgen|van)(ochtend|middag|namiddag|avond|nacht)(?=\W|$)/i;
|
4023 | }
|
4024 | innerExtract(context, match) {
|
4025 | const dateText = match[DATE_GROUP].toLowerCase();
|
4026 | const timeText = match[TIME_OF_DAY_GROUP].toLowerCase();
|
4027 | const component = context.createParsingComponents();
|
4028 | const targetDate = dayjs_2.default(context.refDate);
|
4029 | switch (dateText) {
|
4030 | case "gisteren":
|
4031 | dayjs_1.assignSimilarDate(component, targetDate.add(-1, "day"));
|
4032 | break;
|
4033 | case "van":
|
4034 | dayjs_1.assignSimilarDate(component, targetDate);
|
4035 | break;
|
4036 | case "morgen":
|
4037 | dayjs_1.assignTheNextDay(component, targetDate);
|
4038 | break;
|
4039 | }
|
4040 | switch (timeText) {
|
4041 | case "ochtend":
|
4042 | component.imply("meridiem", index_1.Meridiem.AM);
|
4043 | component.imply("hour", 6);
|
4044 | break;
|
4045 | case "middag":
|
4046 | component.imply("meridiem", index_1.Meridiem.AM);
|
4047 | component.imply("hour", 12);
|
4048 | break;
|
4049 | case "namiddag":
|
4050 | component.imply("meridiem", index_1.Meridiem.PM);
|
4051 | component.imply("hour", 15);
|
4052 | break;
|
4053 | case "avond":
|
4054 | component.imply("meridiem", index_1.Meridiem.PM);
|
4055 | component.imply("hour", 20);
|
4056 | break;
|
4057 | }
|
4058 | return component;
|
4059 | }
|
4060 | }
|
4061 | exports.default = NLCasualDateTimeParser;
|
4062 |
|
4063 | },{"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../index":20,"../../../utils/dayjs":90,"dayjs":93}],70:[function(require,module,exports){
|
4064 | "use strict";
|
4065 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
4066 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4067 | };
|
4068 | Object.defineProperty(exports, "__esModule", { value: true });
|
4069 | const index_1 = require("../../../index");
|
4070 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
4071 | const dayjs_1 = __importDefault(require("dayjs"));
|
4072 | const dayjs_2 = require("../../../utils/dayjs");
|
4073 | const DAY_GROUP = 1;
|
4074 | const MOMENT_GROUP = 2;
|
4075 | class NLCasualTimeParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
4076 | innerPattern() {
|
4077 | return /(deze)?\s*(namiddag|avond|middernacht|ochtend|middag|'s middags|'s avonds|'s ochtends)(?=\W|$)/i;
|
4078 | }
|
4079 | innerExtract(context, match) {
|
4080 | const targetDate = dayjs_1.default(context.refDate);
|
4081 | const component = context.createParsingComponents();
|
4082 | if (match[DAY_GROUP] === "deze") {
|
4083 | component.assign("day", context.refDate.getDate());
|
4084 | component.assign("month", context.refDate.getMonth() + 1);
|
4085 | component.assign("year", context.refDate.getFullYear());
|
4086 | }
|
4087 | switch (match[MOMENT_GROUP].toLowerCase()) {
|
4088 | case "namiddag":
|
4089 | case "'s namiddags":
|
4090 | component.imply("meridiem", index_1.Meridiem.PM);
|
4091 | component.imply("hour", 15);
|
4092 | break;
|
4093 | case "avond":
|
4094 | case "'s avonds'":
|
4095 | component.imply("meridiem", index_1.Meridiem.PM);
|
4096 | component.imply("hour", 20);
|
4097 | break;
|
4098 | case "middernacht":
|
4099 | dayjs_2.assignTheNextDay(component, targetDate);
|
4100 | component.imply("hour", 0);
|
4101 | component.imply("minute", 0);
|
4102 | component.imply("second", 0);
|
4103 | break;
|
4104 | case "ochtend":
|
4105 | case "'s ochtends":
|
4106 | component.imply("meridiem", index_1.Meridiem.AM);
|
4107 | component.imply("hour", 6);
|
4108 | break;
|
4109 | case "middag":
|
4110 | case "'s middags":
|
4111 | component.imply("meridiem", index_1.Meridiem.AM);
|
4112 | component.imply("hour", 12);
|
4113 | break;
|
4114 | }
|
4115 | return component;
|
4116 | }
|
4117 | }
|
4118 | exports.default = NLCasualTimeParser;
|
4119 |
|
4120 | },{"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../index":20,"../../../utils/dayjs":90,"dayjs":93}],71:[function(require,module,exports){
|
4121 | "use strict";
|
4122 | Object.defineProperty(exports, "__esModule", { value: true });
|
4123 | const constants_1 = require("../constants");
|
4124 | const pattern_1 = require("../../../utils/pattern");
|
4125 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
4126 | const PATTERN = new RegExp(`([0-9]{4})[\\.\\/\\s]` +
|
4127 | `(?:(${pattern_1.matchAnyPattern(constants_1.MONTH_DICTIONARY)})|([0-9]{1,2}))[\\.\\/\\s]` +
|
4128 | `([0-9]{1,2})` +
|
4129 | "(?=\\W|$)", "i");
|
4130 | const YEAR_NUMBER_GROUP = 1;
|
4131 | const MONTH_NAME_GROUP = 2;
|
4132 | const MONTH_NUMBER_GROUP = 3;
|
4133 | const DATE_NUMBER_GROUP = 4;
|
4134 | class NLCasualYearMonthDayParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
4135 | innerPattern() {
|
4136 | return PATTERN;
|
4137 | }
|
4138 | innerExtract(context, match) {
|
4139 | const month = match[MONTH_NUMBER_GROUP]
|
4140 | ? parseInt(match[MONTH_NUMBER_GROUP])
|
4141 | : constants_1.MONTH_DICTIONARY[match[MONTH_NAME_GROUP].toLowerCase()];
|
4142 | if (month < 1 || month > 12) {
|
4143 | return null;
|
4144 | }
|
4145 | const year = parseInt(match[YEAR_NUMBER_GROUP]);
|
4146 | const day = parseInt(match[DATE_NUMBER_GROUP]);
|
4147 | return {
|
4148 | day: day,
|
4149 | month: month,
|
4150 | year: year,
|
4151 | };
|
4152 | }
|
4153 | }
|
4154 | exports.default = NLCasualYearMonthDayParser;
|
4155 |
|
4156 | },{"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../utils/pattern":91,"../constants":66}],72:[function(require,module,exports){
|
4157 | "use strict";
|
4158 | Object.defineProperty(exports, "__esModule", { value: true });
|
4159 | const years_1 = require("../../../calculation/years");
|
4160 | const constants_1 = require("../constants");
|
4161 | const constants_2 = require("../constants");
|
4162 | const constants_3 = require("../constants");
|
4163 | const pattern_1 = require("../../../utils/pattern");
|
4164 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
4165 | const PATTERN = new RegExp("(?:on\\s*?)?" +
|
4166 | `(${constants_2.ORDINAL_NUMBER_PATTERN})` +
|
4167 | "(?:\\s*" +
|
4168 | "(?:tot|\\-|\\–|until|through|till|\\s)\\s*" +
|
4169 | `(${constants_2.ORDINAL_NUMBER_PATTERN})` +
|
4170 | ")?" +
|
4171 | "(?:-|/|\\s*(?:of)?\\s*)" +
|
4172 | "(" +
|
4173 | pattern_1.matchAnyPattern(constants_1.MONTH_DICTIONARY) +
|
4174 | ")" +
|
4175 | "(?:" +
|
4176 | "(?:-|/|,?\\s*)" +
|
4177 | `(${constants_3.YEAR_PATTERN}(?![^\\s]\\d))` +
|
4178 | ")?" +
|
4179 | "(?=\\W|$)", "i");
|
4180 | const MONTH_NAME_GROUP = 3;
|
4181 | const DATE_GROUP = 1;
|
4182 | const DATE_TO_GROUP = 2;
|
4183 | const YEAR_GROUP = 4;
|
4184 | class NLMonthNameMiddleEndianParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
4185 | innerPattern() {
|
4186 | return PATTERN;
|
4187 | }
|
4188 | innerExtract(context, match) {
|
4189 | const month = constants_1.MONTH_DICTIONARY[match[MONTH_NAME_GROUP].toLowerCase()];
|
4190 | const day = constants_2.parseOrdinalNumberPattern(match[DATE_GROUP]);
|
4191 | if (day > 31) {
|
4192 | match.index = match.index + match[DATE_GROUP].length;
|
4193 | return null;
|
4194 | }
|
4195 | const components = context.createParsingComponents({
|
4196 | day: day,
|
4197 | month: month,
|
4198 | });
|
4199 | if (match[YEAR_GROUP]) {
|
4200 | const year = constants_3.parseYear(match[YEAR_GROUP]);
|
4201 | components.assign("year", year);
|
4202 | }
|
4203 | else {
|
4204 | const year = years_1.findYearClosestToRef(context.refDate, day, month);
|
4205 | components.imply("year", year);
|
4206 | }
|
4207 | if (!match[DATE_TO_GROUP]) {
|
4208 | return components;
|
4209 | }
|
4210 | const endDate = constants_2.parseOrdinalNumberPattern(match[DATE_TO_GROUP]);
|
4211 | const result = context.createParsingResult(match.index, match[0]);
|
4212 | result.start = components;
|
4213 | result.end = components.clone();
|
4214 | result.end.assign("day", endDate);
|
4215 | return result;
|
4216 | }
|
4217 | }
|
4218 | exports.default = NLMonthNameMiddleEndianParser;
|
4219 |
|
4220 | },{"../../../calculation/years":3,"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../utils/pattern":91,"../constants":66}],73:[function(require,module,exports){
|
4221 | "use strict";
|
4222 | Object.defineProperty(exports, "__esModule", { value: true });
|
4223 | const constants_1 = require("../constants");
|
4224 | const years_1 = require("../../../calculation/years");
|
4225 | const pattern_1 = require("../../../utils/pattern");
|
4226 | const constants_2 = require("../constants");
|
4227 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
4228 | const PATTERN = new RegExp(`(${pattern_1.matchAnyPattern(constants_1.MONTH_DICTIONARY)})` +
|
4229 | `\\s*` +
|
4230 | `(?:` +
|
4231 | `[,-]?\\s*(${constants_2.YEAR_PATTERN})?` +
|
4232 | ")?" +
|
4233 | "(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)", "i");
|
4234 | const MONTH_NAME_GROUP = 1;
|
4235 | const YEAR_GROUP = 2;
|
4236 | class NLMonthNameParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
4237 | innerPattern() {
|
4238 | return PATTERN;
|
4239 | }
|
4240 | innerExtract(context, match) {
|
4241 | const components = context.createParsingComponents();
|
4242 | components.imply("day", 1);
|
4243 | const monthName = match[MONTH_NAME_GROUP];
|
4244 | const month = constants_1.MONTH_DICTIONARY[monthName.toLowerCase()];
|
4245 | components.assign("month", month);
|
4246 | if (match[YEAR_GROUP]) {
|
4247 | const year = constants_2.parseYear(match[YEAR_GROUP]);
|
4248 | components.assign("year", year);
|
4249 | }
|
4250 | else {
|
4251 | const year = years_1.findYearClosestToRef(context.refDate, 1, month);
|
4252 | components.imply("year", year);
|
4253 | }
|
4254 | return components;
|
4255 | }
|
4256 | }
|
4257 | exports.default = NLMonthNameParser;
|
4258 |
|
4259 | },{"../../../calculation/years":3,"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../utils/pattern":91,"../constants":66}],74:[function(require,module,exports){
|
4260 | "use strict";
|
4261 | Object.defineProperty(exports, "__esModule", { value: true });
|
4262 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
4263 | const PATTERN = new RegExp("([0-9]|0[1-9]|1[012])/([0-9]{4})" + "", "i");
|
4264 | const MONTH_GROUP = 1;
|
4265 | const YEAR_GROUP = 2;
|
4266 | class NLSlashMonthFormatParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
4267 | innerPattern() {
|
4268 | return PATTERN;
|
4269 | }
|
4270 | innerExtract(context, match) {
|
4271 | const year = parseInt(match[YEAR_GROUP]);
|
4272 | const month = parseInt(match[MONTH_GROUP]);
|
4273 | return context.createParsingComponents().imply("day", 1).assign("month", month).assign("year", year);
|
4274 | }
|
4275 | }
|
4276 | exports.default = NLSlashMonthFormatParser;
|
4277 |
|
4278 | },{"../../../common/parsers/AbstractParserWithWordBoundary":7}],75:[function(require,module,exports){
|
4279 | "use strict";
|
4280 | Object.defineProperty(exports, "__esModule", { value: true });
|
4281 | const AbstractTimeExpressionParser_1 = require("../../../common/parsers/AbstractTimeExpressionParser");
|
4282 | class NLTimeExpressionParser extends AbstractTimeExpressionParser_1.AbstractTimeExpressionParser {
|
4283 | primaryPrefix() {
|
4284 | return "(?:(?:om)\\s*)?";
|
4285 | }
|
4286 | followingPhase() {
|
4287 | return "\\s*(?:\\-|\\–|\\~|\\〜|om|\\?)\\s*";
|
4288 | }
|
4289 | extractPrimaryTimeComponents(context, match) {
|
4290 | if (match[0].match(/^\s*\d{4}\s*$/)) {
|
4291 | return null;
|
4292 | }
|
4293 | return super.extractPrimaryTimeComponents(context, match);
|
4294 | }
|
4295 | }
|
4296 | exports.default = NLTimeExpressionParser;
|
4297 |
|
4298 | },{"../../../common/parsers/AbstractTimeExpressionParser":8}],76:[function(require,module,exports){
|
4299 | "use strict";
|
4300 | Object.defineProperty(exports, "__esModule", { value: true });
|
4301 | const constants_1 = require("../constants");
|
4302 | const results_1 = require("../../../results");
|
4303 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
4304 | class NLTimeUnitWithinFormatParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
4305 | innerPattern() {
|
4306 | return new RegExp(`(?:binnen|in|binnen de|voor)\\s*` + "(" + constants_1.TIME_UNITS_PATTERN + ")" + `(?=\\W|$)`, "i");
|
4307 | }
|
4308 | innerExtract(context, match) {
|
4309 | const timeUnits = constants_1.parseTimeUnits(match[1]);
|
4310 | return results_1.ParsingComponents.createRelativeFromRefDate(context.refDate, timeUnits);
|
4311 | }
|
4312 | }
|
4313 | exports.default = NLTimeUnitWithinFormatParser;
|
4314 |
|
4315 | },{"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../results":89,"../constants":66}],77:[function(require,module,exports){
|
4316 | "use strict";
|
4317 | Object.defineProperty(exports, "__esModule", { value: true });
|
4318 | const constants_1 = require("../../nl/constants");
|
4319 | const pattern_1 = require("../../../utils/pattern");
|
4320 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
4321 | const weeks_1 = require("../../../calculation/weeks");
|
4322 | const PATTERN = new RegExp("(?:(?:\\,|\\(|\\()\\s*)?" +
|
4323 | "(?:op\\s*?)?" +
|
4324 | "(?:(deze|vorige|volgende)\\s*(?:week\\s*)?)?" +
|
4325 | `(${pattern_1.matchAnyPattern(constants_1.WEEKDAY_DICTIONARY)})` +
|
4326 | "(?=\\W|$)", "i");
|
4327 | const PREFIX_GROUP = 1;
|
4328 | const WEEKDAY_GROUP = 2;
|
4329 | const POSTFIX_GROUP = 3;
|
4330 | class NLWeekdayParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
4331 | innerPattern() {
|
4332 | return PATTERN;
|
4333 | }
|
4334 | innerExtract(context, match) {
|
4335 | const dayOfWeek = match[WEEKDAY_GROUP].toLowerCase();
|
4336 | const offset = constants_1.WEEKDAY_DICTIONARY[dayOfWeek];
|
4337 | const prefix = match[PREFIX_GROUP];
|
4338 | const postfix = match[POSTFIX_GROUP];
|
4339 | let modifierWord = prefix || postfix;
|
4340 | modifierWord = modifierWord || "";
|
4341 | modifierWord = modifierWord.toLowerCase();
|
4342 | let modifier = null;
|
4343 | if (modifierWord == "vorige") {
|
4344 | modifier = "last";
|
4345 | }
|
4346 | else if (modifierWord == "volgende") {
|
4347 | modifier = "next";
|
4348 | }
|
4349 | else if (modifierWord == "deze") {
|
4350 | modifier = "this";
|
4351 | }
|
4352 | const date = weeks_1.toDayJSWeekday(context.refDate, offset, modifier);
|
4353 | return context
|
4354 | .createParsingComponents()
|
4355 | .assign("weekday", offset)
|
4356 | .imply("day", date.date())
|
4357 | .imply("month", date.month() + 1)
|
4358 | .imply("year", date.year());
|
4359 | }
|
4360 | }
|
4361 | exports.default = NLWeekdayParser;
|
4362 |
|
4363 | },{"../../../calculation/weeks":2,"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../utils/pattern":91,"../../nl/constants":66}],78:[function(require,module,exports){
|
4364 | "use strict";
|
4365 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
4366 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4367 | };
|
4368 | Object.defineProperty(exports, "__esModule", { value: true });
|
4369 | const AbstractMergeDateRangeRefiner_1 = __importDefault(require("../../../common/refiners/AbstractMergeDateRangeRefiner"));
|
4370 | class NLMergeDateRangeRefiner extends AbstractMergeDateRangeRefiner_1.default {
|
4371 | patternBetween() {
|
4372 | return /^\s*(tot|-)\s*$/i;
|
4373 | }
|
4374 | }
|
4375 | exports.default = NLMergeDateRangeRefiner;
|
4376 |
|
4377 | },{"../../../common/refiners/AbstractMergeDateRangeRefiner":11}],79:[function(require,module,exports){
|
4378 | "use strict";
|
4379 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
4380 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4381 | };
|
4382 | Object.defineProperty(exports, "__esModule", { value: true });
|
4383 | const AbstractMergeDateTimeRefiner_1 = __importDefault(require("../../../common/refiners/AbstractMergeDateTimeRefiner"));
|
4384 | class NLMergeDateTimeRefiner extends AbstractMergeDateTimeRefiner_1.default {
|
4385 | patternBetween() {
|
4386 | return new RegExp("^\\s*(om|na|voor|in de|,|-)?\\s*$");
|
4387 | }
|
4388 | }
|
4389 | exports.default = NLMergeDateTimeRefiner;
|
4390 |
|
4391 | },{"../../../common/refiners/AbstractMergeDateTimeRefiner":12}],80:[function(require,module,exports){
|
4392 | "use strict";
|
4393 | Object.defineProperty(exports, "__esModule", { value: true });
|
4394 | exports.parseYear = exports.YEAR_PATTERN = exports.MONTH_DICTIONARY = exports.WEEKDAY_DICTIONARY = void 0;
|
4395 | exports.WEEKDAY_DICTIONARY = {
|
4396 | "domingo": 0,
|
4397 | "dom": 0,
|
4398 | "segunda": 1,
|
4399 | "segunda-feira": 1,
|
4400 | "seg": 1,
|
4401 | "terça": 2,
|
4402 | "terça-feira": 2,
|
4403 | "ter": 2,
|
4404 | "quarta": 3,
|
4405 | "quarta-feira": 3,
|
4406 | "qua": 3,
|
4407 | "quinta": 4,
|
4408 | "quinta-feira": 4,
|
4409 | "qui": 4,
|
4410 | "sexta": 5,
|
4411 | "sexta-feira": 5,
|
4412 | "sex": 5,
|
4413 | "sábado": 6,
|
4414 | "sabado": 6,
|
4415 | "sab": 6,
|
4416 | };
|
4417 | exports.MONTH_DICTIONARY = {
|
4418 | "janeiro": 1,
|
4419 | "jan": 1,
|
4420 | "jan.": 1,
|
4421 | "fevereiro": 2,
|
4422 | "fev": 2,
|
4423 | "fev.": 2,
|
4424 | "março": 3,
|
4425 | "mar": 3,
|
4426 | "mar.": 3,
|
4427 | "abril": 4,
|
4428 | "abr": 4,
|
4429 | "abr.": 4,
|
4430 | "maio": 5,
|
4431 | "mai": 5,
|
4432 | "mai.": 5,
|
4433 | "junho": 6,
|
4434 | "jun": 6,
|
4435 | "jun.": 6,
|
4436 | "julho": 7,
|
4437 | "jul": 7,
|
4438 | "jul.": 7,
|
4439 | "agosto": 8,
|
4440 | "ago": 8,
|
4441 | "ago.": 8,
|
4442 | "setembro": 9,
|
4443 | "set": 9,
|
4444 | "set.": 9,
|
4445 | "outubro": 10,
|
4446 | "out": 10,
|
4447 | "out.": 10,
|
4448 | "novembro": 11,
|
4449 | "nov": 11,
|
4450 | "nov.": 11,
|
4451 | "dezembro": 12,
|
4452 | "dez": 12,
|
4453 | "dez.": 12,
|
4454 | };
|
4455 | exports.YEAR_PATTERN = "[0-9]{1,4}(?![^\\s]\\d)(?:\\s*[a|d]\\.?\\s*c\\.?|\\s*a\\.?\\s*d\\.?)?";
|
4456 | function parseYear(match) {
|
4457 | if (match.match(/^[0-9]{1,4}$/)) {
|
4458 | let yearNumber = parseInt(match);
|
4459 | if (yearNumber < 100) {
|
4460 | if (yearNumber > 50) {
|
4461 | yearNumber = yearNumber + 1900;
|
4462 | }
|
4463 | else {
|
4464 | yearNumber = yearNumber + 2000;
|
4465 | }
|
4466 | }
|
4467 | return yearNumber;
|
4468 | }
|
4469 | if (match.match(/a\.?\s*c\.?/i)) {
|
4470 | match = match.replace(/a\.?\s*c\.?/i, "");
|
4471 | return -parseInt(match);
|
4472 | }
|
4473 | return parseInt(match);
|
4474 | }
|
4475 | exports.parseYear = parseYear;
|
4476 |
|
4477 | },{}],81:[function(require,module,exports){
|
4478 | "use strict";
|
4479 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
4480 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4481 | };
|
4482 | Object.defineProperty(exports, "__esModule", { value: true });
|
4483 | exports.createConfiguration = exports.createCasualConfiguration = exports.parseDate = exports.parse = exports.strict = exports.casual = void 0;
|
4484 | const configurations_1 = require("../../configurations");
|
4485 | const chrono_1 = require("../../chrono");
|
4486 | const SlashDateFormatParser_1 = __importDefault(require("../../common/parsers/SlashDateFormatParser"));
|
4487 | const PTWeekdayParser_1 = __importDefault(require("./parsers/PTWeekdayParser"));
|
4488 | const PTTimeExpressionParser_1 = __importDefault(require("./parsers/PTTimeExpressionParser"));
|
4489 | const PTMergeDateTimeRefiner_1 = __importDefault(require("./refiners/PTMergeDateTimeRefiner"));
|
4490 | const PTMergeDateRangeRefiner_1 = __importDefault(require("./refiners/PTMergeDateRangeRefiner"));
|
4491 | const PTMonthNameLittleEndianParser_1 = __importDefault(require("./parsers/PTMonthNameLittleEndianParser"));
|
4492 | const PTCasualDateParser_1 = __importDefault(require("./parsers/PTCasualDateParser"));
|
4493 | const PTCasualTimeParser_1 = __importDefault(require("./parsers/PTCasualTimeParser"));
|
4494 | exports.casual = new chrono_1.Chrono(createCasualConfiguration());
|
4495 | exports.strict = new chrono_1.Chrono(createConfiguration(true));
|
4496 | function parse(text, ref, option) {
|
4497 | return exports.casual.parse(text, ref, option);
|
4498 | }
|
4499 | exports.parse = parse;
|
4500 | function parseDate(text, ref, option) {
|
4501 | return exports.casual.parseDate(text, ref, option);
|
4502 | }
|
4503 | exports.parseDate = parseDate;
|
4504 | function createCasualConfiguration(littleEndian = true) {
|
4505 | const option = createConfiguration(false, littleEndian);
|
4506 | option.parsers.push(new PTCasualDateParser_1.default());
|
4507 | option.parsers.push(new PTCasualTimeParser_1.default());
|
4508 | return option;
|
4509 | }
|
4510 | exports.createCasualConfiguration = createCasualConfiguration;
|
4511 | function createConfiguration(strictMode = true, littleEndian = true) {
|
4512 | return configurations_1.includeCommonConfiguration({
|
4513 | parsers: [
|
4514 | new SlashDateFormatParser_1.default(littleEndian),
|
4515 | new PTWeekdayParser_1.default(),
|
4516 | new PTTimeExpressionParser_1.default(),
|
4517 | new PTMonthNameLittleEndianParser_1.default(),
|
4518 | ],
|
4519 | refiners: [new PTMergeDateTimeRefiner_1.default(), new PTMergeDateRangeRefiner_1.default()],
|
4520 | }, strictMode);
|
4521 | }
|
4522 | exports.createConfiguration = createConfiguration;
|
4523 |
|
4524 | },{"../../chrono":4,"../../common/parsers/SlashDateFormatParser":10,"../../configurations":19,"./parsers/PTCasualDateParser":82,"./parsers/PTCasualTimeParser":83,"./parsers/PTMonthNameLittleEndianParser":84,"./parsers/PTTimeExpressionParser":85,"./parsers/PTWeekdayParser":86,"./refiners/PTMergeDateRangeRefiner":87,"./refiners/PTMergeDateTimeRefiner":88}],82:[function(require,module,exports){
|
4525 | "use strict";
|
4526 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
4527 | if (k2 === undefined) k2 = k;
|
4528 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
4529 | }) : (function(o, m, k, k2) {
|
4530 | if (k2 === undefined) k2 = k;
|
4531 | o[k2] = m[k];
|
4532 | }));
|
4533 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
4534 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
4535 | }) : function(o, v) {
|
4536 | o["default"] = v;
|
4537 | });
|
4538 | var __importStar = (this && this.__importStar) || function (mod) {
|
4539 | if (mod && mod.__esModule) return mod;
|
4540 | var result = {};
|
4541 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
4542 | __setModuleDefault(result, mod);
|
4543 | return result;
|
4544 | };
|
4545 | Object.defineProperty(exports, "__esModule", { value: true });
|
4546 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
4547 | const references = __importStar(require("../../../common/casualReferences"));
|
4548 | class PTCasualDateParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
4549 | innerPattern(context) {
|
4550 | return /(agora|hoje|amanha|amanhã|ontem)(?=\W|$)/i;
|
4551 | }
|
4552 | innerExtract(context, match) {
|
4553 | const lowerText = match[0].toLowerCase();
|
4554 | const component = context.createParsingComponents();
|
4555 | switch (lowerText) {
|
4556 | case "agora":
|
4557 | return references.now(context.refDate);
|
4558 | case "hoje":
|
4559 | return references.today(context.refDate);
|
4560 | case "amanha":
|
4561 | case "amanhã":
|
4562 | return references.tomorrow(context.refDate);
|
4563 | case "ontem":
|
4564 | return references.yesterday(context.refDate);
|
4565 | }
|
4566 | return component;
|
4567 | }
|
4568 | }
|
4569 | exports.default = PTCasualDateParser;
|
4570 |
|
4571 | },{"../../../common/casualReferences":6,"../../../common/parsers/AbstractParserWithWordBoundary":7}],83:[function(require,module,exports){
|
4572 | "use strict";
|
4573 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
4574 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4575 | };
|
4576 | Object.defineProperty(exports, "__esModule", { value: true });
|
4577 | const index_1 = require("../../../index");
|
4578 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
4579 | const dayjs_1 = require("../../../utils/dayjs");
|
4580 | const dayjs_2 = __importDefault(require("dayjs"));
|
4581 | class PTCasualTimeParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
4582 | innerPattern() {
|
4583 | return /(?:esta\s*)?(manha|manhã|tarde|meia-noite|meio-dia|noite)(?=\W|$)/i;
|
4584 | }
|
4585 | innerExtract(context, match) {
|
4586 | const targetDate = dayjs_2.default(context.refDate);
|
4587 | const component = context.createParsingComponents();
|
4588 | switch (match[1].toLowerCase()) {
|
4589 | case "tarde":
|
4590 | component.imply("meridiem", index_1.Meridiem.PM);
|
4591 | component.imply("hour", 15);
|
4592 | break;
|
4593 | case "noite":
|
4594 | component.imply("meridiem", index_1.Meridiem.PM);
|
4595 | component.imply("hour", 22);
|
4596 | break;
|
4597 | case "manha":
|
4598 | case "manhã":
|
4599 | component.imply("meridiem", index_1.Meridiem.AM);
|
4600 | component.imply("hour", 6);
|
4601 | break;
|
4602 | case "meia-noite":
|
4603 | dayjs_1.assignTheNextDay(component, targetDate);
|
4604 | component.imply("hour", 0);
|
4605 | component.imply("minute", 0);
|
4606 | component.imply("second", 0);
|
4607 | break;
|
4608 | case "meio-dia":
|
4609 | component.imply("meridiem", index_1.Meridiem.AM);
|
4610 | component.imply("hour", 12);
|
4611 | break;
|
4612 | }
|
4613 | return component;
|
4614 | }
|
4615 | }
|
4616 | exports.default = PTCasualTimeParser;
|
4617 |
|
4618 | },{"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../index":20,"../../../utils/dayjs":90,"dayjs":93}],84:[function(require,module,exports){
|
4619 | "use strict";
|
4620 | Object.defineProperty(exports, "__esModule", { value: true });
|
4621 | const years_1 = require("../../../calculation/years");
|
4622 | const constants_1 = require("../constants");
|
4623 | const constants_2 = require("../constants");
|
4624 | const pattern_1 = require("../../../utils/pattern");
|
4625 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
4626 | const PATTERN = new RegExp(`([0-9]{1,2})(?:º|ª|°)?` +
|
4627 | "(?:\\s*(?:desde|de|\\-|\\–|ao?|\\s)\\s*([0-9]{1,2})(?:º|ª|°)?)?\\s*(?:de)?\\s*" +
|
4628 | `(?:-|/|\\s*(?:de|,)?\\s*)` +
|
4629 | `(${pattern_1.matchAnyPattern(constants_1.MONTH_DICTIONARY)})` +
|
4630 | `(?:\\s*(?:de|,)?\\s*(${constants_2.YEAR_PATTERN}))?` +
|
4631 | `(?=\\W|$)`, "i");
|
4632 | const DATE_GROUP = 1;
|
4633 | const DATE_TO_GROUP = 2;
|
4634 | const MONTH_NAME_GROUP = 3;
|
4635 | const YEAR_GROUP = 4;
|
4636 | class PTMonthNameLittleEndianParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
4637 | innerPattern() {
|
4638 | return PATTERN;
|
4639 | }
|
4640 | innerExtract(context, match) {
|
4641 | const result = context.createParsingResult(match.index, match[0]);
|
4642 | const month = constants_1.MONTH_DICTIONARY[match[MONTH_NAME_GROUP].toLowerCase()];
|
4643 | const day = parseInt(match[DATE_GROUP]);
|
4644 | if (day > 31) {
|
4645 | match.index = match.index + match[DATE_GROUP].length;
|
4646 | return null;
|
4647 | }
|
4648 | result.start.assign("month", month);
|
4649 | result.start.assign("day", day);
|
4650 | if (match[YEAR_GROUP]) {
|
4651 | const yearNumber = constants_2.parseYear(match[YEAR_GROUP]);
|
4652 | result.start.assign("year", yearNumber);
|
4653 | }
|
4654 | else {
|
4655 | const year = years_1.findYearClosestToRef(context.refDate, day, month);
|
4656 | result.start.imply("year", year);
|
4657 | }
|
4658 | if (match[DATE_TO_GROUP]) {
|
4659 | const endDate = parseInt(match[DATE_TO_GROUP]);
|
4660 | result.end = result.start.clone();
|
4661 | result.end.assign("day", endDate);
|
4662 | }
|
4663 | return result;
|
4664 | }
|
4665 | }
|
4666 | exports.default = PTMonthNameLittleEndianParser;
|
4667 |
|
4668 | },{"../../../calculation/years":3,"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../utils/pattern":91,"../constants":80}],85:[function(require,module,exports){
|
4669 | "use strict";
|
4670 | Object.defineProperty(exports, "__esModule", { value: true });
|
4671 | const AbstractTimeExpressionParser_1 = require("../../../common/parsers/AbstractTimeExpressionParser");
|
4672 | class PTTimeExpressionParser extends AbstractTimeExpressionParser_1.AbstractTimeExpressionParser {
|
4673 | primaryPrefix() {
|
4674 | return "(?:(?:ao?|às?|das|da|de|do)\\s*)?";
|
4675 | }
|
4676 | followingPhase() {
|
4677 | return "\\s*(?:\\-|\\–|\\~|\\〜|a(?:o)?|\\?)\\s*";
|
4678 | }
|
4679 | }
|
4680 | exports.default = PTTimeExpressionParser;
|
4681 |
|
4682 | },{"../../../common/parsers/AbstractTimeExpressionParser":8}],86:[function(require,module,exports){
|
4683 | "use strict";
|
4684 | Object.defineProperty(exports, "__esModule", { value: true });
|
4685 | const constants_1 = require("../constants");
|
4686 | const pattern_1 = require("../../../utils/pattern");
|
4687 | const AbstractParserWithWordBoundary_1 = require("../../../common/parsers/AbstractParserWithWordBoundary");
|
4688 | const weeks_1 = require("../../../calculation/weeks");
|
4689 | const PATTERN = new RegExp("(?:(?:\\,|\\(|\\()\\s*)?" +
|
4690 | "(?:(este|esta|passado|pr[oó]ximo)\\s*)?" +
|
4691 | `(${pattern_1.matchAnyPattern(constants_1.WEEKDAY_DICTIONARY)})` +
|
4692 | "(?:\\s*(?:\\,|\\)|\\)))?" +
|
4693 | "(?:\\s*(este|esta|passado|pr[óo]ximo)\\s*semana)?" +
|
4694 | "(?=\\W|\\d|$)", "i");
|
4695 | const PREFIX_GROUP = 1;
|
4696 | const WEEKDAY_GROUP = 2;
|
4697 | const POSTFIX_GROUP = 3;
|
4698 | class PTWeekdayParser extends AbstractParserWithWordBoundary_1.AbstractParserWithWordBoundaryChecking {
|
4699 | innerPattern() {
|
4700 | return PATTERN;
|
4701 | }
|
4702 | innerExtract(context, match) {
|
4703 | const dayOfWeek = match[WEEKDAY_GROUP].toLowerCase();
|
4704 | const offset = constants_1.WEEKDAY_DICTIONARY[dayOfWeek];
|
4705 | if (offset === undefined) {
|
4706 | return null;
|
4707 | }
|
4708 | const prefix = match[PREFIX_GROUP];
|
4709 | const postfix = match[POSTFIX_GROUP];
|
4710 | let norm = prefix || postfix || "";
|
4711 | norm = norm.toLowerCase();
|
4712 | let modifier = null;
|
4713 | if (norm == "passado") {
|
4714 | modifier = "this";
|
4715 | }
|
4716 | else if (norm == "próximo" || norm == "proximo") {
|
4717 | modifier = "next";
|
4718 | }
|
4719 | else if (norm == "este") {
|
4720 | modifier = "this";
|
4721 | }
|
4722 | const date = weeks_1.toDayJSWeekday(context.refDate, offset, modifier);
|
4723 | return context
|
4724 | .createParsingComponents()
|
4725 | .assign("weekday", offset)
|
4726 | .imply("day", date.date())
|
4727 | .imply("month", date.month() + 1)
|
4728 | .imply("year", date.year());
|
4729 | }
|
4730 | }
|
4731 | exports.default = PTWeekdayParser;
|
4732 |
|
4733 | },{"../../../calculation/weeks":2,"../../../common/parsers/AbstractParserWithWordBoundary":7,"../../../utils/pattern":91,"../constants":80}],87:[function(require,module,exports){
|
4734 | "use strict";
|
4735 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
4736 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4737 | };
|
4738 | Object.defineProperty(exports, "__esModule", { value: true });
|
4739 | const AbstractMergeDateRangeRefiner_1 = __importDefault(require("../../../common/refiners/AbstractMergeDateRangeRefiner"));
|
4740 | class PTMergeDateRangeRefiner extends AbstractMergeDateRangeRefiner_1.default {
|
4741 | patternBetween() {
|
4742 | return /^\s*(?:-)\s*$/i;
|
4743 | }
|
4744 | }
|
4745 | exports.default = PTMergeDateRangeRefiner;
|
4746 |
|
4747 | },{"../../../common/refiners/AbstractMergeDateRangeRefiner":11}],88:[function(require,module,exports){
|
4748 | "use strict";
|
4749 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
4750 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4751 | };
|
4752 | Object.defineProperty(exports, "__esModule", { value: true });
|
4753 | const AbstractMergeDateTimeRefiner_1 = __importDefault(require("../../../common/refiners/AbstractMergeDateTimeRefiner"));
|
4754 | class PTMergeDateTimeRefiner extends AbstractMergeDateTimeRefiner_1.default {
|
4755 | patternBetween() {
|
4756 | return new RegExp("^\\s*(?:,|à)?\\s*$");
|
4757 | }
|
4758 | }
|
4759 | exports.default = PTMergeDateTimeRefiner;
|
4760 |
|
4761 | },{"../../../common/refiners/AbstractMergeDateTimeRefiner":12}],89:[function(require,module,exports){
|
4762 | "use strict";
|
4763 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
4764 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4765 | };
|
4766 | Object.defineProperty(exports, "__esModule", { value: true });
|
4767 | exports.ParsingResult = exports.ParsingComponents = void 0;
|
4768 | const quarterOfYear_1 = __importDefault(require("dayjs/plugin/quarterOfYear"));
|
4769 | const dayjs_1 = __importDefault(require("dayjs"));
|
4770 | const dayjs_2 = require("./utils/dayjs");
|
4771 | dayjs_1.default.extend(quarterOfYear_1.default);
|
4772 | class ParsingComponents {
|
4773 | constructor(refDate, knownComponents) {
|
4774 | this.knownValues = {};
|
4775 | this.impliedValues = {};
|
4776 | if (knownComponents) {
|
4777 | for (const key in knownComponents) {
|
4778 | this.knownValues[key] = knownComponents[key];
|
4779 | }
|
4780 | }
|
4781 | const refDayJs = dayjs_1.default(refDate);
|
4782 | this.imply("day", refDayJs.date());
|
4783 | this.imply("month", refDayJs.month() + 1);
|
4784 | this.imply("year", refDayJs.year());
|
4785 | this.imply("hour", 12);
|
4786 | this.imply("minute", 0);
|
4787 | this.imply("second", 0);
|
4788 | this.imply("millisecond", 0);
|
4789 | }
|
4790 | get(component) {
|
4791 | if (component in this.knownValues) {
|
4792 | return this.knownValues[component];
|
4793 | }
|
4794 | if (component in this.impliedValues) {
|
4795 | return this.impliedValues[component];
|
4796 | }
|
4797 | return null;
|
4798 | }
|
4799 | isCertain(component) {
|
4800 | return component in this.knownValues;
|
4801 | }
|
4802 | getCertainComponents() {
|
4803 | return Object.keys(this.knownValues);
|
4804 | }
|
4805 | imply(component, value) {
|
4806 | if (component in this.knownValues) {
|
4807 | return this;
|
4808 | }
|
4809 | this.impliedValues[component] = value;
|
4810 | return this;
|
4811 | }
|
4812 | assign(component, value) {
|
4813 | this.knownValues[component] = value;
|
4814 | delete this.impliedValues[component];
|
4815 | return this;
|
4816 | }
|
4817 | delete(component) {
|
4818 | delete this.knownValues[component];
|
4819 | delete this.impliedValues[component];
|
4820 | }
|
4821 | clone() {
|
4822 | const component = new ParsingComponents(new Date());
|
4823 | component.knownValues = {};
|
4824 | component.impliedValues = {};
|
4825 | for (const key in this.knownValues) {
|
4826 | component.knownValues[key] = this.knownValues[key];
|
4827 | }
|
4828 | for (const key in this.impliedValues) {
|
4829 | component.impliedValues[key] = this.impliedValues[key];
|
4830 | }
|
4831 | return component;
|
4832 | }
|
4833 | isOnlyDate() {
|
4834 | return !this.isCertain("hour") && !this.isCertain("minute") && !this.isCertain("second");
|
4835 | }
|
4836 | isOnlyTime() {
|
4837 | return !this.isCertain("weekday") && !this.isCertain("day") && !this.isCertain("month");
|
4838 | }
|
4839 | isOnlyWeekdayComponent() {
|
4840 | return this.isCertain("weekday") && !this.isCertain("day") && !this.isCertain("month");
|
4841 | }
|
4842 | isOnlyDayMonthComponent() {
|
4843 | return this.isCertain("day") && this.isCertain("month") && !this.isCertain("year");
|
4844 | }
|
4845 | isValidDate() {
|
4846 | const date = this.isCertain("timezoneOffset") ? this.dateWithoutTimezoneAdjustment() : this.date();
|
4847 | if (date.getFullYear() !== this.get("year"))
|
4848 | return false;
|
4849 | if (date.getMonth() !== this.get("month") - 1)
|
4850 | return false;
|
4851 | if (date.getDate() !== this.get("day"))
|
4852 | return false;
|
4853 | if (this.get("hour") != null && date.getHours() != this.get("hour"))
|
4854 | return false;
|
4855 | if (this.get("minute") != null && date.getMinutes() != this.get("minute"))
|
4856 | return false;
|
4857 | return true;
|
4858 | }
|
4859 | toString() {
|
4860 | return `[ParsingComponents {knownValues: ${JSON.stringify(this.knownValues)}, impliedValues: ${JSON.stringify(this.impliedValues)}}]`;
|
4861 | }
|
4862 | dayjs() {
|
4863 | return dayjs_1.default(this.date());
|
4864 | }
|
4865 | date() {
|
4866 | const date = this.dateWithoutTimezoneAdjustment();
|
4867 | return new Date(date.getTime() + this.getTimezoneAdjustmentMinute(date) * 60000);
|
4868 | }
|
4869 | dateWithoutTimezoneAdjustment() {
|
4870 | const date = new Date(this.get("year"), this.get("month") - 1, this.get("day"), this.get("hour"), this.get("minute"), this.get("second"), this.get("millisecond"));
|
4871 | date.setFullYear(this.get("year"));
|
4872 | return date;
|
4873 | }
|
4874 | getTimezoneAdjustmentMinute(date) {
|
4875 | var _a;
|
4876 | date = date !== null && date !== void 0 ? date : new Date();
|
4877 | const currentTimezoneOffset = -date.getTimezoneOffset();
|
4878 | const targetTimezoneOffset = (_a = this.get("timezoneOffset")) !== null && _a !== void 0 ? _a : currentTimezoneOffset;
|
4879 | return currentTimezoneOffset - targetTimezoneOffset;
|
4880 | }
|
4881 | static createRelativeFromRefDate(refDate, fragments) {
|
4882 | let date = dayjs_1.default(refDate);
|
4883 | for (const key in fragments) {
|
4884 | date = date.add(fragments[key], key);
|
4885 | }
|
4886 | const components = new ParsingComponents(refDate);
|
4887 | if (fragments["hour"] || fragments["minute"] || fragments["second"]) {
|
4888 | dayjs_2.assignSimilarTime(components, date);
|
4889 | dayjs_2.assignSimilarDate(components, date);
|
4890 | }
|
4891 | else {
|
4892 | dayjs_2.implySimilarTime(components, date);
|
4893 | if (fragments["d"]) {
|
4894 | components.assign("day", date.date());
|
4895 | components.assign("month", date.month() + 1);
|
4896 | components.assign("year", date.year());
|
4897 | }
|
4898 | else {
|
4899 | if (fragments["week"]) {
|
4900 | components.imply("weekday", date.day());
|
4901 | }
|
4902 | components.imply("day", date.date());
|
4903 | if (fragments["month"]) {
|
4904 | components.assign("month", date.month() + 1);
|
4905 | components.assign("year", date.year());
|
4906 | }
|
4907 | else {
|
4908 | components.imply("month", date.month() + 1);
|
4909 | if (fragments["year"]) {
|
4910 | components.assign("year", date.year());
|
4911 | }
|
4912 | else {
|
4913 | components.imply("year", date.year());
|
4914 | }
|
4915 | }
|
4916 | }
|
4917 | }
|
4918 | return components;
|
4919 | }
|
4920 | }
|
4921 | exports.ParsingComponents = ParsingComponents;
|
4922 | class ParsingResult {
|
4923 | constructor(refDate, index, text, start, end) {
|
4924 | this.refDate = refDate;
|
4925 | this.index = index;
|
4926 | this.text = text;
|
4927 | this.start = start || new ParsingComponents(this.refDate);
|
4928 | this.end = end;
|
4929 | }
|
4930 | clone() {
|
4931 | const result = new ParsingResult(this.refDate, this.index, this.text);
|
4932 | result.start = this.start ? this.start.clone() : null;
|
4933 | result.end = this.end ? this.end.clone() : null;
|
4934 | return result;
|
4935 | }
|
4936 | date() {
|
4937 | return this.start.date();
|
4938 | }
|
4939 | toString() {
|
4940 | return `[ParsingResult {index: ${this.index}, text: '${this.text}', ...}]`;
|
4941 | }
|
4942 | }
|
4943 | exports.ParsingResult = ParsingResult;
|
4944 |
|
4945 | },{"./utils/dayjs":90,"dayjs":93,"dayjs/plugin/quarterOfYear":94}],90:[function(require,module,exports){
|
4946 | "use strict";
|
4947 | Object.defineProperty(exports, "__esModule", { value: true });
|
4948 | exports.implySimilarTime = exports.assignSimilarTime = exports.assignSimilarDate = exports.assignTheNextDay = void 0;
|
4949 | function assignTheNextDay(component, targetDayJs) {
|
4950 | targetDayJs = targetDayJs.add(1, "day");
|
4951 | assignSimilarDate(component, targetDayJs);
|
4952 | implySimilarTime(component, targetDayJs);
|
4953 | }
|
4954 | exports.assignTheNextDay = assignTheNextDay;
|
4955 | function assignSimilarDate(component, targetDayJs) {
|
4956 | component.assign("day", targetDayJs.date());
|
4957 | component.assign("month", targetDayJs.month() + 1);
|
4958 | component.assign("year", targetDayJs.year());
|
4959 | }
|
4960 | exports.assignSimilarDate = assignSimilarDate;
|
4961 | function assignSimilarTime(component, targetDayJs) {
|
4962 | component.assign("hour", targetDayJs.hour());
|
4963 | component.assign("minute", targetDayJs.minute());
|
4964 | component.assign("second", targetDayJs.second());
|
4965 | component.assign("millisecond", targetDayJs.millisecond());
|
4966 | component.assign("timezoneOffset", targetDayJs.utcOffset());
|
4967 | }
|
4968 | exports.assignSimilarTime = assignSimilarTime;
|
4969 | function implySimilarTime(component, targetDayJs) {
|
4970 | component.imply("hour", targetDayJs.hour());
|
4971 | component.imply("minute", targetDayJs.minute());
|
4972 | component.imply("second", targetDayJs.second());
|
4973 | component.imply("millisecond", targetDayJs.millisecond());
|
4974 | component.imply("timezoneOffset", targetDayJs.utcOffset());
|
4975 | }
|
4976 | exports.implySimilarTime = implySimilarTime;
|
4977 |
|
4978 | },{}],91:[function(require,module,exports){
|
4979 | "use strict";
|
4980 | Object.defineProperty(exports, "__esModule", { value: true });
|
4981 | exports.matchAnyPattern = exports.extractTerms = exports.repeatedTimeunitPattern = void 0;
|
4982 | function repeatedTimeunitPattern(prefix, singleTimeunitPattern) {
|
4983 | const singleTimeunitPatternNoCapture = singleTimeunitPattern.replace(/\((?!\?)/g, "(?:");
|
4984 | return `${prefix}${singleTimeunitPatternNoCapture}\\s*(?:,?\\s{0,5}${singleTimeunitPatternNoCapture}){0,10}`;
|
4985 | }
|
4986 | exports.repeatedTimeunitPattern = repeatedTimeunitPattern;
|
4987 | function extractTerms(dictionary) {
|
4988 | let keys;
|
4989 | if (dictionary instanceof Array) {
|
4990 | keys = [...dictionary];
|
4991 | }
|
4992 | else if (dictionary instanceof Map) {
|
4993 | keys = Array.from(dictionary.keys());
|
4994 | }
|
4995 | else {
|
4996 | keys = Object.keys(dictionary);
|
4997 | }
|
4998 | return keys;
|
4999 | }
|
5000 | exports.extractTerms = extractTerms;
|
5001 | function matchAnyPattern(dictionary) {
|
5002 | const joinedTerms = extractTerms(dictionary)
|
5003 | .sort((a, b) => b.length - a.length)
|
5004 | .join("|")
|
5005 | .replace(/\./g, "\\.");
|
5006 | return `(?:${joinedTerms})`;
|
5007 | }
|
5008 | exports.matchAnyPattern = matchAnyPattern;
|
5009 |
|
5010 | },{}],92:[function(require,module,exports){
|
5011 | "use strict";
|
5012 | Object.defineProperty(exports, "__esModule", { value: true });
|
5013 | exports.addImpliedTimeUnits = exports.reverseTimeUnits = void 0;
|
5014 | function reverseTimeUnits(timeUnits) {
|
5015 | const reversed = {};
|
5016 | for (const key in timeUnits) {
|
5017 | reversed[key] = -timeUnits[key];
|
5018 | }
|
5019 | return reversed;
|
5020 | }
|
5021 | exports.reverseTimeUnits = reverseTimeUnits;
|
5022 | function addImpliedTimeUnits(components, timeUnits) {
|
5023 | const output = components.clone();
|
5024 | let date = components.dayjs();
|
5025 | for (const key in timeUnits) {
|
5026 | date = date.add(timeUnits[key], key);
|
5027 | }
|
5028 | if ("day" in timeUnits || "d" in timeUnits || "week" in timeUnits || "month" in timeUnits || "year" in timeUnits) {
|
5029 | output.imply("day", date.date());
|
5030 | output.imply("month", date.month() + 1);
|
5031 | output.imply("year", date.year());
|
5032 | }
|
5033 | if ("second" in timeUnits || "minute" in timeUnits || "hour" in timeUnits) {
|
5034 | output.imply("second", date.second());
|
5035 | output.imply("minute", date.minute());
|
5036 | output.imply("hour", date.hour());
|
5037 | }
|
5038 | return output;
|
5039 | }
|
5040 | exports.addImpliedTimeUnits = addImpliedTimeUnits;
|
5041 |
|
5042 | },{}],93:[function(require,module,exports){
|
5043 | !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).dayjs=e()}(this,(function(){"use strict";var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",f="month",h="quarter",c="year",d="date",$="Invalid Date",l=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},m=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},g={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,f),s=n-i<0,u=e.clone().add(r+(s?-1:1),f);return+(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:f,y:c,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:h}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},D="en",v={};v[D]=M;var p=function(t){return t instanceof _},S=function(t,e,n){var r;if(!t)return D;if("string"==typeof t)v[t]&&(r=t),e&&(v[t]=e,r=t);else{var i=t.name;v[i]=t,r=i}return!n&&r&&(D=r),r||!n&&D},w=function(t,e){if(p(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},O=g;O.l=S,O.i=p,O.w=function(t,e){return w(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=S(t.locale,null,!0),this.parse(t)}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(O.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match(l);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return O},m.isValid=function(){return!(this.$d.toString()===$)},m.isSame=function(t,e){var n=w(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return w(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<w(t)},m.$g=function(t,e,n){return O.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!O.u(e)||e,h=O.p(t),$=function(t,e){var i=O.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},l=function(t,e){return O.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,g="set"+(this.$u?"UTC":"");switch(h){case c:return r?$(1,0):$(31,11);case f:return r?$(1,M):$(0,M+1);case o:var D=this.$locale().weekStart||0,v=(y<D?y+7:y)-D;return $(r?m-v:m+(6-v),M);case a:case d:return l(g+"Hours",0);case u:return l(g+"Minutes",1);case s:return l(g+"Seconds",2);case i:return l(g+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=O.p(t),h="set"+(this.$u?"UTC":""),$=(n={},n[a]=h+"Date",n[d]=h+"Date",n[f]=h+"Month",n[c]=h+"FullYear",n[u]=h+"Hours",n[s]=h+"Minutes",n[i]=h+"Seconds",n[r]=h+"Milliseconds",n)[o],l=o===a?this.$D+(e-this.$W):e;if(o===f||o===c){var y=this.clone().set(d,1);y.$d[$](l),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d}else $&&this.$d[$](l);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[O.p(t)]()},m.add=function(r,h){var d,$=this;r=Number(r);var l=O.p(h),y=function(t){var e=w($);return O.w(e.date(e.date()+Math.round(t*r)),$)};if(l===f)return this.set(f,this.$M+r);if(l===c)return this.set(c,this.$y+r);if(l===a)return y(1);if(l===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[l]||1,m=this.$d.getTime()+r*M;return O.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this;if(!this.isValid())return $;var n=t||"YYYY-MM-DDTHH:mm:ssZ",r=O.z(this),i=this.$locale(),s=this.$H,u=this.$m,a=this.$M,o=i.weekdays,f=i.months,h=function(t,r,i,s){return t&&(t[r]||t(e,n))||i[r].substr(0,s)},c=function(t){return O.s(s%12||12,t,"0")},d=i.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},l={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:O.s(a+1,2,"0"),MMM:h(i.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:O.s(this.$D,2,"0"),d:String(this.$W),dd:h(i.weekdaysMin,this.$W,o,2),ddd:h(i.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:O.s(s,2,"0"),h:c(1),hh:c(2),a:d(s,u,!0),A:d(s,u,!1),m:String(u),mm:O.s(u,2,"0"),s:String(this.$s),ss:O.s(this.$s,2,"0"),SSS:O.s(this.$ms,3,"0"),Z:r};return n.replace(y,(function(t,e){return e||l[t]||r.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,$){var l,y=O.p(d),M=w(r),m=(M.utcOffset()-this.utcOffset())*e,g=this-M,D=O.m(this,M);return D=(l={},l[c]=D/12,l[f]=D,l[h]=D/3,l[o]=(g-m)/6048e5,l[a]=(g-m)/864e5,l[u]=g/n,l[s]=g/e,l[i]=g/t,l)[y]||g,$?D:O.a(D)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return v[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=S(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return O.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),b=_.prototype;return w.prototype=b,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",f],["$y",c],["$D",d]].forEach((function(t){b[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),w.extend=function(t,e){return t.$i||(t(e,_,w),t.$i=!0),w},w.locale=S,w.isDayjs=p,w.unix=function(t){return w(1e3*t)},w.en=v[D],w.Ls=v,w.p={},w}));
|
5044 | },{}],94:[function(require,module,exports){
|
5045 | !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).dayjs_plugin_quarterOfYear=n()}(this,(function(){"use strict";var t="month",n="quarter";return function(e,i){var r=i.prototype;r.quarter=function(t){return this.$utils().u(t)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(t-1))};var s=r.add;r.add=function(e,i){return e=Number(e),this.$utils().p(i)===n?this.add(3*e,t):s.bind(this)(e,i)};var u=r.startOf;r.startOf=function(e,i){var r=this.$utils(),s=!!r.u(i)||i;if(r.p(e)===n){var o=this.quarter()-1;return s?this.month(3*o).startOf(t).startOf("day"):this.month(3*o+2).endOf(t).endOf("day")}return u.bind(this)(e,i)}}}));
|
5046 | },{}]},{},[20])(20)
|
5047 | });
|