Skip to content

virtual-designer/timeconv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

timeconv

Converts short time strings into numeric values representing that time in seconds.

Documentation

To use timeconv in your project, install it using the following command:

npm install timeconv

And then simply import it in your JS/TS file.

import timeconv from 'timeconv';

Functions

timeconv.stringToTimeInterval(input: string): { error: string | undefined, seconds: number }

This function takes a string input containing numbers and units, that represents time interval, and calculates the total seconds. If the calculation is successful, seconds will be a normal number and error will be undefined. Otherwise, error will be a string and seconds will be NaN.

Example
import timeconv from 'timeconv';

console.log(timeconv.stringToTimeInterval("1h45m30s")); // { error: undefined, seconds: 6330 }

About

Timeconv: Convert short time strings into numeric values representing that time in seconds

Resources

License

Stars

Watchers

Forks