##// END OF EJS Templates
Backport PR #4085 : Fix nbconvert date formats for Windows.
Thomas Kluyver -
Show More
@@ -33,7 +33,7 b' from IPython.config import Config'
33 33 from IPython.nbformat import current as nbformat
34 34 from IPython.utils.traitlets import MetaHasTraits, DottedObjectName, Unicode, List, Dict, Any
35 35 from IPython.utils.importstring import import_item
36 from IPython.utils.text import indent
36 from IPython.utils import text
37 37 from IPython.utils import py3compat
38 38
39 39 from IPython.nbconvert import transformers as nbtransformers
@@ -47,7 +47,7 b' from IPython.nbconvert import filters'
47 47 JINJA_EXTENSIONS = ['jinja2.ext.loopcontrols']
48 48
49 49 default_filters = {
50 'indent': indent,
50 'indent': text.indent,
51 51 'markdown2html': filters.markdown2html,
52 52 'ansi2html': filters.ansi2html,
53 53 'filter_data_type': filters.DataTypeFilter,
@@ -282,7 +282,7 b' class Exporter(LoggingConfigurable):'
282 282 resources['metadata']['name'] = notebook_name
283 283
284 284 modified_date = datetime.datetime.fromtimestamp(os.path.getmtime(filename))
285 resources['metadata']['modified_date'] = modified_date.strftime("%B %d, %Y")
285 resources['metadata']['modified_date'] = modified_date.strftime(text.date_format)
286 286
287 287 with io.open(filename) as f:
288 288 return self.from_notebook_node(nbformat.read(f, 'json'), resources=resources,**kw)
@@ -29,6 +29,7 b' from pygments.formatters import LatexFormatter'
29 29 # Our own imports
30 30 # Configurable traitlets
31 31 from IPython.utils.traitlets import Unicode, Bool
32 from IPython.utils import text
32 33
33 34 # Needed to override transformer
34 35 from .base import (Transformer)
@@ -157,7 +158,7 b' class SphinxTransformer(Transformer):'
157 158 if self.publish_date:
158 159 resources["sphinx"]["date"] = self.publish_date
159 160 elif len(resources['metadata']['modified_date'].strip()) == 0:
160 resources["sphinx"]["date"] = date.today().strftime("%B %-d, %Y")
161 resources["sphinx"]["date"] = date.today().strftime(text.date_format)
161 162 else:
162 163 resources["sphinx"]["date"] = resources['metadata']['modified_date']
163 164
@@ -219,7 +220,7 b' class SphinxTransformer(Transformer):'
219 220 if resources['metadata']['modified_date']:
220 221 default_date = resources['metadata']['modified_date']
221 222 else:
222 default_date = date.today().strftime("%B %-d, %Y")
223 default_date = date.today().strftime(text.date_format)
223 224
224 225 user_date = console.input("Date (deafults to \"" + default_date + "\"): ")
225 226 if len(user_date.strip()) == 0:
@@ -21,6 +21,7 b' Inheritance diagram:'
21 21
22 22 import os
23 23 import re
24 import sys
24 25 import textwrap
25 26 from string import Formatter
26 27
@@ -29,6 +30,16 b' from IPython.testing.skipdoctest import skip_doctest_py3, skip_doctest'
29 30 from IPython.utils import py3compat
30 31
31 32 #-----------------------------------------------------------------------------
33 # Declarations
34 #-----------------------------------------------------------------------------
35
36 # datetime.strftime date format for ipython
37 if sys.platform == 'win32':
38 date_format = "%B %d, %Y"
39 else:
40 date_format = "%B %-d, %Y"
41
42 #-----------------------------------------------------------------------------
32 43 # Code
33 44 #-----------------------------------------------------------------------------
34 45
General Comments 0
You need to be logged in to leave comments. Login now