feat: parse both-year ranges and open-ended events

Honkai: Star Rail and Wuthering Waves state a year on each side of a range
("Aug. 14, 2026 - Aug. 24, 2026"), which the year-on-the-end parser cannot
read.

Both also publish genuinely open-ended events — "Jul. 24, 2026 - End of
4.6", "July 10, 2026 - Permanent". Those keep their real start and report no
end, rather than being dropped or given a guessed one.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
Lucas Winther
2026-08-15 00:47:50 +02:00
co-authored by Claude Opus 5
parent 107179acfa
commit 90be312942
2 changed files with 89 additions and 0 deletions
+43
View File
@@ -1,7 +1,9 @@
import { describe, expect, test } from "bun:test";
import {
parseFullRange,
parseMonthDayRange,
parseMonthDayYear,
parseOpenRange,
parseSlashDateTimeRange,
} from "../src/ingest/dates.ts";
@@ -84,3 +86,44 @@ describe("parseSlashDateTimeRange", () => {
expect(parseSlashDateTimeRange("Permanently Available")).toBeNull();
});
});
describe("parseFullRange", () => {
test("reads a year from each side", () => {
expect(parseFullRange("Aug. 14, 2026 - Aug. 24, 2026")).toEqual({
start: { iso: "2026-08-14T00:00:00.000Z", precision: "day" },
end: { iso: "2026-08-24T00:00:00.000Z", precision: "day" },
});
});
test("ignores prose trailing the range", () => {
const r = parseFullRange(
"July 30, 2026 - August 13, 2026 Reach Union Level 8 to unlock",
);
expect(r?.end.iso).toBe("2026-08-13T00:00:00.000Z");
});
test("does not fire on a range with the year only at the end", () => {
// That shape belongs to parseMonthDayRange, which rolls the start year.
expect(parseFullRange("August 12 - September 21, 2026")).toBeNull();
});
});
describe("parseOpenRange", () => {
test("keeps a real start when the end is not a date", () => {
// "End of 4.6" and "Permanent" are honest unknowns, not parse failures.
for (const input of [
"Jul. 24, 2026 - End of 4.6",
"July 10, 2026 - Permanent",
"August 3, 2026",
]) {
const r = parseOpenRange(input);
expect(r?.end).toBeNull();
expect(r?.start.iso.slice(0, 4)).toBe("2026");
}
});
test("returns null when there is no full date at all", () => {
expect(parseOpenRange("08/12 - 08/24")).toBeNull();
expect(parseOpenRange("Releases in Version 3.6")).toBeNull();
});
});