hexo-front-matter icon indicating copy to clipboard operation
hexo-front-matter copied to clipboard

Date parse issue

Open 0x-jerry opened this issue 5 years ago • 5 comments

Here is my front matter

title: test article
date: 2020-02-09T13:50:14.098Z
---

I want the date is exact 2020-02-09T13:50:14.098Z, but the result of parse is 2020-02-09T05:50:14.098Z.

I think ISO time is more precise.

0x-jerry avatar Feb 09 '20 15:02 0x-jerry

Currently hexo will transform xml-formatted time based on timezone configuration given by _config.yml. Hexo will not transform date format only if ISO 8601 formatted time is given.

SukkaW avatar Feb 09 '20 16:02 SukkaW

I have test this lib, and it will transform all date format, not only ISO 8601.

I guess it is because js-yaml will handle all the date format, not only ISO 8601.

image

0x-jerry avatar Feb 10 '20 01:02 0x-jerry

https://github.com/hexojs/hexo-front-matter/blob/69516870249e91ba3e77e5b2e395645b3991d97a/lib/front_matter.js#L60 https://github.com/hexojs/hexo-front-matter/blob/55e50e5c1d80cb02a448bf41ae8ce9330156efad/lib/front_matter.ts#L58 this code add an unnecessary time zone offset

mosby-zhou avatar Jul 28 '21 09:07 mosby-zhou

This current behaviour is particularly annoying for teams with people working in multiple timezones, because the dates in the generated output change depending on the timezone of the team member generating the docs, which then appear as spurious changes in downstream processing of the output.

If it's not OK to change this behaviour across the board, perhaps there could be a _config.yml option in Hexo to turn off the adding the local user's timezone offset (that is, turn off the addition of item.getTimezoneOffset() * 60 * 1000 highlighted by @mosby-zhou above)? (I'd be happy to make a PR for this is if there's any indication that it would be welcome.)

markl-canva avatar Aug 27 '24 14:08 markl-canva

This current behaviour is particularly annoying for teams with people working in multiple timezones, because the dates in the generated output change depending on the timezone of the team member generating the docs, which then appear as spurious changes in downstream processing of the output.

Did you set timezone in your _config.yaml? Explict specifying timezone would help.

SukkaW avatar Sep 01 '24 18:09 SukkaW