UNPKG

youtube-duration-format

Version:

Format the duration returned by google youtube data api as human understandable

14 lines (11 loc) 491 B
'use strict'; var test = require('ava'); var ytDurationFormat = require('./'); test(function (t) { t.assert(ytDurationFormat('PT2M38S') === '02:38','02:38'); t.assert(ytDurationFormat('PT15M31S') === '15:31','15:31'); t.assert(ytDurationFormat('PT3H56M1S') === '3:56:01','3:56:01'); t.assert(ytDurationFormat('PT55S') === '00:55','00:55'); t.assert(ytDurationFormat('P2W3DT80H21M11S') === '488:21:11','488:21:11'); t.assert(ytDurationFormat('PT2M38S','sec') === 158,'158'); });