juration

WebJar for juration

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

juration
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

juration
WebJar for juration
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/framp/juration

Download juration

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/juration/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>juration</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/juration/
implementation 'org.webjars.npm:juration:0.0.1'
// https://jarcasting.com/artifacts/org.webjars.npm/juration/
implementation ("org.webjars.npm:juration:0.0.1")
'org.webjars.npm:juration:jar:0.0.1'
<dependency org="org.webjars.npm" name="juration" rev="0.0.1">
  <artifact name="juration" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='juration', version='0.0.1')
)
libraryDependencies += "org.webjars.npm" % "juration" % "0.0.1"
[org.webjars.npm/juration "0.0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

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.

Fork changes

  • Added node.js package
  • Multilanguage support

TODO

  • Make juration a function (so that settings aren't shared among instances)

Usage

Client-side:

<script src="juration.js"></script>

Node.js:

var juration = require('juration');

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"

Changing language

Client-side:

<script src="../languages/it-IT.js"></script>

Node.js

juration.setLanguage('it-IT');

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.

Versions

Version
0.0.1