Module:Ticks: Difference between revisions

No edit summary
No edit summary
Line 7: Line 7:


     local timeDisplay
     local timeDisplay
    local minutes = seconds / 60


     -- Check for whole minute or half-minute
     if seconds >= 120 then
    local minutes = seconds / 60
        if minutes == math.floor(minutes) then
    if minutes == math.floor(minutes) then
            timeDisplay = string.format('<abbr title="Time in minutes">%.0fm</abbr>', minutes)
        timeDisplay = string.format('<abbr title="Time in minutes">%.0fm</abbr>', minutes)
        elseif (minutes * 10) % 5 == 0 then  -- divisible by 0.5
    elseif (minutes * 10) % 5 == 0 then  -- divisible by 0.5
            timeDisplay = string.format('<abbr title="Time in minutes">%.1fm</abbr>', minutes)
        timeDisplay = string.format('<abbr title="Time in minutes">%.1fm</abbr>', minutes)
        end
     else
     end
 
    if not timeDisplay then
         -- Fall back to seconds with 1 decimal place, strip .0 if present
         -- Fall back to seconds with 1 decimal place, strip .0 if present
         local secondsFormatted = string.format("%.1f", seconds):gsub("%.0$", "")
         local secondsFormatted = string.format("%.1f", seconds):gsub("%.0$", "")