1

Correction de l'heure affectée aux nouveaux posts

This commit is contained in:
2025-12-02 16:36:57 +01:00
parent 39cee981ae
commit c65afa0a1e
2 changed files with 103 additions and 42 deletions

View File

@@ -9,7 +9,7 @@ const YAML = require("yaml");
const { buildUserAgent, checkUrl } = require("./lib/http");
const { getArchiveUrl, saveToArchive } = require("./lib/archive");
const { scrapePage } = require("./lib/puppeteer");
const { formatDateTime } = require("./lib/datetime");
const { formatDateTime, toHugoDateTime } = require("./lib/datetime");
const LINKS_ROOT = path.join("content", "interets", "liens-interessants");
@@ -83,26 +83,14 @@ if (duplicateBundlePath) {
console.log(`📂 Archive URL ${archiveUrl}...`);
// Déterminer la date et l'heure d'enregistrement
let entryDate = customDate ? new Date(customDate) : new Date();
if (isNaN(entryDate.getTime())) {
console.error("❌ Invalid date format. Use YYYY-MM-DD.");
process.exit(1);
}
const entryDate = customDate ? toHugoDateTime(customDate) : toHugoDateTime();
const formattedEntryDate = formatDateTime(entryDate);
const formattedStatusDate = formatDateTime();
const formattedDateFrench = entryDate.setLocale("fr").toFormat("d LLLL yyyy 'à' HH:mm");
const now = new Date(); // Current date for status
const formattedEntryDate = formatDateTime(entryDate); // ISO 8601 local avec offset
const formattedStatusDate = now.toISOString(); // ISO format
const formattedDateFrench = entryDate.toLocaleDateString("fr-FR", {
year: "numeric",
month: "long",
day: "numeric",
hour: "2-digit",
minute: "2-digit",
});
const year = entryDate.getFullYear();
const month = String(entryDate.getMonth() + 1).padStart(2, "0");
const day = String(entryDate.getDate()).padStart(2, "0");
const year = entryDate.year;
const month = String(entryDate.month).padStart(2, "0");
const day = String(entryDate.day).padStart(2, "0");
// Define paths
const bundlePath = path.join(hugoRoot, `content/interets/liens-interessants/${year}/${month}/${day}/${urlHash}/`);