Report post

Are you sure you want to report the post shown below? This will send an email to the ATVO administrators. Please include a short reason for reporting.

Users reporting for no reason may be locked out.


Post

Posted by Toni R
on
Dwayne Prins wrote:
Simon Grossmann wrote:
This is what we use internally for custom themes to convert gaps:
internal static string ConvertToTimeString(this float seconds, string secFormat = "0.000", bool withMinutes = true, string prefix = "", string def = "")
{
    if (seconds <= 0)
        return def;

    var min = 0;
    float sectime;
    if (withMinutes)
    {
        min = (int) (seconds / 60);
        sectime = seconds % 60;
    }
    else
    {
        sectime = seconds;
    }

    var sb = new StringBuilder(prefix);
    if (min > 0)
        sb.Append(min).Append(':').Append(sectime.ToString("0" + secFormat));
    else
        sb.Append(sectime.ToString(secFormat));

    return sb.ToString().Replace(',', '.');
}

This is the exact same issue I ran into with the seconds on the same lap. Thank you Simon for this snippet of code. After some tweaks I got this working with the script shown above. Thank you for "guiding" me in some way :)

If somebody is interested, this is the part I changed:
From this:
// If the car is in the same lap just return the time
return "+" + interval.ToString("0.000");

To this:
// If the car is in the same lap just return the time
// If the car is in same lap but over a minute behind, convert total seconds to proper format
var min = 0;
float sectime;
if (interval > 60)
{
min = (int) (interval / 60);
        sectime = interval % 60;
        return "+" + min + ":" + sectime.ToString("00.000");
}
else
return "+" + interval.ToString("0.000");


But in this code "interval" is not defined, doesn't work