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

Date parse issue #28

Open
0x-jerry opened this issue Feb 9, 2020 · 5 comments
Open

Date parse issue #28

0x-jerry opened this issue Feb 9, 2020 · 5 comments

Comments

@0x-jerry
Copy link

0x-jerry commented Feb 9, 2020

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.

@SukkaW
Copy link
Member

SukkaW commented Feb 9, 2020

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.

@0x-jerry
Copy link
Author

0x-jerry commented Feb 10, 2020

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

@mosby-zhou
Copy link

mosby-zhou commented Jul 28, 2021

data[key] = new Date(item.getTime() + (item.getTimezoneOffset() * 60 * 1000));

data[key] = new Date(item.getTime() + (item.getTimezoneOffset() * 60 * 1000));

this code add an unnecessary time zone offset

@markl-canva
Copy link

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.)

@SukkaW
Copy link
Member

SukkaW commented Sep 1, 2024

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.

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

4 participants