mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Change date_format to support (locale,format)
This commit is contained in:
parent
bf314fde6b
commit
d1d82db4f7
1 changed files with 5 additions and 0 deletions
|
|
@ -5,6 +5,7 @@ from pelican.settings import _DEFAULT_CONFIG
|
|||
from datetime import datetime
|
||||
from os import getenv
|
||||
from sys import platform, stdin
|
||||
import locale
|
||||
|
||||
class Page(object):
|
||||
"""Represents a page
|
||||
|
|
@ -85,6 +86,10 @@ class Page(object):
|
|||
else:
|
||||
self.date_format = settings['DEFAULT_DATE_FORMAT']
|
||||
|
||||
if isinstance(self.date_format, tuple):
|
||||
locale.setlocale(locale.LC_ALL, self.date_format[0])
|
||||
self.date_format = self.date_format[1]
|
||||
|
||||
if hasattr(self, 'date'):
|
||||
if platform == 'win32':
|
||||
self.locale_date = self.date.strftime(self.date_format.encode('ascii','xmlcharrefreplace')).decode(stdin.encoding)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue