Added new Plugin KiddyTimer
[enigma2-plugins.git] / kiddytimer / src / KTglob.py
1 import time
2
3 PLUGIN_BASE = "KiddyTimer"
4 PLUGIN_VERSION = "0.3"
5
6 DAYNAMES= (_("Sunday"),
7           _("Monday"),
8           _("Tuesday"),
9           _("Wednesday"),
10           _("Thursday"),
11           _("Friday"),
12           _("Saturday"),
13           )
14
15 ONEHOUR=3600
16 ONEMINUTE=60
17
18 MOVEPOSITIONSTEP = 10
19
20
21 #This is a hack to get the times in the current timezone to feed as default value for the ConfigClock
22 ONEOCLOCK=time.mktime([2000,1,1,1,0,0,5,1,time.timezone])
23 EIGHTOCLOCK=time.mktime([2000,1,1,8,0,0,5,1,time.timezone])
24 EIGHTOCLOCKNOON=time.mktime([2000,1,1,20,0,0,5,1,time.timezone])
25
26 oKiddyTimer = None
27 plugin_path = ""
28
29 ##############################################################################
30
31 SKIN = """
32     <screen flags="wfNoBorder" position="0,0" size="82,82" title="Kiddy Timer" backgroundColor="#ff000000">
33         <widget name="TimerGraph" pixmaps="~/img/Timer1000.png,~/img/Timer0950.png,~/img/Timer0900.png,~/img/Timer0850.png,~/img/Timer0800.png,~/img/Timer0750.png,~/img/Timer0700.png,~/img/Timer0650.png,~/img/Timer0600.png,~/img/Timer0550.png,~/img/Timer0500.png,~/img/Timer0450.png,~/img/Timer0400.png,~/img/Timer0350.png,~/img/Timer0300.png,~/img/Timer0250.png,~/img/Timer0200.png,~/img/Timer0150.png,~/img/Timer0100.png,~/img/Timer0050.png,~/img/Timer0000.png" position="0,0" zPosition="1" size="130,130" transparent="1" alphatest="on" />
34         <widget name="TimerText" zPosition="2" position="0,30" size="82,21" font="Regular;18" halign="center" valign="center" foregroundColor="#000000" transparent = "1" />
35     </screen>"""
36
37 ##############################################################################
38
39 def getSecondsFromClock(aClock):
40     iSeconds = 60*(int(aClock[0])*60 + int(aClock[1]))
41     return iSeconds
42
43 def getTimeFromSeconds(iSecondsLeft,bReturnSeconds):
44         iHours = int( iSecondsLeft // 3600 )
45         iHourRest = iSecondsLeft - ( iHours * 3600 )
46         iMinutes = int( iHourRest // 60 )
47         if bReturnSeconds == False:
48             return( ("00"+str(iHours))[-2:] + ":" + ("00"+str(iMinutes))[-2:] )
49         else:
50             iSeconds = int( iHourRest - ( iMinutes * 60) )
51             return( ("00"+str(iHours))[-2:] + ":" + ("00"+str(iMinutes))[-2:] + ":" + ("00"+str(iSeconds))[-2:] )
52
53