920
edits
m (Slight improvements to toStringLong) |
m (Small fix to toStringLong) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 40: | Line 40: | ||
end | end | ||
function TimeSpan. | function TimeSpan.fromMilliseconds(milliseconds) | ||
return TimeSpan.new(0, 0, 0, 0, (milliseconds or 0)) | return TimeSpan.new(0, 0, 0, 0, (milliseconds or 0)) | ||
end | end | ||
function TimeSpan. | function TimeSpan.fromSeconds(seconds) | ||
local totalMilliseconds = (seconds or 0) * MillisecondsPerSecond | local totalMilliseconds = (seconds or 0) * MillisecondsPerSecond | ||
return TimeSpan.new(0, 0, 0, 0, totalMilliseconds) | return TimeSpan.new(0, 0, 0, 0, totalMilliseconds) | ||
Line 116: | Line 116: | ||
return string.format('0 seconds') | return string.format('0 seconds') | ||
end | end | ||
-- Special case to show actiontime related numbers. | |||
return string.format('%. | return string.format('%.2f seconds', totalSeconds) | ||
end | end | ||
Line 138: | Line 138: | ||
end | end | ||
if seconds > 0 then | if seconds > 0 then | ||
table.insert(output, string.format('% | table.insert(output, string.format('%.2f second%s', seconds, (seconds > 1) and "s" or "")) | ||
end | end | ||
return table.concat(output, ", ") | return table.concat(output, ", ") | ||
end | end |
edits