linux-dreambox-3.2: fix sha256sum after 'push to 3.2.54'
[opendreambox.git] / meta-opendreambox / recipes-dreambox / enigma2 / enigma2-3.999git20131118 / 0006-added-manual-day-month-translation-to-clocktotext-co.patch
1 From 757496066d9c9e3b0ef3082626578511e1ac724c Mon Sep 17 00:00:00 2001
2 From: ghost <andreas.monzner@dream-property.net>
3 Date: Mon, 9 Dec 2013 22:42:13 +0100
4 Subject: [PATCH 6/7] added manual day/month translation to clocktotext
5  converter (patch from merlin / dr.best)
6
7 ---
8  usr/lib/enigma2/python/Components/Converter/ClockToText.py |   33 +++++++++++++++++++++---
9  1 file changed, 30 insertions(+), 3 deletions(-)
10
11 diff --git a/usr/lib/enigma2/python/Components/Converter/ClockToText.py b/usr/lib/enigma2/python/Components/Converter/ClockToText.py
12 index 8ef9874..ca6a2ee 100644
13 --- a/usr/lib/enigma2/python/Components/Converter/ClockToText.py
14 +++ b/usr/lib/enigma2/python/Components/Converter/ClockToText.py
15 @@ -31,6 +31,10 @@ class ClockToText(Converter, object):
16                         self.fmt_string = type[7:]
17                 else:
18                         self.type = self.DEFAULT
19 +               self.short_day = { "Mon": _("Mon"), "Tue": _("Tue"), "Wed": _("Wed"), "Thu": _("Thu"), "Fri": _("Fri"), "Sat": _("Sat"), "Sun": _("Sun") }
20 +               self.full_day = { "Monday": _("Monday"), "Tuesday": _("Tuesday"), "Wednesday": _("Wednesday"), "Thursday": _("Thursday"), "Friday": _("Friday"), "Saturday": _("Saturday"), "Sunday": _("Sunday") }
21 +               self.short_month = { "Jan": _("Jan"), "Feb": _("Feb"), "Mar": _("Mar"), "Apr": _("Apr"), "May": _("May"), "Jun": _("Jun"), "Jul": _("Jul"), "Aug": _("Aug"), "Sep": _("Sep"), "Oct": _("Oct"), "Nov": _("Nov"), "Dec": _("Dec") }
22 +               self.full_month = { "January": _("January"), "February": _("February"), "March": _("March"), "April": _("April"), "May": _("May"), "June": _("June"), "July": _("July"), "August": _("August"), "September": _("September"), "October": _("October"), "November": _("November"), "December": _("December") }
23  
24         @cached
25         def getText(self):
26 @@ -53,16 +57,39 @@ class ClockToText(Converter, object):
27                 elif self.type == self.DEFAULT:
28                         return "%02d:%02d" % (t.tm_hour, t.tm_min)
29                 elif self.type == self.DATE:
30 -                       return strftime("%A %B %d, %Y", t)
31 +                       line = strftime("%A %B")
32 +                       line = line.split(" ")
33 +                       fDay = self.full_day[line[0]]
34 +                       fMonth = self.full_month[line[1]]
35 +                       return "%s %s %s" % (fDay, fMonth, strftime("%d, %Y", t))
36 +
37                 elif self.type == self.FORMAT:
38                         spos = self.fmt_string.find('%')
39                         if spos > 0:
40                                 s1 = self.fmt_string[:spos]
41                                 s2 = strftime(self.fmt_string[spos:], t)
42 -                               return str(s1+s2)
43 +                               shortDay = self.fmt_string.find('%a')
44 +                               fullDay = self.fmt_string.find('%A')
45 +                               shortMonth = self.fmt_string.find('%b')
46 +                               fullMonth = self.fmt_string.find('%B')
47 +                               line = str(s1+s2)
48 +                               if shortDay > -1:
49 +                                       replaces = self.short_day
50 +                                       # http://stackoverflow.com/questions/6116978/python-replace-multiple-strings
51 +                                       line = reduce(lambda inline, outline: inline.replace(*outline), replaces.iteritems(), line)
52 +                               if fullDay > -1:
53 +                                       replaces = self.full_day
54 +                                       line = reduce(lambda inline, outline: inline.replace(*outline), replaces.iteritems(), line)
55 +                               if shortMonth > -1:
56 +                                       replaces = self.short_month
57 +                                       line = reduce(lambda inline, outline: inline.replace(*outline), replaces.iteritems(), line)
58 +                               if fullMonth > -1:
59 +                                       replaces = self.full_month
60 +                                       line = reduce(lambda inline, outline: inline.replace(*outline), replaces.iteritems(), line)
61 +                               return line
62                         else:
63                                 return strftime(self.fmt_string, t)
64 -               
65 +
66                 else:
67                         return "???"
68  
69 -- 
70 1.7.10.4
71