fix: normalize timestamps to UTC in template fixture tests#750
Open
YaoJifengZJU wants to merge 1 commit intoobsidianmd:mainfrom
Open
fix: normalize timestamps to UTC in template fixture tests#750YaoJifengZJU wants to merge 1 commit intoobsidianmd:mainfrom
YaoJifengZJU wants to merge 1 commit intoobsidianmd:mainfrom
Conversation
…timezone compatibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The youtube template fixture test fails on machines outside the UTC-8 timezone
because the expected output hardcodes a timezone-aware timestamp (-08:00).
When running on UTC+8 (e.g. China), the test produces:
created: "2025-01-15T20:00:00+08:00"
But the expected fixture contains:
created: "2025-01-15T04:00:00-08:00"
These represent the same moment in time, but string comparison fails.
Fix
Added a
normalizeTimestamps()helper in the test file that converts allISO 8601 timestamps to UTC before comparison, using the
dayjslibraryalready present in the project.
This makes the test pass correctly on any timezone.
Testing
Verified on UTC+8 (Asia/Shanghai): all 548 tests pass.