Coder Social home page Coder Social logo

prettycron's Introduction

prettyCron Build Status

prettyCron is a simple JavaScript deuglifier for cron schedules: it prints out a human-readable interpretation of when the schedule will run.

For examples...

... check out the project home page.

Installation - browser

Include prettycron.js after adding moment.js and later.js.

<script src="moment.min.js" type="text/javascript"></script>
<script src="later.min.js" type="text/javascript"></script>
<script src="prettycron.js" type="text/javascript"></script>

Installation - Node

Simply use npm and require:

$ npm install prettycron
var prettyCron = require('prettycron');

Usage

prettyCron exposes two methods, both of which take a cron specification as the only argument.

prettyCron.toString(cron)

Returns a human-readable sentence describing all the times this cron will run.

prettyCron.toString("37 10 * * * *");
// returns "10:37 every day"

prettyCron.getNext(cron)

Returns a string representing the next time this cron will run, formatted with moment's calendar() method.

prettyCron.getNext("0 * * * *");
// if current time is 4:45pm, then returns "Today at 5:00 PM"

prettyCron.getNextDates(cron, numDates)

Returns an array of strings representing the next (numDates) amount of times this cron will run, formatted with moment's calendar() method.

prettyCron.getNextDates("0 * * * *", 4);
// If current time is 3.45 PM, then returns [ 'Today at 4:00 PM', 'Today at 5:00 PM', 'Today at 6:00 PM', 'Today at 7:00 PM' ]

Credits

prettyCron was originally written by dunse and posted to gist. This version is by Hourann Bosci with contributions from Johan Andersson, Phil Jepsen, Andre Buchanan, and Anton Petrov.

It's licensed under LGPLv3.

prettycron's People

Contributors

azza-bazoo avatar anderssonjohan avatar audace avatar danielmschmidt avatar fdaugan avatar andrebuchanan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.