Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

post for tomorrow gets published today #94

Open
markuszoeller opened this issue Oct 5, 2017 · 1 comment
Open

post for tomorrow gets published today #94

markuszoeller opened this issue Oct 5, 2017 · 1 comment

Comments

@markuszoeller
Copy link

markuszoeller commented Oct 5, 2017

I write blog posts with pre-defined publishing dates. If this date is tomorrow, the publishing happens today, which is 1 day too early.

steps to reproduce

Create a post with tomorrow's date (example assumes that today is October the 5th):

.. post:: Oct 6, 2017
   :title: this is a title

Build the sources ablog build

expected result

The post is not published

actual result

The post is listed in the recent posts section

Recent posts
============

.. postlist:: 5
   :excerpts:
   :date: %b %d, %Y
   :list-style: circle

root cause

The variable TOMORROW gets created with time, while the post.date is a datetime object without time. Examples:
A print statement after this line https://github.com/abakan/ablog/blob/87933fa874680129986c5fff54518d83c753c07b/ablog/blog.py#L89

print('TOMORROW = %s', TOMORROW)   # added for debug

results in this output:

('TOMORROW = %s', datetime.datetime(2017, 10, 6, 7, 34, 2, 150817))

while the print statement after this comparison at https://github.com/abakan/ablog/blob/87933fa874680129986c5fff54518d83c753c07b/ablog/blog.py#L239

print('post date: %s', post.date)  # added for debug

results in this output:

('post date: %s', datetime.datetime(2017, 10, 6, 0, 0))

In short, the post date of tomorrow will always be older than the TOMORROW variable.

possible fix

This (ugly) diff shows one way to do it:

--- blog.py	2017-10-05 20:19:08.405927051 +0200
+++ blog.py.new	2017-10-05 20:10:42.842425856 +0200
@@ -87,6 +87,7 @@
 
 
 TOMORROW = datetime.today() + dtmod.timedelta(1)
+TOMORROW = TOMORROW.replace(hour=0, minute=0, second=0, microsecond=0)
 FUTURE = datetime(9999, 12, 31)
 
 

When we remove the time information of TOMORROW, the comparison works and a post for tomorrow gets only published tomorrow.

markuszoeller added a commit to markuszoeller/markuszoeller.github.io that referenced this issue Oct 5, 2017
Blog posts with post dates for tomorrow get published today:
abakan-zz/ablog#94

This change adds a private patch until it is fixed in ABlog.
@nabobalis
Copy link

A new version of Ablog (v0.9.0) is out at this repo.

We did take your fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants