Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from Converter import Converter
- from time import localtime, strftime, mktime, time
- from Components.Element import cached
- from datetime import date, datetime
- MONTHS = (_('Январь'),
- _('February'),
- _('March'),
- _('April'),
- _('May'),
- _('June'),
- _('July'),
- _('August'),
- _('September'),
- _('October'),
- _('November'),
- _('December'))
- shortMONTHS = (_('Jan'),
- _('Feb'),
- _('Mar'),
- _('Apr'),
- _('May'),
- _('Jun'),
- _('Jul'),
- _('Aug'),
- _('Sep'),
- _('Oct'),
- _('Nov'),
- _('Dec'))
- DAYWEEK = (_('Понедельник'),
- _('Вторник'),
- _('Среда'),
- _('Четверг'),
- _('Пятница'),
- _('Суббота'),
- _('Воскресенье'))
- shortDAYWEEK = (_('Mon'),
- _('Tue'),
- _('Wed'),
- _('Thu'),
- _('Fri'),
- _('Sat'),
- _('Sun'))
- class ClockToText(Converter, object):
- DEFAULT = 0
- FORMAT = 4
- def __init__(self, type):
- elif str(type).find('Format') != -1:
- self.type = self.FORMAT
- self.fmt_string = type[7:]
- @cached
- def getText(self):
- time = self.source.time
- if time is None:
- return ''
- elif self.type == self.FORMAT:
- spos = self.fmt_string.find('%')
- self.fmt_string = self.fmt_string.replace('%A',_(DAYWEEK[t.tm_wday]))
- self.fmt_string = self.fmt_string.replace('%B',_(MONTHS[t.tm_mon-1]))
- self.fmt_string = self.fmt_string.replace('%a',_(shortDAYWEEK[t.tm_wday]))
- self.fmt_string = self.fmt_string.replace('%b',_(shortMONTHS[t.tm_mon-1]))
- if spos > 0:
- s1 = self.fmt_string[:spos]
- s2 = strftime(self.fmt_string[spos:], t)
- return str(s1+s2)
- else:
- return strftime(self.fmt_string, t)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement