Skip to content
/ dura Public

Simple and easy extendable library to work with time durations

Notifications You must be signed in to change notification settings

ozio/dura

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dura

Extendable duration library.

Installation

import Dura from 'dura';
import en from 'dura/locales/en';
import humanizePlugin from 'dura/plugins/humanize';

Dura.registerLocales({ en });
Dura.registerPlugins([humanizePlugin]);

Usage

const durationByMills = new Dura(1000);
const durationBySeconds = new Dura(21, 's');
const durationByMinutes = new Dura(30, 'm');
const durationByHours = new Dura(3, 'h');
const durationByDays = new Dura(5, 'd');

Plugins

Humanize

import humanizePlugin from 'dura/plugins/humanize';
Dura.registerPlugins([humanizePlugin]);

const duration = new Dura(7 * 24 * 60 * 60 * 1000);
const humanizedDuration = duration.humaninze('en'); // 7 days
const humanizedRelatedDuration = duration.humaninze('en', true); // in 7 days

About

Simple and easy extendable library to work with time durations

Resources

Stars

Watchers

Forks

Packages

No packages published