Skip to content

Commit

Permalink
📆 Show date as UTC date (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanc1 authored Jan 23, 2024
1 parent 855f29e commit a62438c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/wise-lizards-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@myst-theme/frontmatter': patch
---

Show date as UTC date
4 changes: 3 additions & 1 deletion packages/frontmatter/src/FrontmatterBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export function DateString({
spacer?: boolean;
}) {
if (!date) return null;
const dateString = new Date(date).toLocaleDateString('en-US', format);
const d = new Date(date); // This is in the users timezone
const utcDate = new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
const dateString = utcDate.toLocaleDateString('en-US', format);
return (
<time dateTime={date} className={classNames({ 'text-spacer': spacer })}>
{dateString}
Expand Down

0 comments on commit a62438c

Please sign in to comment.