Giter Site home page Giter Site logo

human-interval's Introduction

Human Interval

Human-readable interval parser for Javascript.

Converts words written in English to numbers by using node-numbered.

Originally inspired by matthewmueller/date.

Uses

Human Interval is used by job scheduling libraries such as Agenda and Bree. They are a job schedulers for Node.js with cron expression syntax, human-friendly times, Dates, and more!

Example usage

const humanInterval = require('human-interval');

setTimeout(() => {
  // Do something!
}, humanInterval('three minutes'));

More sophisticated examples

Human Interval understands all of the following examples:

humanInterval('minute');
humanInterval('one minute');
humanInterval('1.5 minutes');
humanInterval('3 days and 4 hours');
humanInterval('3 days, 4 hours and 36 seconds');
humanInterval('4 months, 3 days, 5 hours and forty-five seconds');

The full list

Units

Supports the following units in the plural and singular forms:

  • seconds
  • minutes
  • hours
  • days
  • weeks
  • months โ€” assumes 30 days
  • years โ€” assumes 365 days

Wordy numbers

Supports numbers being written out in English words.

humanInterval('five minutes');

Hyphenated numbers

Supports hyphenated numbers.

humanInterval('twenty-five seconds');

Negative numbers

Supports negative numbers if the time starts with a - symbol immediately followed by a number.

humanInterval('-2 minutes');

License

The MIT License

human-interval's People

Contributors

simison avatar rschmukler avatar omgimalexis avatar renovate[bot] avatar renovate-bot avatar capacitorset avatar sampathblam avatar theabstractdev avatar niftylettuce 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.