fix: scheduled post filter uses UTC instead of site timezone - #663
Open
WXY-V1hZ wants to merge 1 commit into
Open
fix: scheduled post filter uses UTC instead of site timezone#663WXY-V1hZ wants to merge 1 commit into
WXY-V1hZ wants to merge 1 commit into
Conversation
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.
Description
The
postFilterutility comparespubDatetimeagainstDate.now()to determine whether a scheduled post should be visible. However,new Date("2026-06-28")is interpreted as midnight UTC, while the user may be in a different timezone (e.g., Asia/Shanghai, UTC+8).This means:
pubDatetime: 2026-06-28and builds at 3:00 AM China time, the UTC time is still June 27 19:00 — 5 hours before the intended publish time.import.meta.env.DEV), the time check is skipped, so the post appears. But in production builds, it's silently filtered out — no error, no warning, just a missing page.pubDatetimeare affected, making it hard to reproduce and debug.Fix: Use
dayjs.utc(date).tz(tz, true)to interpret the date in the site's configured timezone rather than UTC. Thetrueparameter ("fixed mode") keeps the calendar values unchanged and shifts the underlying UTC instant accordingly, so2026-06-28means "June 28 in Shanghai" not "June 28 at Greenwich".Types of changes
Checklist
Further comments
This only affects users whose timezone offset is positive (east of UTC) and who publish posts on the same day. The existing
Datetime.astrocomponent already usesdayjs().tz()with the site's configured timezone for display — this fix bringspostFilterin line with that same convention.Related Issue
No existing issue — discovered during personal use.