diff --git a/src/stringifier.js b/src/stringifier.js index 6549149..dab47f0 100644 --- a/src/stringifier.js +++ b/src/stringifier.js @@ -6,7 +6,8 @@ function pad00(n) { return `00${n}`.slice(-2); } -export function stringifyTime(t) { +export function stringifyTime(tf) { + const t = Number.parseFloat(tf.toFixed(2)); const ms = t.toFixed(2).slice(-2); const s = (t | 0) % 60; const m = (t / 60 | 0) % 60; diff --git a/test/stringifier.js b/test/stringifier.js index df2f9c1..3284b3b 100644 --- a/test/stringifier.js +++ b/test/stringifier.js @@ -6,6 +6,7 @@ import { parsed, stringified, parsed2, stringified2 } from './fixtures/stringifi describe('ASS stringifier', () => { it('should stringify time', () => { expect(stringifyTime(0)).to.equal('0:00:00.00'); + expect(stringifyTime(15.999)).to.equal('0:00:16.00'); expect(stringifyTime(5025.67)).to.equal('1:23:45.67'); });