add homeys TVCharts plugin
[vuplus_dvbapp-plugin] / kiddytimer / src / KTglob.py
1 from __init__ import _
2 from Components.config import config
3 import time
4
5 PLUGIN_BASE = "KiddyTimer"
6 PLUGIN_VERSION = "1.0d"
7
8 DAYNAMES= (_("Sunday"),
9           _("Monday"),
10           _("Tuesday"),
11           _("Wednesday"),
12           _("Thursday"),
13           _("Friday"),
14           _("Saturday"),
15           )
16
17 ONEHOUR=3600
18 ONEMINUTE=60
19
20 MOVEPOSITIONSTEP = 10
21
22
23 #This is a hack to get the times in the current timezone to feed as default value for the ConfigClock
24 ONEOCLOCK=time.mktime([2000,1,1,1,0,0,5,1,time.timezone])
25 FOUROCLOCK=time.mktime([2000,1,1,4,0,0,5,1,time.timezone])
26 EIGHTOCLOCK=time.mktime([2000,1,1,8,0,0,5,1,time.timezone])
27 EIGHTOCLOCKNOON=time.mktime([2000,1,1,20,0,0,5,1,time.timezone])
28
29 plugin_path = ""
30
31 ##############################################################################
32
33 SKIN = """
34     <screen flags="wfNoBorder" position="0,0" size="82,104" title="Kiddy Timer" backgroundColor="#ff000000">
35         <ePixmap pixmap="~/img/Smiley-Background.png" position="0,0" zPosition="1" size="82,82" alphatest="blend" transparent="1"/>
36         <widget name="TimerSlider" pixmap="~/img/Smiley-Slider.png" zPosition="4" position="0,0" size="82,82" transparent="1" orientation="orBottomToTop" />
37         <widget name="TimerSliderText" zPosition="5" position="0,83" size="82,21" font="Regular;18" halign="center" valign="center" foregroundColor="#000000" backgroundColor="#aaffffff" />
38         <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="2" size="82,82" transparent="1" alphatest="on" />
39         <widget name="TimerText" zPosition="3" position="0,30" size="82,21" font="Regular;18" halign="center" valign="center" foregroundColor="#000000" transparent = "1" />
40     </screen>"""
41
42 ##############################################################################
43
44 def getTodaysTimeInSeconds():
45     # Number of the current day
46     dayNr = int(time.strftime("%w" , time.localtime() ))
47     # Number of seconds for the current day
48     iDayTime = getSecondsFromClock( config.plugins.KiddyTimer.dayTimes[dayNr].timeValue.value )
49     return(iDayTime)
50
51 def getSecondsFromClock(aClock):
52     iSeconds = 60*(int(aClock[0])*60 + int(aClock[1]))
53     return iSeconds
54
55 def getTimeFromSeconds(iSecondsLeft,bReturnSeconds):
56         iHours = int( iSecondsLeft // 3600 )
57         iHourRest = iSecondsLeft - ( iHours * 3600 )
58         iMinutes = int( iHourRest // 60 )
59         if bReturnSeconds == False:
60             return( ("00"+str(iHours))[-2:] + ":" + ("00"+str(iMinutes))[-2:] )
61         else:
62             iSeconds = int( iHourRest - ( iMinutes * 60) )
63             return( ("00"+str(iHours))[-2:] + ":" + ("00"+str(iMinutes))[-2:] + ":" + ("00"+str(iSeconds))[-2:] )
64
65