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