coopy / hh-mm-ss

:watch: Simple hh:mm:ss time formatting utility for use in media players

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hh-mm-ss: time formatting utility

Build Status js-standard-style

⌚ Convert seconds or miliseconds to hh:mm:ss format and vice versa.

var TimeFormat = require('hh-mm-ss')

TimeFormat.toS('137:00:00')            // 493200

TimeFormat.fromS(194)                  // '03:14'
TimeFormat.fromS(150, 'hh:mm:ss')      // '00:02:30'

TimeFormat.fromMs(12345)               // '00:12.345'

Usage

toMs(time)

Convert given hh:mm:ss formatted string to miliseconds

Parameters

  • time String representation

toS(time)

Convert given hh:mm:ss formatted string to seconds

Parameters

  • time String representation

fromMs(ms, format)

Generate formatted string from time in miliseconds

Parameters

  • ms Time in miliseconds
  • format (optional) Default output format. If not specified, mm:ss is implied. See section below for supported format list

fromS(s, format)

Generate formatted string from time in seconds

Parameters

  • s Time in seconds
  • format (optional) Default output format. If not specified, mm:ss is implied. See section below for supported format list

Supported time formats

The following formats are supported: mm:ss, hh:mm:ss, mm:ss.sss, hh:mm:ss.sss.

  • hh - hours
  • mm - minutes
  • ss - second
  • sss - miliseconds

Install

npm install hh-mm-ss --save

License

MIT

About

:watch: Simple hh:mm:ss time formatting utility for use in media players


Languages

Language:JavaScript 100.0%