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 getConfigListEntry(_("Date"), self.timeinput_date),
47 getConfigListEntry(_("Time"), self.timeinput_time)
49 configlist.list = self.list
50 configlist.l.setList(self.list)
55 def getTimestamp(self, date, mytime):
56 d = time.localtime(date)
57 dt = datetime.datetime(d.tm_year, d.tm_mon, d.tm_mday, mytime[0], mytime[1])
58 return int(time.mktime(dt.timetuple()))
61 time = self.getTimestamp(self.timeinput_date.value, self.timeinput_time.value)
62 if self.save_mask & 1:
63 self.timeinput_time.save()
64 if self.save_mask & 2:
65 self.timeinput_date.save()
66 self.close((True, time))
69 if self.save_mask & 1:
70 self.timeinput_time.cancel()
71 if self.save_mask & 2:
72 self.timeinput_date.cancel()