Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
check list
Description
Issue resolved: #28
See also hexojs/hexo#4548
This pull request introduces significant changes to timezone handling, aiming to address long-standing timezone issues in Hexo. (Of course, after hexo-front-matter is updated, Hexo’s code will also need corresponding adjustments — for example, passing the timezone parameter when calling hexo-front-matter, and prompting users to properly configure the timezone in
_config.yml
)The core logic can be found in the comments of
lib/timestamp.ts
. Specifically:1. If a timezone is set in the timestamp, use that timezone.
2. Otherwise, use the timezone defined in the Hexo configuration. hexo-front-matter no longer read the timezone from the machine, as this can cause issues in CI environments or when collaborators are in different timezones.
3. If no timezone is provided, treat the timestamp as UTC by default and take no further action.
Note that this behavior differs from the YAML specification — YAML treats unspecified timestamps as UTC, whereas we apply Hexo’s configured timezone.
To support the new functionality, I used the
yaml
andluxon
libraries, which are different from Hexo’s current dependencies (js-yaml
andmoment-timezone
). However, all unit tests have passed, so I believe this should not cause any issues.Additional information