JSPM

  • Created
  • Published
  • Downloads 1107356
  • Score
    100M100P100Q177223F
  • License MIT

Convert cron expressions into descriptions

Package Exports

  • cronstrue
  • cronstrue/dist/cronstrue.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cronstrue) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

cronstrue Build Status

cronstrue is a JavaScript library that parses a cron expression and outputs a human readable description of the cron schedule. For example, given the expression "*/5 * * * *" it will output "Every 5 minutes".

This library was ported from the original C# implemenation called cron-expression-descriptor and is also available in a few other languages.

Features

  • Zero dependencies
  • Supports all cron expression special characters including * / , - ? L W, #
  • Supports 5, 6 (w/ seconds or year), or 7 (w/ seconds and year) part cron expressions
  • (i18n support with 14 languages coming soon)

Installation

cronstrue is exported as an UMD module so it will work in an AMD, CommonJS or browser global context.

Node

npm install cronstrue
var cronstrue = require('cronstrue');

Browser

The cronstrue.min.js file from the /dist folder in the npm package should be served to the browser. There are no dependencies so you can simply include the library in a <script> tag.

<script src="cronstrue.min.js" type="text/javascript"></script>
var cronstrue = window.cronstrue;

Usage

cronstrue.toString("* * * * *");
> "Every minute"

cronstrue.toString("0 23 ? * MON-FRI");
> "At 11:00 PM, Monday through Friday"

cronstrue.toString("23 12 * * SUN#2");
> "At 12:23 PM, on the second Sunday of the month"

For more usage examples, including a demonstration of how cronstrue can handle some very complex cron expressions, you can reference the unit tests.

License

cronstrue is freely distributable under the terms of the MIT license.