if (str_to_num(hours_time))
- Код: Выделить всё
Get_Time(hours_time[], len) // cod "Exolent" fix "Egor1496"
{
new arrm_month[] = {31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}
static _hours[5], _minutes[5], _seconds[5], _month[5], _day[5], _year[7];
format_time(_hours, sizeof(_hours) - 1, "%H");
format_time(_minutes, sizeof(_minutes) - 1, "%M");
format_time(_seconds, sizeof(_seconds) - 1, "%S");
format_time(_month, sizeof(_month) - 1, "%m");
format_time(_day, sizeof(_day) - 1, "%d");
format_time(_year, sizeof(_year) - 1, "%Y");
new hours = str_to_num(_hours);
new minutes = str_to_num(_minutes);
//new seconds = str_to_num(_seconds);
new month = str_to_num(_month);
new day = str_to_num(_day);
new year = str_to_num(_year);
day_hourse = day * 24
month_hourse = arrm_month[month - 1] * 24
year_hourse = year * 365 * 24
formatex(hours_time, len, "%i", year_hourse + month_hourse + day_hourse);
hours += minutes / 60
minutes = minutes % 60
day += hours / 24
hours = hours % 24
new max_days = GetDaysInMonth(month, year);
month += day / max_days
day = day % max_days
year += month / 12
month = month % 12
}
GetDaysInMonth(month, year=0)
{
switch( month )
{
case 1: return 31; // january
case 2: return ((year % 4) == 0) ? 29 : 28; // february
case 3: return 31; // march
case 4: return 30; // april
case 5: return 31; // may
case 6: return 30; // june
case 7: return 31; // july
case 8: return 31; // august
case 9: return 30; // september
case 10: return 31; // october
case 11: return 30; // november
case 12: return 31; // december
}
return 30;
}