1 from Screen import Screen
2 from Components.config import ConfigClock, ConfigDateTime, getConfigListEntry
3 from Components.ActionMap import NumberActionMap
4 from Components.ConfigList import ConfigListScreen
5 from Components.Label import Label
6 from Components.Pixmap import Pixmap
10 class TimeDateInput(Screen, ConfigListScreen):
11 def __init__(self, session, config_time=None, config_date=None):
12 Screen.__init__(self, session)
13 self["oktext"] = Label(_("OK"))
14 self["canceltext"] = Label(_("Cancel"))
16 self["cancel"] = Pixmap()
18 self.createConfig(config_date, config_time)
20 self["actions"] = NumberActionMap(["SetupActions"],
24 "cancel": self.keyCancel,
28 ConfigListScreen.__init__(self, self.list)
29 self.createSetup(self["config"])
31 def createConfig(self, conf_date, conf_time):
36 conf_time = ConfigClock(default = time.time()),
40 conf_date = ConfigDateTime(default = time.time(), formatstring = _("%d.%B %Y"), increment = 86400)
41 self.timeinput_date = conf_date
42 self.timeinput_time = conf_time
44 def createSetup(self, configlist):
46 self.list.append(getConfigListEntry(_("Date"), self.timeinput_date))
47 self.list.append(getConfigListEntry(_("Time"), self.timeinput_time))
48 configlist.list = self.list
49 configlist.l.setList(self.list)
54 def getTimestamp(self, date, mytime):
55 d = time.localtime(date)
56 dt = datetime.datetime(d.tm_year, d.tm_mon, d.tm_mday, mytime[0], mytime[1])
57 return int(time.mktime(dt.timetuple()))
60 time = self.getTimestamp(self.timeinput_date.value, self.timeinput_time.value)
61 if self.save_mask & 1:
62 self.timeinput_time.save()
63 if self.save_mask & 2:
64 self.timeinput_date.save()
65 self.close((True, time))
68 if self.save_mask & 1:
69 self.timeinput_time.cancel()
70 if self.save_mask & 2:
71 self.timeinput_date.cancel()