[PYTHON] TIME FORMAT (PLAY TIME) SELECT CHARACTER

01/23/2016 20:44 Exygo#1
Preview:

[Only registered and activated users can see links. Click Here To Register...][Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...][Only registered and activated users can see links. Click Here To Register...]

Cod:

Code:
	#Exygo's function
	def timp_frumos(self, minute):
		#import math # modulul math se presupune a fi deja importat sus
		self.ore = minute / 60
		if minute  <= 60:
			return uiScriptLocale.EXYGO_TIME_FORMAT_MINUTE % (minute)
		else:
			if self.ore <= 24:
				return uiScriptLocale.EXYGO_TIME_FORMAT_HOURS_AND_MINUTES % (self.ore, minute - 60 * self.ore) # Ingeniozitate maa!
			else:
				self.zile = self.ore / 24
				return uiScriptLocale.EXYGO_TIME_FORMAT_DAYS_AND_HOURS % (self.zile, self.ore - 24 * self.zile) # Ingeniozitate maa!
Code:
self.PlayTime.SetText(self.timp_frumos(playTime))
And the part for locale_xx/locale_interface.txt

Code:
EXYGO_TIME_FORMAT_MINUTE	%s minute(s)
EXYGO_TIME_FORMAT_HOURS_AND_MINUTES	%s hour(s) and %s minute(s)
EXYGO_TIME_FORMAT_DAYS_AND_HOURS	%s day(s) and %s hour(s)
Install this youself! No guide for noobs yet!

Hint: introselect.py

* This little part of code was wrote by Exygo(me)
01/24/2016 23:59 Noa_#2
is that the same?
PHP Code:
self.PlayTime.SetText(self.SecondToDHM(playTime*60)) 
01/25/2016 12:39 .UNLTD.#3
Wo muss das alles hin? xDDDDDD
01/25/2016 20:45 Noa_#4
SecondToDHM work only with seconds, so convert minutes to seconds multiplied by 60
01/26/2016 09:32 .Various#5
Well, thanks, but the calculations goes much easier.
e.g use divmod(x, y). This method returns a tuple (a // b, a % b)

Code:
        s, m = divmod(m, 60)
        d, s = divmod(s, 24)
        print("%dDays %02dHours %02dMinutes" % (d, s, m))
Best regards, .Various