1 from Components.Converter.Converter import Converter
2 from Components.Element import cached
4 class RemainingToText(Converter, object):
10 def __init__(self, type):
11 Converter.__init__(self, type)
12 if type == "WithSeconds":
13 self.type = self.WITH_SECONDS
14 elif type == "NoSeconds":
15 self.type = self.NO_SECONDS
16 elif type == "InSeconds":
17 self.type = self.IN_SECONDS
19 self.type = self.DEFAULT
23 time = self.source.time
27 (duration, remaining) = self.source.time
29 if self.type == self.WITH_SECONDS:
30 if remaining is not None:
31 return "%d:%02d:%02d" % (remaining / 3600, (remaining / 60) - ((remaining / 3600) * 60), remaining % 60)
33 return "%02d:%02d:%02d" % (duration / 3600, (duration / 60) - ((duration / 3600) * 60), duration % 60)
34 elif self.type == self.NO_SECONDS:
35 if remaining is not None:
36 return "+%d:%02d" % (remaining / 3600, (remaining / 60) - ((remaining / 3600) * 60))
38 return "%02d:%02d" % (duration / 3600, (duration / 60) - ((duration / 3600) * 60))
39 elif self.type == self.IN_SECONDS:
40 if remaining is not None:
44 elif self.type == self.DEFAULT:
45 if remaining is not None:
46 return "+%d min" % (remaining / 60)
48 return "%d min" % (duration / 60)
52 text = property(getText)