cronstrue 2.58.0 → 2.60.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.
@@ -282,7 +282,7 @@ var ExpressionDescriptor = (function () {
282
282
  }
283
283
  }
284
284
  ExpressionDescriptor.toString = function (expression, _a) {
285
- var _b = _a === void 0 ? {} : _a, _c = _b.throwExceptionOnParseError, throwExceptionOnParseError = _c === void 0 ? true : _c, _d = _b.verbose, verbose = _d === void 0 ? false : _d, _e = _b.dayOfWeekStartIndexZero, dayOfWeekStartIndexZero = _e === void 0 ? true : _e, _f = _b.monthStartIndexZero, monthStartIndexZero = _f === void 0 ? false : _f, use24HourTimeFormat = _b.use24HourTimeFormat, _g = _b.locale, locale = _g === void 0 ? null : _g, _h = _b.tzOffset, tzOffset = _h === void 0 ? 0 : _h;
285
+ var _b = _a === void 0 ? {} : _a, _c = _b.throwExceptionOnParseError, throwExceptionOnParseError = _c === void 0 ? true : _c, _d = _b.verbose, verbose = _d === void 0 ? false : _d, _e = _b.dayOfWeekStartIndexZero, dayOfWeekStartIndexZero = _e === void 0 ? true : _e, _f = _b.monthStartIndexZero, monthStartIndexZero = _f === void 0 ? false : _f, use24HourTimeFormat = _b.use24HourTimeFormat, _g = _b.locale, locale = _g === void 0 ? null : _g;
286
286
  var options = {
287
287
  throwExceptionOnParseError: throwExceptionOnParseError,
288
288
  verbose: verbose,
@@ -290,10 +290,9 @@ var ExpressionDescriptor = (function () {
290
290
  monthStartIndexZero: monthStartIndexZero,
291
291
  use24HourTimeFormat: use24HourTimeFormat,
292
292
  locale: locale,
293
- tzOffset: tzOffset,
294
293
  };
295
294
  if (options.tzOffset) {
296
- console.warn("'tzOffset' option has been deprecated and will be removed in a future release.");
295
+ console.warn("'tzOffset' option has been deprecated and is no longer supported.");
297
296
  }
298
297
  var descripter = new ExpressionDescriptor(expression, options);
299
298
  return descripter.getFullDescription();
@@ -427,8 +426,24 @@ var ExpressionDescriptor = (function () {
427
426
  ExpressionDescriptor.prototype.getHoursDescription = function () {
428
427
  var _this = this;
429
428
  var expression = this.expressionParts[2];
429
+ var hourIndex = 0;
430
+ var rangeEndValues = [];
431
+ expression
432
+ .split("/")[0]
433
+ .split(",")
434
+ .forEach(function (range) {
435
+ var rangeParts = range.split("-");
436
+ if (rangeParts.length === 2) {
437
+ rangeEndValues.push({ value: rangeParts[1], index: hourIndex + 1 });
438
+ }
439
+ hourIndex += rangeParts.length;
440
+ });
441
+ var evaluationIndex = 0;
430
442
  var description = this.getSegmentDescription(expression, this.i18n.everyHour(), function (s) {
431
- return _this.formatTime(s, "0", "");
443
+ var match = rangeEndValues.find(function (r) { return r.value === s && r.index === evaluationIndex; });
444
+ var isRangeEndWithNonZeroMinute = match && _this.expressionParts[1] !== "0";
445
+ evaluationIndex++;
446
+ return isRangeEndWithNonZeroMinute ? _this.formatTime(s, "59", "") : _this.formatTime(s, "0", "");
432
447
  }, function (s) {
433
448
  return stringUtilities_1.StringUtilities.format(_this.i18n.everyX0Hours(s), s);
434
449
  }, function (s) {
@@ -436,16 +451,6 @@ var ExpressionDescriptor = (function () {
436
451
  }, function (s) {
437
452
  return _this.i18n.atX0();
438
453
  });
439
- if (description && expression.includes("-") && this.expressionParts[1] != "0") {
440
- var atTheHourMatches = Array.from(description.matchAll(/:00/g));
441
- if (atTheHourMatches.length > 1) {
442
- var lastAtTheHourMatchIndex = atTheHourMatches[atTheHourMatches.length - 1].index;
443
- description =
444
- description.substring(0, lastAtTheHourMatchIndex) +
445
- ":59" +
446
- description.substring(lastAtTheHourMatchIndex + 3);
447
- }
448
- }
449
454
  return description;
450
455
  };
451
456
  ExpressionDescriptor.prototype.getDayOfWeekDescription = function () {
@@ -465,22 +470,6 @@ var ExpressionDescriptor = (function () {
465
470
  exp = exp.replace("L", "");
466
471
  }
467
472
  var parsedExp = parseInt(exp);
468
- if (_this.options.tzOffset) {
469
- var hourExpression = _this.expressionParts[2];
470
- var hour = parseInt(hourExpression) + (_this.options.tzOffset ? _this.options.tzOffset : 0);
471
- if (hour >= 24) {
472
- parsedExp++;
473
- }
474
- else if (hour < 0) {
475
- parsedExp--;
476
- }
477
- if (parsedExp > 6) {
478
- parsedExp = 0;
479
- }
480
- else if (parsedExp < 0) {
481
- parsedExp = 6;
482
- }
483
- }
484
473
  var description = _this.i18n.daysOfTheWeekInCase
485
474
  ? _this.i18n.daysOfTheWeekInCase(form)[parsedExp]
486
475
  : daysOfWeekNames[parsedExp];
@@ -706,13 +695,6 @@ var ExpressionDescriptor = (function () {
706
695
  ExpressionDescriptor.prototype.formatTime = function (hourExpression, minuteExpression, secondExpression) {
707
696
  var hourOffset = 0;
708
697
  var minuteOffset = 0;
709
- if (this.options.tzOffset) {
710
- hourOffset = this.options.tzOffset > 0 ? Math.floor(this.options.tzOffset) : Math.ceil(this.options.tzOffset);
711
- minuteOffset = parseFloat((this.options.tzOffset % 1).toFixed(2));
712
- if (minuteOffset != 0) {
713
- minuteOffset *= 60;
714
- }
715
- }
716
698
  var hour = parseInt(hourExpression) + hourOffset;
717
699
  var minute = parseInt(minuteExpression) + minuteOffset;
718
700
  if (minute >= 60) {