aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components/Converter/RemainingToText.py
diff options
context:
space:
mode:
authorMladen Horvat <acidburn@opendreambox.org>2008-12-10 09:53:18 +0100
committerMladen Horvat <acidburn@opendreambox.org>2008-12-10 09:53:18 +0100
commit9e9b0f5405807576512b9e9e5f6adeb87218822e (patch)
tree3654db66ac7e6414ce6cfef0123a34c1065ec3a5 /lib/python/Components/Converter/RemainingToText.py
parent35970b94b3b2df24f19d259fba04e23cfcf22e45 (diff)
parenta6976a2c3c6256a0c860827550aabd7ee9bdf3bf (diff)
downloadenigma2-9e9b0f5405807576512b9e9e5f6adeb87218822e.tar.gz
enigma2-9e9b0f5405807576512b9e9e5f6adeb87218822e.zip
Merge branch 'master' of git://git.opendreambox.org/git/enigma2
Diffstat (limited to 'lib/python/Components/Converter/RemainingToText.py')
-rw-r--r--lib/python/Components/Converter/RemainingToText.py34
1 files changed, 29 insertions, 5 deletions
diff --git a/lib/python/Components/Converter/RemainingToText.py b/lib/python/Components/Converter/RemainingToText.py
index adefe9cf..4249e30a 100644
--- a/lib/python/Components/Converter/RemainingToText.py
+++ b/lib/python/Components/Converter/RemainingToText.py
@@ -2,19 +2,43 @@ from Components.Converter.Converter import Converter
from Components.Element import cached
class RemainingToText(Converter, object):
+ DEFAULT = 0
+ WITH_SECONDS = 1
+ NO_SECONDS = 2
+
def __init__(self, type):
Converter.__init__(self, type)
+ if type == "WithSeconds":
+ self.type = self.WITH_SECONDS
+ elif type == "NoSeconds":
+ self.type = self.NO_SECONDS
+ else:
+ self.type = self.DEFAULT
@cached
def getText(self):
- r = self.source.time
- if r is None:
+ time = self.source.time
+ if time is None:
return ""
(duration, remaining) = self.source.time
- if remaining is not None:
- return "+%d min" % (remaining / 60)
+
+ if self.type == self.WITH_SECONDS:
+ if remaining is not None:
+ return "%d:%02d:%02d" % (remaining / 3600, (remaining / 60) - ((remaining / 3600) * 60), remaining % 60)
+ else:
+ return "%02d:%02d:%02d" % (duration / 3600, (duration / 60) - ((duration / 3600) * 60), duration % 60)
+ elif self.type == self.NO_SECONDS:
+ if remaining is not None:
+ return "+%d:%02d" % (remaining / 3600, (remaining / 60) - ((remaining / 3600) * 60))
+ else:
+ return "%02d:%02d" % (duration / 3600, (duration / 60) - ((duration / 3600) * 60))
+ elif self.type == self.DEFAULT:
+ if remaining is not None:
+ return "+%d min" % (remaining / 60)
+ else:
+ return "%d min" % (duration / 60)
else:
- return "%d min" % (duration / 60)
+ return "???"
text = property(getText)