feat: formatted date times one website

This commit is contained in:
Leyla Becker 2026-02-19 16:32:11 -06:00
parent dffd14a19f
commit 927f13b623
5 changed files with 51 additions and 17 deletions

View file

@ -10,7 +10,7 @@ const getGitCreatedTime = (filePath) => {
{ encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
).trim();
if (result) {
return DateTime.fromISO(result);
return DateTime.fromISO(result).toUTC();
}
} catch (e) {
// Git command failed, return null
@ -25,7 +25,7 @@ const getGitModifiedTime = (filePath) => {
{ encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
).trim();
if (result) {
return DateTime.fromISO(result);
return DateTime.fromISO(result).toUTC();
}
} catch (e) {
// Git command failed, return null
@ -61,7 +61,7 @@ const getFileCreatedTime = (filePath) => {
try {
const stats = fs.statSync(filePath);
const time = stats.birthtime ?? stats.mtime;
return DateTime.fromJSDate(time);
return DateTime.fromJSDate(time, { zone: 'utc' });
} catch (e) {
return null;
}
@ -70,7 +70,7 @@ const getFileCreatedTime = (filePath) => {
const getFileModifiedTime = (filePath) => {
try {
const stats = fs.statSync(filePath);
return DateTime.fromJSDate(stats.mtime);
return DateTime.fromJSDate(stats.mtime, { zone: 'utc' });
} catch (e) {
return null;
}
@ -79,8 +79,8 @@ const getFileModifiedTime = (filePath) => {
const parseDate = (value) => {
if (!value) return null;
if (DateTime.isDateTime(value)) return value;
if (value instanceof Date) return DateTime.fromJSDate(value);
const parsed = DateTime.fromISO(value);
if (value instanceof Date) return DateTime.fromJSDate(value, { zone: 'utc' });
const parsed = DateTime.fromISO(value, { zone: 'utc' });
return parsed.isValid ? parsed : null;
}
@ -98,7 +98,7 @@ const getPostCreatedAt = (data) => {
return fileDate;
}
return DateTime.fromJSDate(data.page.date);
return DateTime.fromJSDate(data.page.date, { zone: 'utc' });
}
module.exports = {