Skip to content

christianwish/string-to-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

string-to-time

Build Status

Get time information from strings

Install

$ npm i string-to-time

Use

const { stringToTime } = require('string-to-time');

const estimation = '4 hours for some stuff, 1.2 days plus 2 x 35 minutes for somthing else...'
const time = stringToTime(estimation);

console.log(time);
// --> { d: 1, h: 6, m: 46 }

The following units are working when given next to a number:

  • for minutes: m, minute, minutes
  • for hours: h, hour, hours
  • for days: d, day, days

Furthermore it's possible to add one multiplication before a unit: '2 x 35 minutes' => { d: 0, h: 1, m: 10 }

About

get minutes, hours and days calculation from strings

Resources

Stars

Watchers

Forks

Packages

No packages published