Skip to content

feat(validate_config): add warning about timezone#5731

Open
stevenjoezhang wants to merge 1 commit intomasterfrom
tz
Open

feat(validate_config): add warning about timezone#5731
stevenjoezhang wants to merge 1 commit intomasterfrom
tz

Conversation

@stevenjoezhang
Copy link
Member

What does it do?

See #5720

Screenshots

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

@github-actions
Copy link

github-actions bot commented Jan 6, 2026

How to test

git clone -b tz https://github.com/hexojs/hexo.git
cd hexo
npm install
npm test

@coveralls
Copy link

Pull Request Test Coverage Report for Build 20736158720

Details

  • 6 of 20 (30.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 99.351%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/hexo/validate_config.ts 6 20 30.0%
Totals Coverage Status
Change from base Build 20673264715: -0.1%
Covered Lines: 9944
Relevant Lines: 10009

💛 - Coveralls

Comment on lines +39 to +40
const machineTimezone = moment.tz.guess();
if (configTimezone.name !== machineTimezone) {
Copy link
Member

@SukkaW SukkaW Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to guess and warn about a mismatch here? E.g., running Hexo on CI may have a different timezone, intentionally.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that the warning will always be displayed in CI environments. However, I think it should be displayed.

If the user's permalink setting includes time-based parts, it will also change the URLs of their posts.

As @stevenjoezhang mentioned in the above comment at #5720 (comment), my concern is that URLs may change.

Currently, URLs are always generated using the LocalTimeZone (machine's timezone) for date/time formatting. If we change it to use the Timezone from _config.yml for generating URLs in the next major version, and users are unaware that their machine's timezone and the timezone in _config.yml are inconsistent, the generated URLs could unintentionally change.

However, I do think it might be acceptable to address this by including a migration guide in the release notes instead of showing the warning.

Copy link
Member

@yoshinorin yoshinorin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, LGTM

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

Successfully merging this pull request may close these issues.

4 participants