diff --git a/site/lib/added-dates.mjs b/site/lib/added-dates.mjs index 7b9c984..eb51489 100644 --- a/site/lib/added-dates.mjs +++ b/site/lib/added-dates.mjs @@ -1,3 +1,5 @@ +import { latestAllowedDate } from "./shared.mjs"; + /** * An entry's `added` date is when it joined the catalog, and it never * changes afterwards. Moving a file to another category is a rename in git, @@ -38,8 +40,11 @@ export function lateAddedDates(entries, firstAdded) { const errors = []; for (const { rel, added } of entries) { const first = firstAdded.get(rel); - if (first && added && String(added) > first) { - errors.push(`${rel} added ${added} is later than the file's first commit (${first}, following renames); set added: ${first}`); + if (first && added) { + const limit = latestAllowedDate(Date.parse(`${first}T00:00:00Z`)); + if (String(added) > limit) { + errors.push(`${rel} added ${added} is later than the file's first commit (${first}, following renames); set added: ${first}`); + } } } return errors; diff --git a/site/lib/lib.test.mjs b/site/lib/lib.test.mjs index b40d987..83d2433 100644 --- a/site/lib/lib.test.mjs +++ b/site/lib/lib.test.mjs @@ -1783,6 +1783,8 @@ await section("added dates follow renames (added-dates.mjs)", async () => { const utc = firstAddedFromLog(["\0" + String(Date.UTC(2026, 10, 7, 2, 30) / 1000), "", "A\tcatalog/2d/late.md"].join("\n")); eq("added: a timestamp header is read as a UTC day", utc.get("catalog/2d/late.md"), "2026-11-07"); eq("added: a UTC added date on an evening commit passes", lateAddedDates([{ rel: "catalog/2d/late.md", added: "2026-11-07" }], utc).length, 0); + eq("added: one day after first commit's UTC date passes for contributors east of UTC", lateAddedDates([{ rel: "catalog/2d/late.md", added: "2026-11-08" }], utc).length, 0); + eq("added: two days after first commit's UTC date fails", lateAddedDates([{ rel: "catalog/2d/late.md", added: "2026-11-09" }], utc).length, 1); }); /* engine scope and limits on entry pages (#173) --------------------------- */