1 from Components.Converter.Converter import Converter
2 from time import localtime
4 class ClockToText(Converter, object):
9 # add: date, date as string, weekday, ...
10 # (whatever you need!)
12 def __init__(self, type, *args, **kwargs):
13 Converter.__init__(self)
14 if type == "WithSeconds":
15 self.type = self.WITH_SECONDS
16 elif type == "InMinutes":
17 self.type = self.IN_MINUTES
19 self.type = self.DEFAULT
22 time = self.source.time
27 if self.type == self.IN_MINUTES:
28 return "%d min" % (time / 60)
32 if self.type == self.WITH_SECONDS:
33 return "%2d:%02d:%02d" % (t.tm_hour, t.tm_min, t.tm_sec)
34 elif self.type == self.DEFAULT:
35 return "%02d:%02d" % (t.tm_hour, t.tm_min)
39 text = property(getText)