I guess my brain just threw an out of memory exception and crashed,
My problem is I have a class member array of SYSTEMTIME
size 3 which is user defined (read from a .lua)
SYSTEMTIME m_MatchTime[3];
Then it's read this way from the file:
m_MatchTime[0].wDayOfWeek = static_cast<WORD>( m_Lua.GetGlobalNumber( "FirstDay" ) );
m_MatchTime[0].wHour = static_cast<WORD>( m_Lua.GetGlobalNumber( "FirstHour" ) );
m_MatchTime[0].wMinute = static_cast<WORD>( m_Lua.GetGlobalNumber( "FirstMinute" ) );
m_MatchTime[1].wDayOfWeek = static_cast<WORD>( m_Lua.GetGlobalNumber( "SecondDay" ) );
m_MatchTime[1].wHour = static_cast<WORD>( m_Lua.GetGlobalNumber( "SecondHour" ) );
m_MatchTime[1].wMinute = static_cast<WORD>( m_Lua.GetGlobalNumber( "SecondMinute" ) );
m_MatchTime[2].wDayOfWeek = static_cast<WORD>( m_Lua.GetGlobalNumber( "ThirdDay" ) );
m_MatchTime[2].wHour = static_cast<WORD>( m_Lua.GetGlobalNumber( "ThirdHour" ) );
m_MatchTime[2].wMinute = static_cast<WORD>( m_Lua.GetGlobalNumber( "ThirdMinute" ) );
now I have a method:
SYSTEMTIME cTime;
GetLocalTime( &cTime );
I must calculate which from the three user defined times is BEFORE and closer to the current time, then calculate the remaining time to it, (please notice that Sunday = 0, Saturday = 6, also note that only wDayOfWeek, wHour and wMinute must be compared to get to the closest )
Edit: Now I'm awarding 500bounty for a solution, please note the example of what I want,
Today: Day 4, Hour 3, Minute 0,
Date: Day 5, Hour 5, Minute 30
The remaining time until date is: 1 days, 2 hour and 30 minutes.