mirror of
https://github.com/Xevion/undefined.behavio.rs.git
synced 2025-12-06 11:16:51 -06:00
Disable date-fns-tz timezone offset solution, add thoughts, revert
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { z, defineCollection } from "astro:content";
|
import { z, defineCollection } from "astro:content";
|
||||||
import { parse } from "date-fns";
|
import { parse } from "date-fns";
|
||||||
import { zonedTimeToUtc } from "date-fns-tz";
|
// import { zonedTimeToUtc } from "date-fns-tz";
|
||||||
|
|
||||||
const blogCollection = defineCollection({
|
const blogCollection = defineCollection({
|
||||||
type: "content", // v2.5.0 and later
|
type: "content", // v2.5.0 and later
|
||||||
@@ -8,10 +8,13 @@ const blogCollection = defineCollection({
|
|||||||
title: z.string(),
|
title: z.string(),
|
||||||
description: z.string(),
|
description: z.string(),
|
||||||
pubDate: z.string().transform((date) => {
|
pubDate: z.string().transform((date) => {
|
||||||
|
// I am truly lost on how TZ works in Javascript Dates.
|
||||||
|
// I believe somehow the solution would lie here in making sure that the date offset is parsed and transmitted properly,
|
||||||
|
// but there is no insight in how this works so far. I'm lost as fuck.
|
||||||
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||||
const parsed = parse(date, "yyyy-MM-dd HH:mm:ss XX", new Date());
|
const parsed = parse(date, "yyyy-MM-dd HH:mm:ss XX", new Date());
|
||||||
const utc = zonedTimeToUtc(parsed, timezone);
|
// const utc = zonedTimeToUtc(parsed, timezone);
|
||||||
return z.date().parse(utc);
|
return z.date().parse(parsed);
|
||||||
}),
|
}),
|
||||||
tags: z.array(z.string()),
|
tags: z.array(z.string()),
|
||||||
preview_image: z.string().optional(),
|
preview_image: z.string().optional(),
|
||||||
|
|||||||
Reference in New Issue
Block a user