Quote:
Originally Posted by Bugsy
I guess I do not fully understand what you are trying to do. Can you explain a real world example?
|
Of course, I've just finished my idea, it needs some refinement, but it's already serving the purpose.
PHP Code:
public CalculateStrings()
{
new Time[15], ToDay[5], Month[5]
get_time("%A", Time, charsmax(Time))
new EventDay = 7 - CalculateDays(Time)
get_time("%d", ToDay, charsmax(ToDay))
new iFutureDate = str_to_num(ToDay) + EventDay
get_time("%m", Month, charsmax(Month))
new FormatedFutureDate[30]
formatex(FormatedFutureDate, charsmax(FormatedFutureDate), "19:00:00 %i/%i/2021", str_to_num(Month), iFutureDate)
new iFutureDateTime = parse_time( FormatedFutureDate , "%H:%M:%S %m/%d/%Y" );
new iCurrentDateTime = get_systime();
Counter = iFutureDateTime - iCurrentDateTime;
set_task_ex(1.0, "TimeToEvent", TASK_HUD_DROP, .flags = SetTask_Repeat)
}
convert_seconds( iTotalSeconds , &seconds , &minutes , &hours , &days )
{
days = iTotalSeconds / 86400
hours = ( iTotalSeconds / 3600 ) % 24
minutes = ( iTotalSeconds / 60 ) % 60
seconds = iTotalSeconds % 60
}
CalculateDays(const szDay[])
{
new Count = 0
enum _:ItemData
{
szDays[10],
iCount
}
new const g_szDays[][ItemData] =
{
{"Sunday", 1},
{"Monday", 2},
{"Tuesday", 3},
{"Wednesday", 4},
{"Thursday", 5},
{"Friday", 6},
{"Saturday", 7}
}
for(new i; i < sizeof g_szDays; i++)
{
if(equali(szDay, g_szDays[i][szDays]))
{
Count = g_szDays[i][iCount]
break
}
}
return Count
}
__________________