GithubHelp home page GithubHelp logo

nclaeys / juration Goto Github PK

View Code? Open in Web Editor NEW

This project forked from domchristie/juration

0.0 2.0 1.0 71 KB

A natural language duration parser/stringifier written in javascript

Home Page: http://domchristie.github.com/juration

JavaScript 80.91% HTML 12.94% CSS 6.14%

juration's Introduction

Juration.js

A simple natural language duration parser written in javascript. Time ranges (in seconds) can also be converted to human readable strings. Check out the demo.

Inspired by chronic, and chronic_duration.

Usage

Parsing

juration.parse("3mins 5secs"); // returns 185

Stringifying

juration.stringify(185); // returns "3 mins 5 secs"
juration.stringify(185, { format: 'small' }); // returns "3 mins 5 secs"
juration.stringify(185, { format: 'micro' }); // returns "3m 5s"
juration.stringify(185, { format: 'long' });  // returns "3 minutes 5 seconds"
juration.stringify(185, { format: 'long', units: 1 });  // returns "3 minutes"
juration.stringify(3601, { format: 'micro', units: 2 });  // returns "1h"

Examples

Parse-able strings:

  • 12.4 secs
  • 3 mins 4 sec
  • 2 hrs 20 min
  • 2h20min
  • 6 mos 1 day
  • 47 yrs 6 mos and 4d
  • 3 weeks and 2 days

Todo

  • Add customisable default unit option, e.g. juration.parse("10", { defaultUnit: 'minutes' }) // returns 600
  • Parse chrono format i.e. hh:mm:ss

Licence

Juration is copyright © 2011 Dom Christie and released under the MIT license.

juration's People

Contributors

boivie avatar domchristie avatar jotto avatar miguelff avatar nclaeys avatar

Watchers

 avatar  avatar

Forkers

koningskristof

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.