Skip to content

Commit 835540f

Browse files
committed
fix(date): add timeZone to date formatting for accurate display
1 parent 33ec456 commit 835540f

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/pages/notes/[slug].astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ if (!note || note.data.draft) {
1010
}
1111
1212
const { Content } = await render(note)
13-
const fmtDate = new Intl.DateTimeFormat('es-CO', { day: 'numeric', month: 'long', year: 'numeric' })
13+
// timeZone UTC: la fecha del frontmatter es un día calendario, no un instante.
14+
const fmtDate = new Intl.DateTimeFormat('es-CO', { day: 'numeric', month: 'long', year: 'numeric', timeZone: 'UTC' })
1415
---
1516

1617
<BaseLayout title={`${note.data.title} — CodeByMike`} description={note.data.description} type="article">

src/pages/notes/index.astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ const notes = (await getCollection('notes', ({ data }) => !data.draft)).sort(
66
(a, b) => b.data.date.getTime() - a.data.date.getTime(),
77
)
88
9-
const fmtDate = new Intl.DateTimeFormat('es-CO', { day: 'numeric', month: 'long', year: 'numeric' })
9+
// timeZone UTC: la fecha del frontmatter es un día calendario, no un instante;
10+
// sin esto, America/Bogota (-5) la retrocede al día anterior.
11+
const fmtDate = new Intl.DateTimeFormat('es-CO', { day: 'numeric', month: 'long', year: 'numeric', timeZone: 'UTC' })
1012
---
1113

1214
<BaseLayout

0 commit comments

Comments
 (0)