cronstrue 3.41.0 → 3.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -106,6 +106,9 @@ var CronParser = (function () {
106
106
  };
107
107
  CronParser.prototype.normalize = function (expressionParts) {
108
108
  var _this = this;
109
+ for (var i = 0; i < expressionParts.length; i++) {
110
+ expressionParts[i] = expressionParts[i].toUpperCase();
111
+ }
109
112
  expressionParts[3] = expressionParts[3].replace("?", "*");
110
113
  expressionParts[5] = expressionParts[5].replace("?", "*");
111
114
  expressionParts[2] = expressionParts[2].replace("?", "*");
@@ -140,9 +143,10 @@ var CronParser = (function () {
140
143
  }
141
144
  return t.replace(dowDigits, dowDigitsAdjusted);
142
145
  });
143
- if (expressionParts[5] == "L") {
144
- expressionParts[5] = "6";
145
- }
146
+ expressionParts[5] = expressionParts[5]
147
+ .split(",")
148
+ .map(function (item) { return (item == "L" ? "6" : item); })
149
+ .join(",");
146
150
  if (expressionParts[3] == "?") {
147
151
  expressionParts[3] = "*";
148
152
  }
@@ -474,7 +478,7 @@ var ExpressionDescriptor = (function () {
474
478
  };
475
479
  ExpressionDescriptor.prototype.getDayOfWeekDescription = function (dayOfWeekExpression) {
476
480
  var _this = this;
477
- var _a, _b;
481
+ var _a, _b, _c, _d;
478
482
  if (dayOfWeekExpression === void 0) { dayOfWeekExpression = this.expressionParts[5]; }
479
483
  var daysOfWeekNames = this.i18n.daysOfTheWeek();
480
484
  var description = null;
@@ -483,11 +487,19 @@ var ExpressionDescriptor = (function () {
483
487
  }
484
488
  else {
485
489
  var dayOfWeekItems = dayOfWeekExpression.split(",");
490
+ var nthOrLastItems = dayOfWeekItems.filter(function (s) { return /[#L]/.test(s); });
491
+ var plainItems = dayOfWeekItems.filter(function (s) { return !/[#L]/.test(s); });
492
+ if (plainItems.length > 0 && nthOrLastItems.some(function (s) { return s.indexOf("#") > -1; })) {
493
+ var nthOrLastDescription = (_a = this.getDayOfWeekDescription(nthOrLastItems.join(","))) !== null && _a !== void 0 ? _a : "";
494
+ return (((_b = this.getDayOfWeekDescription(plainItems.join(","))) !== null && _b !== void 0 ? _b : "") +
495
+ "".concat(this.i18n.spaceAnd(), " ") +
496
+ ExpressionDescriptor.removeLeadingComma(nthOrLastDescription));
497
+ }
486
498
  var lastItems = dayOfWeekItems.filter(function (s) { return s.indexOf("L") > -1; });
487
499
  var otherItems = dayOfWeekItems.filter(function (s) { return s.indexOf("L") === -1; });
488
500
  if (lastItems.length > 0 && otherItems.length > 0) {
489
- var lastDescription = (_a = this.getDayOfWeekDescription(lastItems.join(","))) !== null && _a !== void 0 ? _a : "";
490
- return (((_b = this.getDayOfWeekDescription(otherItems.join(","))) !== null && _b !== void 0 ? _b : "") +
501
+ var lastDescription = (_c = this.getDayOfWeekDescription(lastItems.join(","))) !== null && _c !== void 0 ? _c : "";
502
+ return (((_d = this.getDayOfWeekDescription(otherItems.join(","))) !== null && _d !== void 0 ? _d : "") +
491
503
  "".concat(this.i18n.spaceAnd(), " ") +
492
504
  ExpressionDescriptor.removeLeadingComma(lastDescription));
493
505
  }