From 56f08269280cd97a9d76806567a933e3a95dd2c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20Wa=CC=88rting?= Date: Fri, 16 Aug 2019 22:27:37 +0200 Subject: [PATCH] remove zero fill at the final place supersede #1583 --- package-lock.json | 5 ----- package.json | 3 +-- src/renderer/pages/player-page.js | 15 +++++++-------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index f51ae335..36c41ea5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10659,11 +10659,6 @@ "fd-slicer": "~1.0.1" } }, - "zero-fill": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/zero-fill/-/zero-fill-2.2.3.tgz", - "integrity": "sha1-o97wa6XjmuZEhQu0yirUEStIVek=" - }, "zip-stream": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/zip-stream/-/zip-stream-1.2.0.tgz", diff --git a/package.json b/package.json index 81824c54..e68f11d6 100644 --- a/package.json +++ b/package.json @@ -47,8 +47,7 @@ "srt-to-vtt": "^1.1.1", "vlc-command": "^1.0.1", "webtorrent": "0.x", - "winreg": "^1.2.0", - "zero-fill": "^2.2.3" + "winreg": "^1.2.0" }, "devDependencies": { "babel-eslint": "^10.0.2", diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index 46dbe55c..b58dba56 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -3,7 +3,6 @@ const React = require('react') const Bitfield = require('bitfield') const prettyBytes = require('prettier-bytes') -const zeroFill = require('zero-fill') const TorrentSummary = require('../lib/torrent-summary') const Playlist = require('../lib/playlist') @@ -758,14 +757,14 @@ function formatTime (time, total) { return '0:00' } - const totalHours = Math.floor(total / 3600) - const totalMinutes = Math.floor(total / 60) - const hours = Math.floor(time / 3600) - let minutes = Math.floor(time % 3600 / 60) - if (totalMinutes > 9) { - minutes = zeroFill(2, minutes) + const totalHours = total / 3600 | 0 + const totalMinutes = total / 60 | 0 + const hours = time / 3600 | 0 + let minutes = time % 3600 / 60 | 0 + if (totalMinutes > 9 && minutes < 10) { + minutes = '0' + minutes } - const seconds = zeroFill(2, Math.floor(time % 60)) + const seconds = `0${time % 60 | 0}`.slice(-2) return (totalHours > 0 ? hours + ':' : '') + minutes + ':' + seconds }