cronstrue 3.40.0 → 3.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cronstrue-i18n.js +21 -13
- package/dist/cronstrue-i18n.min.js +1 -1
- package/dist/cronstrue.js +21 -13
- package/dist/cronstrue.min.js +1 -1
- package/dist/expressionDescriptor.d.ts +1 -0
- package/package.json +1 -1
package/dist/cronstrue-i18n.js
CHANGED
|
@@ -474,7 +474,7 @@ var ExpressionDescriptor = (function () {
|
|
|
474
474
|
};
|
|
475
475
|
ExpressionDescriptor.prototype.getDayOfWeekDescription = function (dayOfWeekExpression) {
|
|
476
476
|
var _this = this;
|
|
477
|
-
var _a, _b;
|
|
477
|
+
var _a, _b, _c, _d;
|
|
478
478
|
if (dayOfWeekExpression === void 0) { dayOfWeekExpression = this.expressionParts[5]; }
|
|
479
479
|
var daysOfWeekNames = this.i18n.daysOfTheWeek();
|
|
480
480
|
var description = null;
|
|
@@ -483,11 +483,19 @@ var ExpressionDescriptor = (function () {
|
|
|
483
483
|
}
|
|
484
484
|
else {
|
|
485
485
|
var dayOfWeekItems = dayOfWeekExpression.split(",");
|
|
486
|
+
var nthOrLastItems = dayOfWeekItems.filter(function (s) { return /[#L]/.test(s); });
|
|
487
|
+
var plainItems = dayOfWeekItems.filter(function (s) { return !/[#L]/.test(s); });
|
|
488
|
+
if (plainItems.length > 0 && nthOrLastItems.some(function (s) { return s.indexOf("#") > -1; })) {
|
|
489
|
+
var nthOrLastDescription = (_a = this.getDayOfWeekDescription(nthOrLastItems.join(","))) !== null && _a !== void 0 ? _a : "";
|
|
490
|
+
return (((_b = this.getDayOfWeekDescription(plainItems.join(","))) !== null && _b !== void 0 ? _b : "") +
|
|
491
|
+
"".concat(this.i18n.spaceAnd(), " ") +
|
|
492
|
+
ExpressionDescriptor.removeLeadingComma(nthOrLastDescription));
|
|
493
|
+
}
|
|
486
494
|
var lastItems = dayOfWeekItems.filter(function (s) { return s.indexOf("L") > -1; });
|
|
487
495
|
var otherItems = dayOfWeekItems.filter(function (s) { return s.indexOf("L") === -1; });
|
|
488
496
|
if (lastItems.length > 0 && otherItems.length > 0) {
|
|
489
|
-
var lastDescription = (
|
|
490
|
-
return (((
|
|
497
|
+
var lastDescription = (_c = this.getDayOfWeekDescription(lastItems.join(","))) !== null && _c !== void 0 ? _c : "";
|
|
498
|
+
return (((_d = this.getDayOfWeekDescription(otherItems.join(","))) !== null && _d !== void 0 ? _d : "") +
|
|
491
499
|
"".concat(this.i18n.spaceAnd(), " ") +
|
|
492
500
|
ExpressionDescriptor.removeLeadingComma(lastDescription));
|
|
493
501
|
}
|
|
@@ -587,7 +595,10 @@ var ExpressionDescriptor = (function () {
|
|
|
587
595
|
return description;
|
|
588
596
|
};
|
|
589
597
|
ExpressionDescriptor.removeLeadingComma = function (description) {
|
|
590
|
-
return description.replace(/^[,،,、]
|
|
598
|
+
return description.replace(/^[,،,、] ?/, "");
|
|
599
|
+
};
|
|
600
|
+
ExpressionDescriptor.hasLeadingComma = function (description) {
|
|
601
|
+
return /^[,،,、]/.test(description);
|
|
591
602
|
};
|
|
592
603
|
ExpressionDescriptor.prototype.getDayOfMonthDescription = function (dayOfMonthExpression) {
|
|
593
604
|
var _this = this;
|
|
@@ -718,11 +729,8 @@ var ExpressionDescriptor = (function () {
|
|
|
718
729
|
if (segments[i].indexOf("/") > -1 || segments[i].indexOf("-") > -1) {
|
|
719
730
|
var isSegmentRangeWithoutIncrement = segments[i].indexOf("-") > -1 && segments[i].indexOf("/") == -1;
|
|
720
731
|
var currentDescriptionContent = this.getSegmentDescription(segments[i], allDescription, getSingleItemDescription, getIncrementDescriptionFormat, isSegmentRangeWithoutIncrement ? this.i18n.commaX0ThroughX1 : getRangeDescriptionFormat, getDescriptionFormat);
|
|
721
|
-
if (isSegmentRangeWithoutIncrement) {
|
|
722
|
-
currentDescriptionContent =
|
|
723
|
-
}
|
|
724
|
-
else if (i > 0 && currentDescriptionContent.startsWith(", ")) {
|
|
725
|
-
currentDescriptionContent = currentDescriptionContent.substring(2);
|
|
732
|
+
if (isSegmentRangeWithoutIncrement || i > 0) {
|
|
733
|
+
currentDescriptionContent = ExpressionDescriptor.removeLeadingComma(currentDescriptionContent);
|
|
726
734
|
}
|
|
727
735
|
descriptionContent += currentDescriptionContent;
|
|
728
736
|
}
|
|
@@ -731,8 +739,8 @@ var ExpressionDescriptor = (function () {
|
|
|
731
739
|
}
|
|
732
740
|
else {
|
|
733
741
|
var segmentDescription = this.getSegmentDescription(segments[i], allDescription, getSingleItemDescription, getIncrementDescriptionFormat, getRangeDescriptionFormat, getDescriptionFormat);
|
|
734
|
-
if (i > 0 && segmentDescription
|
|
735
|
-
segmentDescription =
|
|
742
|
+
if (i > 0 && segmentDescription) {
|
|
743
|
+
segmentDescription = ExpressionDescriptor.removeLeadingComma(segmentDescription);
|
|
736
744
|
}
|
|
737
745
|
descriptionContent += segmentDescription;
|
|
738
746
|
}
|
|
@@ -749,14 +757,14 @@ var ExpressionDescriptor = (function () {
|
|
|
749
757
|
description = stringUtilities_1.StringUtilities.format(getIncrementDescriptionFormat(segments[1]), segments[1]);
|
|
750
758
|
if (segments[0].indexOf("-") > -1) {
|
|
751
759
|
var rangeSegmentDescription = this.generateRangeSegmentDescription(segments[0], getRangeDescriptionFormat, getSingleItemDescription);
|
|
752
|
-
if (
|
|
760
|
+
if (!ExpressionDescriptor.hasLeadingComma(rangeSegmentDescription)) {
|
|
753
761
|
description += ", ";
|
|
754
762
|
}
|
|
755
763
|
description += rangeSegmentDescription;
|
|
756
764
|
}
|
|
757
765
|
else if (segments[0].indexOf("*") == -1) {
|
|
758
766
|
var rangeItemDescription = stringUtilities_1.StringUtilities.format(getDescriptionFormat(segments[0]), getSingleItemDescription(segments[0]));
|
|
759
|
-
rangeItemDescription =
|
|
767
|
+
rangeItemDescription = ExpressionDescriptor.removeLeadingComma(rangeItemDescription);
|
|
760
768
|
description += stringUtilities_1.StringUtilities.format(this.i18n.commaStartingX0(), rangeItemDescription);
|
|
761
769
|
}
|
|
762
770
|
description += this.getWrappingIncrementDescription(expression, range, allDescription, getSingleItemDescription, getIncrementDescriptionFormat, getRangeDescriptionFormat, getDescriptionFormat);
|