Change date_format to support (locale,format)

This commit is contained in:
Jiachen Yang 2012-02-26 16:35:04 +09:00
commit d1d82db4f7

View file

@ -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)