--These function should NOT be used
--by other packages.

--Helper function
function p.make_2_digit(x)
    if( x < 10 ) then return "0" .. tostring(x) end
    return x
end

--Helper function
function p.make_3_digit(x)
    if( x < 10 ) then return "00" .. tostring(x) end
    if( x < 100 ) then return "0" .. tostring(x) end
    return x
end

--Helper function.
--Takes an integer and returns a string with commas.
function p.add_commas(num)
    local ones_rem = math.floor(num) % 1000
    local thousands = math.floor( (num - ones_rem) / 1000 )
    if( thousands == 0 ) then return tostring(num) end
    return tostring(thousands) .. "," .. p.make_3_digit(ones_rem)
end

--Helper function
function p.time_str(time_f)
    local seconds_total = math.floor(time_f)
    local seconds = math.floor( math.fmod(seconds_total, 60.0) )
    local minutes_total = math.floor( (seconds_total - seconds) / 60.0 )
    local minutes = math.floor( math.fmod(minutes_total, 60.0) )
    local hours_total = math.floor( (minutes_total - minutes) / 60.0 )
    return base_local_str.make_3_digit(hours_total) .. ":"
        .. base_local_str.make_2_digit(minutes) .. ":"
        .. base_local_str.make_2_digit(seconds)
end
