hexo-front-matter
hexo-front-matter copied to clipboard
Date parse issue
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.
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.
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
.
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
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.)
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.