cronstrue 3.13.0 → 3.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -128,6 +128,7 @@ An options object can be passed as the second parameter to `cronstrue.toString`.
128
128
  - **dayOfWeekStartIndexZero: boolean** - Whether to interpret cron expression DOW `1` as Sunday or Monday. (Default: true)
129
129
  - **monthStartIndexZero: boolean** - Whether to interpret January as `0` or `1`. (Default: false)
130
130
  - **use24HourTimeFormat: boolean** - If true, descriptions will use a [24-hour clock](https://en.wikipedia.org/wiki/24-hour_clock) (Default: false but some translations will default to true)
131
+ - **trimHoursLeadingZero: boolean** - Whether to trim the leading zero that may appear in the hours description; e.g. "02:00 AM" -> "2:00 AM", "08:00" -> "8:00" (Default: false)
131
132
  - **locale: string** - The locale to use (Default: "en")
132
133
  - **logicalAndDayFields: boolean** - If true, descriptions for cron expressions with both day of month and day of week specified will follow a logical-AND wording rather than logical-OR wording; e.g. "...between day 11 and 17 of the month, only on Friday" rather than "...between day 11 and 17 of the month, and on Friday" (Default: false)
133
134
 
@@ -287,13 +287,14 @@ var ExpressionDescriptor = (function () {
287
287
  }
288
288
  }
289
289
  ExpressionDescriptor.toString = function (expression, _a) {
290
- 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.logicalAndDayFields, logicalAndDayFields = _h === void 0 ? false : _h;
290
+ 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.trimHoursLeadingZero, trimHoursLeadingZero = _g === void 0 ? false : _g, _h = _b.locale, locale = _h === void 0 ? null : _h, _j = _b.logicalAndDayFields, logicalAndDayFields = _j === void 0 ? false : _j;
291
291
  var options = {
292
292
  throwExceptionOnParseError: throwExceptionOnParseError,
293
293
  verbose: verbose,
294
294
  dayOfWeekStartIndexZero: dayOfWeekStartIndexZero,
295
295
  monthStartIndexZero: monthStartIndexZero,
296
296
  use24HourTimeFormat: use24HourTimeFormat,
297
+ trimHoursLeadingZero: trimHoursLeadingZero,
297
298
  locale: locale,
298
299
  logicalAndDayFields: logicalAndDayFields,
299
300
  };
@@ -752,7 +753,12 @@ var ExpressionDescriptor = (function () {
752
753
  if (secondExpression) {
753
754
  second = ":".concat(("00" + secondExpression).substring(secondExpression.length));
754
755
  }
755
- return "".concat(setPeriodBeforeTime ? period : "").concat(("00" + hour.toString()).substring(hour.toString().length), ":").concat(("00" + minute.toString()).substring(minute.toString().length)).concat(second).concat(!setPeriodBeforeTime ? period : "");
756
+ var hourStr = hour.toString();
757
+ var paddedHour = ("00" + hourStr).substring(hourStr.length);
758
+ var minuteStr = minute.toString();
759
+ var paddedMinute = ("00" + minuteStr).substring(minuteStr.length);
760
+ var displayHour = this.options.trimHoursLeadingZero ? hourStr : paddedHour;
761
+ return "".concat(setPeriodBeforeTime ? period : "").concat(displayHour, ":").concat(paddedMinute).concat(second).concat(!setPeriodBeforeTime ? period : "");
756
762
  };
757
763
  ExpressionDescriptor.prototype.transformVerbosity = function (description, useVerboseFormat) {
758
764
  if (!useVerboseFormat) {