Time conversion
#5

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
I'm not sure. My Div Function is good, use it. It will return you how many times is b in a, without decimal places.
That is pretty much what the modulus operator does, which is native in Pawn. It returns the remainder of the division.

pawn Код:
new temp = time % (24 * 60);
new days = (time - temp) / (24 * 60);
new minutes = temp % 60;
new hours = (temp - minutes) / 60;
Say, 2000 minutes:
Код:
time 2000
temp = 2000 % 1440 = 560
days = (2000 - 560) / (24 * 60) = 1440 / 1440 = 1
minutes = 560 % 60 =  20
hours = (560 - 20) / 60 = 540 / 60 = 9
1 day, 9 hours, 20 minutes.

Do not change the order of the variables. That's important.
Reply


Messages In This Thread
Time conversion - by Luis- - 13.03.2013, 19:42
Re: Time conversion - by [MG]Dimi - 13.03.2013, 19:59
Re: Time conversion - by Luis- - 13.03.2013, 20:06
Re: Time conversion - by [MG]Dimi - 13.03.2013, 20:07
Re: Time conversion - by Vince - 13.03.2013, 21:01
Re: Time conversion - by Luis- - 13.03.2013, 21:08
Re: Time conversion - by Vince - 13.03.2013, 21:34

Forum Jump:


Users browsing this thread: 4 Guest(s)