Skip to content

Commit

Permalink
Merge pull request #1314 from getnikola/fix-dates
Browse files Browse the repository at this point in the history
fix #1284, fix #1313 -- fix dates in new_post
  • Loading branch information
Kwpolska committed Jun 3, 2014
2 parents 4564590 + 41c1e1f commit 53eabce
Show file tree
Hide file tree
Showing 19 changed files with 27 additions and 28 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -12,6 +12,8 @@ Features
Bugfixes
--------

* sanitized dates generated by new_post by forcing an ISO 8601-esque
format of YYYY-mm-dd HH:MM:SS (Issues #1284, #1313)
* made github_deploy compatible with Python 3 (Issue #1311)
* rebuild stuff on TranslatableSettings’ change (Issue #1297)
* made bootstrap-jinja and bootstrap3-jinja work again, assets were missing
Expand Down
2 changes: 1 addition & 1 deletion docs/creating-a-theme.txt
@@ -1,6 +1,6 @@
.. title: Creating a Theme
.. slug: creating-a-theme
.. date: 2012/03/13 12:00
.. date: 2012-03-13 12:00:00 UTC-03:00
.. tags:
.. link:
.. description:
Expand Down
2 changes: 1 addition & 1 deletion docs/extending.txt
@@ -1,6 +1,6 @@
.. title: Extending Nikola
.. slug: extending
.. date: 2012/03/30 23:00
.. date: 2012-03-30 23:00:00 UTC-03:00
.. tags:
.. link:
.. description:
Expand Down
2 changes: 1 addition & 1 deletion docs/internals.txt
@@ -1,6 +1,6 @@
.. title: Nikola Internals
.. slug: internals
.. date: 2012/03/30 23:00
.. date: 2012-03-30 23:00:00 UTC-03:00
.. tags:
.. link:
.. description:
Expand Down
11 changes: 7 additions & 4 deletions docs/manual.txt
@@ -1,6 +1,6 @@
.. title: The Nikola Handbook
.. slug: handbook
.. date: 2012/03/30 23:00
.. date: 2012-03-30 23:00:00 UTC-03:00
.. tags:
.. link:
.. description:
Expand Down Expand Up @@ -459,7 +459,7 @@ The content of that file is as follows::

.. title: How to make money
.. slug: how-to-make-money
.. date: 2012/09/15 19:52:05
.. date: 2012-09-15 19:52:05 UTC
.. tags:
.. link:
.. description:
Expand Down Expand Up @@ -534,15 +534,18 @@ to your configuration::

How to make money
how-to-make-money
2012/09/15 19:52:05
2012-09-15 19:52:05 UTC

However, starting with Nikola v7, you can now use ``.meta`` files and put
all metadata you want, complete with the explanations — they look just like
the beginning of our reST files.

.. title: How to make money
.. slug: how-to-make-money
.. date: 2012/09/15 19:52:05
.. date: 2012-09-15 19:52:05 UTC

Both file formats are supported; however, the new format is preferred, if
possible.

If you are writing a multilingual site, you can also create a per-language
post file (for example: ``how-to-make-money.es.txt`` with the default TRANSLATIONS_PATTERN, see below).
Expand Down
2 changes: 1 addition & 1 deletion docs/social_buttons.txt
@@ -1,6 +1,6 @@
.. title: Alternative Social Buttons
.. slug: social_buttons
.. date: 2013/08/19 23:00
.. date: 2013-08-19 23:00:00 UTC-03:00
.. tags:
.. link:
.. description:
Expand Down
2 changes: 1 addition & 1 deletion docs/theming.txt
@@ -1,6 +1,6 @@
.. title: Theming Nikola
.. slug: theming
.. date: 2012/03/13 12:00
.. date: 2012-03-13 12:00:00 UTC-03:00
.. tags:
.. link:
.. description:
Expand Down
2 changes: 1 addition & 1 deletion docs/upgrading-to-v6.txt
@@ -1,6 +1,6 @@
.. title: Upgrading to v6
.. slug: upgrading-to-v6
.. date: 2013/08/23 23:00
.. date: 2013-08-23 23:00:00 UTC-03:00
.. tags:
.. link:
.. description:
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/samplesite/posts/1.rst
@@ -1,6 +1,6 @@
.. title: Welcome to Nikola
.. slug: welcome-to-nikola
.. date: 2012/03/30 23:00
.. date: 2012-03-30 23:00:00 UTC-03:00
.. tags: nikola, python, demo, blog
.. author: Roberto Alsina
.. link: http://getnikola.com
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/samplesite/stories/1.rst
@@ -1,6 +1,6 @@
.. title: Nikola: it generates static
.. slug: about-nikola
.. date: 2012/03/30 23:00
.. date: 2012-03-30 23:00:00 UTC-03:00
.. tags:
.. link:
.. description:
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/samplesite/stories/a-study-in-scarlet.txt
@@ -1,7 +1,7 @@
.. link:
.. description:
.. tags:
.. date: 2013/08/27 18:20:55
.. date: 2013-08-27 18:20:55 UTC-03:00
.. title: A STUDY IN SCARLET.
.. slug: a-study-in-scarlet

Expand Down
2 changes: 1 addition & 1 deletion nikola/data/samplesite/stories/bootstrap-demo.rst
@@ -1,6 +1,6 @@
.. title: Bootstrap Demo
.. slug: bootstrap-demo
.. date: 2012/03/30 23:00
.. date: 2012-03-30 23:00:00 UTC-03:00
.. tags: bootstrap, demo
.. link: http://getnikola.com
.. description:
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/samplesite/stories/charts.txt
@@ -1,7 +1,7 @@
.. link:
.. description:
.. tags:
.. date: 2013/08/27 18:20:55
.. date: 2013-08-27 18:20:55 UTC-03:00
.. title: Charts
.. slug: charts

Expand Down
2 changes: 1 addition & 1 deletion nikola/data/samplesite/stories/listings-demo.rst
@@ -1,6 +1,6 @@
.. title: Listings Demo
.. slug: listings-demo
.. date: 2012/12/15 10:16:20
.. date: 2012-12-15 10:16:20 UTC-03:00
.. tags:
.. link:
.. description:
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/samplesite/stories/quickref.rst
@@ -1,6 +1,6 @@
.. title: A reStructuredText Reference
.. slug: quickref
.. date: 2012/03/30 23:00
.. date: 2012-03-30 23:00:00 UTC-03:00
.. tags:
.. link:
.. description:
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/samplesite/stories/quickstart.rst
@@ -1,6 +1,6 @@
.. title: A reStructuredText Primer
.. slug: quickstart
.. date: 2012/03/30 23:00
.. date: 2012-03-30 23:00:00 UTC-03:00
.. tags:
.. link:
.. description:
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/samplesite/stories/slides-demo.rst
@@ -1,6 +1,6 @@
.. title: Slides Demo
.. slug: slides-demo
.. date: 2012/12/27 10:16:20
.. date: 2012-12-27 10:16:20 UTC-03:00
.. tags:
.. link:
.. description:
Expand Down
8 changes: 2 additions & 6 deletions nikola/plugins/command/new_post.py
Expand Up @@ -27,7 +27,6 @@
from __future__ import unicode_literals, print_function
import codecs
import datetime
import locale
import os
import sys
import subprocess
Expand Down Expand Up @@ -129,16 +128,13 @@ def get_date(schedule=False, rule=None, last_date=None, tz=None, iso8601=False):
offset_min = offset_sec % 3600
if iso8601:
tz_str = '{0:+03d}:{1:02d}'.format(offset_hrs, offset_min // 60)
return date.strftime('%Y-%m-%dT%T') + tz_str
else:
if offset:
tz_str = ' UTC{0:+03d}:{1:02d}'.format(offset_hrs, offset_min // 60)
else:
tz_str = ' UTC'
return date.strftime('{0} {1}'.format(
locale.nl_langinfo(locale.D_FMT),
locale.nl_langinfo(locale.T_FMT),
)) + tz_str

return date.strftime('%Y-%m-%d %H:%M:%S') + tz_str


class CommandNewPost(Command):
Expand Down
4 changes: 1 addition & 3 deletions tests/test_scheduling.py
Expand Up @@ -46,9 +46,7 @@ def tearDown(cls):
def test_get_date(self):
from nikola.plugins.command.new_post import get_date

# This is now locale-dependent, so do it here, where
# locale is set.
FMT = '{0} {1} %Z'.format(
FMT = '%Y-%m-%d %H:%M:%S %Z'.format(
locale.nl_langinfo(locale.D_FMT),
locale.nl_langinfo(locale.T_FMT),
)
Expand Down

0 comments on commit 53eabce

Please sign in to comment.