Results 1 to 5 of 5

Thread: Date and Time Object - wrong date being reflected for all videos on 31 Jan

  1. #1
    Potential Tuner
    Join Date
    Mar 2024
    Posts
    2

    Date and Time Object - wrong date being reflected for all videos on 31 Jan

    Hi all

    I am using the Date and Time object and whilst it works fine for most dates, it looks like all videos with 31 Jan 2023 are coming up as 3 Mar 2023. It looks like the logic to calculate the epoch date is wrong. Would anyone be able to help me out as I cannot figure out what is wrong with the code?

    I am sure the GoPro data is correct as the Raw epoch data are:

    1675151208
    1675151210
    1675151211
    1675151211

    // Convert UTC timestamp to number of seconds since the base epoch time, in the desired timezone
    SecondsElapsed = (DataValue + TimeZoneShift) - BaseEpochSeconds;
    if(SecondsElapsed < 0)
    SecondsElapsed = 0; // Don't go before Jan 1 of our base epoch year

    if(ShowDate)
    {
    DaysElapsed = floor(SecondsElapsed / DaySeconds);

    YearsElapsedX4 = floor(DaysElapsed / DaysPerYearX4);
    DaysRemainingX4 = DaysElapsed - (YearsElapsedX4 * DaysPerYearX4);

    YearsElapsed = YearsElapsedX4 * 4;

    if(DaysRemainingX4 >= DaysPerLeapYear)
    {
    // Account for days in the leap year
    YearsElapsed += 1;
    DaysRemainingX4 -= DaysPerLeapYear;
    }

    // Account for days in the non-leap years
    AddYears = floor(DaysRemainingX4 / DaysPerYear);
    YearsElapsed += AddYears;
    DaysRemainingX4 -= AddYears * DaysPerYear;

    // Actual year and number of days into the year
    Year = BaseEpochYear + YearsElapsed;
    JulianDate = DaysRemainingX4 + 1;
    IsLeapYear = ((Year % 4) == 0);

    // Convert Julian Date into Month and Day
    Month = 1;
    MonthName = "January";
    Day = JulianDate;

    // After January
    if(Day > 31)
    {
    Month += 1;
    MonthName = "February";
    Day -= 31;
    }

    // After February
    if(IsLeapYear)
    {
    if(Day > 29)
    {
    Month += 1;
    MonthName = "March";
    Day -= 29;
    }
    }
    else
    {
    if(Day > 28)
    {
    Month += 1;
    MonthName = "March";
    Day -= 28;
    }
    }

    // After March
    if(Day > 31)
    {
    Month += 1;
    MonthName = "April";
    Day -= 31;
    }

    // After April
    if(Day > 30)
    {
    Month += 1;
    MonthName = "May";
    Day -= 30;
    }

    // After May
    if(Day > 31)
    {
    Month += 1;
    MonthName = "June";
    Day -= 31;
    }

    // After June
    if(Day > 30)
    {
    Month += 1;
    MonthName = "July";
    Day -= 30;
    }

    // After July
    if(Day > 31)
    {
    Month += 1;
    MonthName = "August";
    Day -= 31;
    }

    // After August
    if(Day > 31)
    {
    Month += 1;
    MonthName = "September";
    Day -= 31;
    }

    // After September
    if(Day > 30)
    {
    Month += 1;
    MonthName = "October";
    Day -= 30;
    }

    // After October
    if(Day > 31)
    {
    Month += 1;
    MonthName = "November";
    Day -= 31;
    }

    // After November
    if(Day > 30)
    {
    Month += 1;
    MonthName = "December";
    Day -= 30;
    }

    if(ShowDateISO)
    {
    // Format date as "YYYY-MM-DD"

    MonthString = FormatNumber(Month, 0);
    if(Month < 10)
    MonthString = "0" + MonthString;

    DayString = FormatNumber(Day, 0);
    if(Day < 10)
    DayString = "0" + DayString;

    DateString = FormatNumber(Year, 0) + "-" + MonthString + "-" + DayString;
    }
    else // !ShowDateISO
    DateString = SubStr(MonthName, 0, 3) + " " + FormatNumber(Day, 0) + ", " + FormatNumber(Year, 0);
    }
    else // !ShowDate
    DateString = "";

  2. #2
    Advanced Tuner
    Join Date
    Apr 2018
    Posts
    304
    Try using the "_Timer - Date and Time - Updated.rro" display object mentioned in this post: https://forum.hptuners.com/showthrea...l=1#post608727

    I think I had found that the date logic would still try to act on the day even after the correct month had been found; so I added some additional logic to essentially stop looking at the next month once we had found the correct month.

  3. #3
    Potential Tuner
    Join Date
    Mar 2024
    Posts
    2
    Thank you very much, HoboBob! It looks to display the right date now.

  4. #4
    Potential Tuner
    Join Date
    Jun 2024
    Posts
    2
    OK, this looks like exactly the fix I need for correcting a TrackAddict file with a 5/31 date. (Which is displaying as 7/1.)

    I've downloaded the update time and date .rro file from the linked thread.

    But now I am completely stumped as to what do with this new .rro file. The only thread I can find on where to put it seems outdated as that location no longer exists. I've googled around for anything mentioning using a new .rro file, and while I'm finding several examples of provided files, I'm not finding any instructions on how to use them.

    Is there a guide somewhere someone can point me to please?

  5. #5
    Potential Tuner
    Join Date
    Jun 2024
    Posts
    2
    Quote Originally Posted by greggersch View Post
    Is there a guide somewhere someone can point me to please?
    DOH! OK, it finally sunk in which 'Documents' folder some of the references were talking about. I was looking for something related to the actual program location, or the ProgramData folder where things like this usually reside. No, it's talking about your actual default User Documents folder. Never noticed as I never use that folder.

    And if look at the Display Object Properties for the time field you want updated, in the 'Style' drop down box, you can then select the new '_Timer - Date and Time - Updated' style.