Actually I made a small function for this when helping a guy in another thread:
pawn Код:
stock ConvertToDaysAndHours(days = 0, hours = 0, minutes = 0, seconds = 0)
{
while(seconds >= 60) minutes++, seconds -= 60;
while(minutes >= 60) hours++, minutes -= 60;
while(hours >= 24) days++, hours -= 24;
new string[55], fstr[20];
if(days) format(fstr, sizeof(fstr), (hours || minutes || seconds) ? ("%d days, ") : ("%d days"), days), strins(string, fstr, 0);
if(hours) format(fstr, sizeof(fstr), (minutes || seconds) ? ("%d hours, ") : ("%d hours"), hours), strins(string, fstr, strlen(string));
if(minutes) format(fstr, sizeof(fstr), (seconds) ? ("%d minutes, ") : ("%d minutes"), minutes), strins(string, fstr, strlen(string));
if(seconds) format(fstr, sizeof(fstr), "%d seconds", seconds), strins(string, fstr, strlen(string));
return string;
}
Example of it's usage:
If you wanted 5 days, 49 hours, 17 minutes and 14 seconds:
pawn Код:
ConvertToDaysAndHours(.days = 4, .hours = 49, .minutes = 17, .seconds = 14);
//Outcome: 7 days, 1 hour, 17 minutes, 14 seconds
If you wanted 3 days, 3 hours and 18 minutes:
pawn Код:
ConvertToDaysAndHours(.days = 3, .hours = 3, .minutes = 18);
//Outcome: 3 days, 3 hours, 18 minutes