[mpd] Use math.floor when formatting song progress (#75)

This ensure compatibility with Lua 5.3
This commit is contained in:
Juan Carlos Menonita 2019-03-03 21:23:23 -06:00 committed by Nguyễn Gia Phong
parent a3759eb8a4
commit bb74db1835
1 changed files with 3 additions and 2 deletions

View File

@ -9,6 +9,7 @@ local io = { popen = io.popen }
local setmetatable = setmetatable
local string = { gmatch = string.gmatch }
local helpers = require("vicious.helpers")
local math = { floor = math.floor }
-- }}}
@ -25,8 +26,8 @@ end
-- {{{ Format playing progress
function format_progress(elapsed, duration)
local em, es = elapsed / 60, elapsed % 60
local dm, ds = duration / 60, duration % 60
local em, es = math.floor(elapsed / 60), math.floor(elapsed % 60)
local dm, ds = math.floor(duration / 60), math.floor(duration % 60)
if dm < 10 then
return ("%d:%02d"):format(em, es), ("%d:%02d"):format(dm, ds)