• Stars
    star
    103
  • Rank 331,207 (Top 7 %)
  • Language
    JavaScript
  • Created about 13 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A natural language duration parser/stringifier written in javascript

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.

More Repositories

1

humps

🐫 Underscore-to-camelCase converter (and vice versa) for strings and object keys in JavaScript.
JavaScript
1,400
star
2

turn

πŸ“– Animate page transitions in Turbo Drive apps
JavaScript
99
star
3

webrtc-hotwire-rails

A video chat app demonstration using Hotwire and Ruby on Rails
JavaScript
61
star
4

photography-view-transitions-nextjs

JavaScript
38
star
5

needles

πŸ“Audio loudness metering in the browser
JavaScript
36
star
6

tailwindcss-jit-rails

An experiment with tailwindcss-jit and the asset pipeline
Ruby
32
star
7

ios-placeholder

A jQuery plugin that mimics the behaviour of iOS placeholder text in input fields
JavaScript
7
star
8

drawer

A starting point for building 2-column responsive layouts that implement a smooth (jank free) sliding sidebar
CSS
4
star
9

csscompress

Minify modern CSS with Ruby
Ruby
3
star
10

slide-r

πŸ‘† Minimalist web component for building horizontal sliding user interfaces
JavaScript
3
star
11

audio-recorder

JavaScript
3
star
12

tmbundle

Frontend snippets for textmate
3
star
13

eddie

JavaScript
3
star
14

tailwind-initial

Tailwind plugin that generates utilities at a low specificity
JavaScript
2
star
15

online-street-photography-course

Eric Kim’s Online Photography Course: http://erickimphotography.com/blog/2014/02/04/free-open-source-online-street-photography-course-all-the-worlds-a-stage-introduction-to-street-photography/
Ruby
2
star
16

anagram

JavaScript
1
star
17

get

JSONP API to retrieve machine readable info from websites and generate embed code for known url types
Ruby
1
star
18

domchristie.co.uk

Astro
1
star
19

hotwire_personalization_test

Ruby
1
star
20

turbolinks_page_invalid_scroll_test

Ruby
1
star
21

go-make-things

JavaScript
1
star
22

turbolinks_materialize_autofocus

Ruby
1
star
23

guide

Styleguides
1
star
24

sweetener

Add getters and setters to a function to connect it with an object
JavaScript
1
star
25

turbo_back_test

demonstration of bug when navigating back whilst a request is in progress
Ruby
1
star
26

photography

HTML
1
star
27

photography-view-transitions

CSS
1
star
28

nice_partials_test

Ruby
1
star
29

progressive-alliance-resources

A list of resources about a progressive electoral alliance in the UK
1
star