Add hour/minute/timezone to blog post dates#151
Merged
Conversation
Frontmatter date-only strings like "2026-05-21" were parsed by `new Date()` as UTC midnight, which displayed as the previous day for any viewer west of UTC and caused the PrairieLearn news popup's "X hours ago" to be off by up to a full day. Switch the five existing posts to full ISO timestamps with US Central offsets, and parse dates with date-fns `parseISO` (treats date-only strings as local time) in the blog index, post layout, RSS feed, and sort. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
`format(parseISO(date), ...)` formats in the local timezone, so the static HTML rendered on Vercel (UTC) and the client hydration in the viewer's timezone could disagree by a day for west-of-UTC viewers — the same off-by- one symptom as before. Extract a small `formatBlogDate` helper that uses `Intl.DateTimeFormat` pinned to America/Chicago, so the rendered calendar date is identical regardless of where the code runs. Lives in a separate file from `lib/blog.ts` (which imports `fs`) to keep the client bundle clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
nwalters512
approved these changes
May 21, 2026
Contributor
There was a problem hiding this comment.
Nit, IMO there's no reason for this to be a separate file, this can just live in lib/blog.ts.
Collaborator
Author
There was a problem hiding this comment.
I removed blogDate.ts and moved it into blog.ts.
Collaborator
Author
| year: "numeric", | ||
| month: "long", | ||
| day: "numeric", | ||
| timeZone: "America/Chicago", |
Contributor
There was a problem hiding this comment.
Hardcoding seems reasonable enough given that we're only rendering dates and not times - I'd want a different approach if we were doing times.
Collaborator
Author
There was a problem hiding this comment.
Per review, drop the standalone lib/blogDate.ts and move formatBlogDate back to lib/blog.ts. Moves getAllPosts (the only fs-using piece, used solely in this page's getStaticProps) inline into pages/about/blog/index.tsx so lib/blog.ts stays free of node-only imports and is safe to bundle into the client component that calls formatBlogDate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Testing
newsFeedUrltohttp://localhost:3000/blog/rss.xml, sync the news items, and check that the time since each article's publication is correct.