Skip to content

fix: parse blog dates as local time to avoid UTC offset#38

Merged
ajbozarth merged 3 commits intogenerative-computing:mainfrom
ajbozarth:fix/blog-date-timezone
May 6, 2026
Merged

fix: parse blog dates as local time to avoid UTC offset#38
ajbozarth merged 3 commits intogenerative-computing:mainfrom
ajbozarth:fix/blog-date-timezone

Conversation

@ajbozarth
Copy link
Copy Markdown
Contributor

@ajbozarth ajbozarth commented May 5, 2026

Summary

  • Rendered date: new Date("YYYY-MM-DD") parses ISO date-only strings as UTC midnight, shifting the displayed date one day earlier in US timezones. Switched to the same split-based new Date(year, month - 1, day) construction used in BlogCard so both the listing and individual post pages render the same date. Closes the gap missed when fix: blog grid partial-row grey background and date off-by-one #16 fixed the same issue in BlogCard.tsx.
  • OG metadata: publishedTime was passing a bare YYYY-MM-DD string, which strict consumers (LinkedIn, Slack, Google) parse as UTC midnight — producing the wrong date on social unfurls and search snippets. Qualified with T12:00:00 so the calendar day is preserved across all UTC offsets. Closes fix: publishedTime OG field passes bare YYYY-MM-DD string, parsed as UTC midnight by consumers #40.

Test plan

  • Open the blogs listing and click into a post — dates should match
  • Verify in a UTC-behind timezone (or with TZ=America/Chicago locally)
  • Inspect <meta property="article:published_time"> on a post page — should be e.g. 2025-01-15T12:00:00

Using new Date(dateStr) with an ISO date-only string parses as UTC
midnight, which shifts to the previous day in US timezones. Switch to
the same split-based construction used in BlogCard so both pages render
the same date.

Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
@ajbozarth ajbozarth requested a review from a team as a code owner May 5, 2026 21:03
@ajbozarth ajbozarth self-assigned this May 5, 2026
@ajbozarth
Copy link
Copy Markdown
Contributor Author

Found this while testing #36

Bare YYYY-MM-DD strings are parsed as UTC midnight by OG metadata
consumers, shifting the displayed date one day earlier for readers in
UTC-behind timezones. Using T12:00:00 preserves the correct calendar
day across all UTC offsets.

Closes generative-computing#40

Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
@ajbozarth
Copy link
Copy Markdown
Contributor Author

Updated to include a fix for #40 as it was around the same timezone issue

Comment thread src/app/blogs/[slug]/page.tsx Outdated
Co-authored-by: Paul Schweigert <paul@paulschweigert.com>
@ajbozarth ajbozarth added this pull request to the merge queue May 6, 2026
Merged via the queue into generative-computing:main with commit cb9e039 May 6, 2026
6 checks passed
@ajbozarth ajbozarth deleted the fix/blog-date-timezone branch May 6, 2026 19:29
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.

fix: publishedTime OG field passes bare YYYY-MM-DD string, parsed as UTC midnight by consumers

2 participants