hexo icon indicating copy to clipboard operation
hexo copied to clipboard

Possible dates bug lib/plugins/processor/post.js

Open tcrowe opened this issue 7 years ago • 8 comments

In this issue we found that if the user sets timezone: in their _config.yml the date is modified and can be different than what they expect. https://github.com/hexojs/hexo/issues/3365

See this code here: https://github.com/hexojs/hexo/blame/master/lib/plugins/processor/post.js#L78

https://github.com/hexojs/hexo/blame/90b107c8b0bd8b386f64463403391f67eb1b2535/lib/plugins/processor/post.ts#L123

if timezone then change date

I'm not certain if this is a bug or not so I need help to understand.

How to test

hexo init
npm install
hexo new post one
hexo new post two
hexo new post three
hexo serve
  1. View markdown dates and then view post dates in browser

  2. Set timezone: Asia/Shanghai inside ./_config.yml

  3. hexo clean && hexo serve

  4. Repeat 2


If you do that you should notice the same date changes reported in #3365. Is this a bug or should hexo be changing the date relative to GMT or location?

Thanks for taking a look

tcrowe avatar Dec 21 '18 19:12 tcrowe

Was just about to post an issue regarding this, glad to see it's probably because of my timezone (Pacific/Auckland).

A post made on the 19th of November is showing the post.date being 4th of November, all other dates are off too, although most are just off by one.

Here's a link to my repo - https://github.com/puremana/personal-blog Affected post - https://github.com/puremana/personal-blog/blob/master/source/_posts/CORS-And-Hiding-Api-Keys.md

puremana avatar Dec 22 '18 09:12 puremana

@puremana Thank you for adding your experience with this as I am investigating the dates and timezones!

tcrowe avatar Dec 22 '18 11:12 tcrowe

I'm not yet investigate, but #3282 is possibility that same problem.

yoshinorin avatar Dec 24 '18 14:12 yoshinorin

Thank you, @YoshinoriN. I will search for all the places with timezone and see what else it's used for. Then I will make a PR to fix it. It's actually been there since the beginning. lol

tcrowe avatar Dec 28 '18 18:12 tcrowe

I tried for a while but I did not come to a solution. I will try again tomorrow.

tcrowe avatar Dec 28 '18 22:12 tcrowe

@tcrowe any luck?

puremana avatar Jan 03 '19 22:01 puremana

No, @puremana. For now all we can do is ask people to disable(comment or delete) the timezone: configuration which will render the dates in the timezone of the machine generating the output source.

When I was looking at the code I couldn't figure out the original intention so I need to think about the implications.

Was it true that if you disable the timezone: that the dates show up as you expect?

tcrowe avatar Jan 04 '19 00:01 tcrowe

Sorry, it turns out timezone doesn't change anything at all in my project, even when it should be. My bug was something else, thanks for all of your help

puremana avatar Jan 04 '19 21:01 puremana