21.06.2008, 11:21
ToTimestamp
Converts years, weeks, etc into a timestamp.
FromTimestamp
Converts a timestamp into years, weeks, etc.
Converts years, weeks, etc into a timestamp.
pawn Код:
stock ToTimestamp(f_years,f_weeks,f_days,f_hours,f_minutes,f_seconds)
{
return
f_seconds +
(f_minutes * 60) +
(f_hours * 60 * 60) +
(f_days * 60 * 60 * 24) +
(f_weeks * 60 * 60 * 24 * 7) +
(f_years * 60 * 60 * 24 * 7 * 365);
}
Converts a timestamp into years, weeks, etc.
pawn Код:
stock FromTimestamp(f_timestamp,&f_years,&f_weeks,&f_days,&f_hours,&f_minutes,&f_seconds)
{
f_years = floatround(f_timestamp / (60 * 60 * 24 * 365),floatround_floor);
f_timestamp %= 60 * 60 * 24 * 365;
f_weeks = floatround(f_timestamp / (60 * 60 * 24 * 7),floatround_floor);
f_timestamp %= 60 * 60 * 24 * 7;
f_days = floatround(f_timestamp / (60 * 60 * 24),floatround_floor);
f_timestamp %= 60 * 60 * 24;
f_hours = floatround(f_timestamp / (60 * 60),floatround_floor);
f_timestamp %= 60 * 60;
f_minutes = floatround(f_timestamp / 60,floatround_floor);
f_seconds = f_timestamp % 60;
}