31 lines
1.2 KiB
Diff
31 lines
1.2 KiB
Diff
Index: docutils-0.9.1/docutils/parsers/rst/directives/misc.py
|
|
===================================================================
|
|
--- docutils-0.9.1.orig/docutils/parsers/rst/directives/misc.py
|
|
+++ docutils-0.9.1/docutils/parsers/rst/directives/misc.py
|
|
@@ -10,6 +10,7 @@ import sys
|
|
import os.path
|
|
import re
|
|
import time
|
|
+import locale
|
|
from docutils import io, nodes, statemachine, utils
|
|
from docutils.error_reporting import SafeString, ErrorString
|
|
from docutils.parsers.rst import Directive, convert_directive_function
|
|
@@ -474,6 +475,17 @@ class Date(Directive):
|
|
'a substitution definition.' % self.name)
|
|
format = '\n'.join(self.content) or '%Y-%m-%d'
|
|
text = time.strftime(format)
|
|
+ if sys.version_info< (3, 0):
|
|
+ try:
|
|
+ text = unicode(text, locale.getpreferredencoding())
|
|
+ except UnicodeError:
|
|
+ try:
|
|
+ text = unicode(text, 'utf-8')
|
|
+ except UnicodeError:
|
|
+ # Fallback to something that can decode all bytes to
|
|
+ # something. Alternative fallback would be to decode
|
|
+ # with errors='replace'
|
|
+ text = unicode(text, 'latin-1')
|
|
return [nodes.Text(text)]
|
|
|
|
|