Skip to content

fix: normalize timestamps to UTC in template fixture tests#750

Open
YaoJifengZJU wants to merge 1 commit intoobsidianmd:mainfrom
YaoJifengZJU:fix/youtube-fixture-timezone
Open

fix: normalize timestamps to UTC in template fixture tests#750
YaoJifengZJU wants to merge 1 commit intoobsidianmd:mainfrom
YaoJifengZJU:fix/youtube-fixture-timezone

Conversation

@YaoJifengZJU
Copy link
Copy Markdown

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 all
ISO 8601 timestamps to UTC before comparison, using the dayjs library
already present in the project.

This makes the test pass correctly on any timezone.

Testing

Verified on UTC+8 (Asia/Shanghai): all 548 tests pass.

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.

1 participant