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 = "";