1 from Components.Converter.Converter import Converter
2 from Components.Element import cached
4 class RemainingToText(Converter, object):
9 def __init__(self, type):
10 Converter.__init__(self, type)
11 if type == "WithSeconds":
12 self.type = self.WITH_SECONDS
13 elif type == "NoSeconds":
14 self.type = self.NO_SECONDS
16 self.type = self.DEFAULT
20 time = self.source.time
24 (duration, remaining) = self.source.time
26 if self.type == self.WITH_SECONDS:
27 if remaining is not None:
28 return "%d:%02d:%02d" % (remaining / 3600, (remaining / 60) - ((remaining / 3600) * 60), remaining % 60)
30 return "%02d:%02d:%02d" % (duration / 3600, (duration / 60) - ((duration / 3600) * 60), duration % 60)
31 elif self.type == self.NO_SECONDS:
32 if remaining is not None:
33 return "+%d:%02d" % (remaining / 3600, (remaining / 60) - ((remaining / 3600) * 60))
35 return "%02d:%02d" % (duration / 3600, (duration / 60) - ((duration / 3600) * 60))
36 elif self.type == self.DEFAULT:
37 if remaining is not None:
38 return "+%d min" % (remaining / 60)
40 return "%d min" % (duration / 60)
44 text = property(getText)