1 from Screen import Screen
2 from Components.config import *
3 from Components.ActionMap import ActionMap, NumberActionMap
4 from Components.ConfigList import ConfigList, ConfigListScreen
5 from Components.Button import Button
6 from Components.Label import Label
7 from Components.Pixmap import Pixmap
11 class TimeDateInput(Screen, ConfigListScreen):
12 def __init__(self, session):
13 Screen.__init__(self, session)
15 self["oktext"] = Label(_("OK"))
16 self["canceltext"] = Label(_("Cancel"))
18 self["cancel"] = Pixmap()
22 self["actions"] = NumberActionMap(["SetupActions"],
26 "cancel": self.keyCancel,
30 ConfigListScreen.__init__(self, self.list)
31 self.createSetup(self["config"])
33 def createConfig(self):
35 self.timeinput_date = ConfigDateTime(default = nowtime, formatstring = (_("%d.%B %Y"), 86400))
36 self.timeinput_time = ConfigClock(default = nowtime)
40 def createSetup(self, configlist):
42 self.list.append(getConfigListEntry(_("Date"), config.timeinput.date))
43 self.list.append(getConfigListEntry(_("Time"), config.timeinput.time))
44 configlist.list = self.list
45 configlist.l.setList(self.list)
47 def keyRightCallback(self, configPath):
48 currentConfigPath = self["config"].getCurrent()[1].parent.getConfigPath()
49 # check if we are still on the same config entry
50 if (currentConfigPath == configPath):
56 def getTimestamp(self, date, mytime):
57 d = time.localtime(date)
58 dt = datetime.datetime(d.tm_year, d.tm_mon, d.tm_mday, mytime[0], mytime[1])
59 return int(mktime(dt.timetuple()))
62 time = self.getTimestamp(config.timeinput.date.value, config.timeinput.time.value)
63 self.close((True, time))