mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/mihalyr/calibre
This commit is contained in:
commit
8cf8421385
@ -2,25 +2,26 @@
|
|||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
from __future__ import unicode_literals, division, absolute_import, print_function
|
from __future__ import unicode_literals, division, absolute_import, print_function
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
from calibre import strftime
|
from datetime import datetime
|
||||||
import locale
|
|
||||||
|
|
||||||
|
CZ_DAYS = ['Po', 'Út', 'St', 'Čt', 'Pá', 'So', 'Ne']
|
||||||
|
CZ_MONTHS = ['led', 'úno', 'bře', 'dub', 'kvě', 'čen', 'čec', 'srp', 'zář', 'říj', 'lis', 'pro']
|
||||||
|
|
||||||
|
|
||||||
def cz_title_time():
|
def cz_title_time():
|
||||||
"""
|
"""
|
||||||
Helper function to return date with czech locale.
|
Helper function to return date with czech locale.
|
||||||
|
Uses hardcoded lookup table of day and month names as strftime requires
|
||||||
|
locale change that is not thread safe.
|
||||||
"""
|
"""
|
||||||
|
today = datetime.today()
|
||||||
orig_locale = locale.getlocale(locale.LC_TIME)
|
weekday = CZ_DAYS[today.weekday()]
|
||||||
try:
|
month = CZ_MONTHS[today.month-1]
|
||||||
locale.setlocale(locale.LC_TIME, 'cs_CZ')
|
return '{weekday}, {day} {month} {year}'.format(weekday=weekday,
|
||||||
except Exception:
|
day=today.day,
|
||||||
return ''
|
month=month,
|
||||||
try:
|
year=today.year)
|
||||||
timestr = strftime('%a, %d %b %Y')
|
|
||||||
finally:
|
|
||||||
locale.setlocale(locale.LC_TIME, orig_locale)
|
|
||||||
return timestr
|
|
||||||
|
|
||||||
|
|
||||||
class DenikNRecipe(BasicNewsRecipe):
|
class DenikNRecipe(BasicNewsRecipe):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user