fix(shipwrecks): a Wikidata date before AD 100 reads as ancient text (300 BC), not as the AD year

parseYear took the minus sign of -0299 as a separator, so a wreck from 300 BC
showed as year 300, sat at AD 300 in the period picker and stretched its
range. Years before AD 100 now keep their year as text ("300 BC", "AD 50")
and count as ancient, like EMODnet's period-dated wrecks; the query service's
XSD 1.1 years (0000 is 1 BC) are converted. Merging records now carries that
text with the date, and coarser-than-year precisions give no date.
This commit is contained in:
Sameh Khamis committed 2026-11-10 13:17:50 -08:00
1 parent 32e7a1a913
commit 0da3a28d76
2 files changed
+83 -25

No files matched your search

+40
View File
@@ -222,3 +222,43 @@ test('a sinking event folds into its ship; month-precise dates keep the year onl
assert.equal(concordia.date, '2012-01-13');
assert.equal('event' in concordia, false);
});
test('a date before AD 100 is kept as ancient text, never read as an AD year', () => {
const entity = (q) => ({ value: `http://www.wikidata.org/entity/${q}` });
const [bc, earlyAd, roman] = normalizeWikidataResults({
results: {
bindings: [
{
item: entity('Q1'),
itemLabel: { value: 'Antikythera wreck' },
coord: { value: 'Point(23.3 35.9)' },
sunk: { value: '-0299-01-01T00:00:00Z' },
sunkPrecision: { value: '11' },
},
{
item: entity('Q2'),
itemLabel: { value: 'Early wreck' },
coord: { value: 'Point(12 40)' },
sunk: { value: '0050-01-01T00:00:00Z' },
sunkPrecision: { value: '9' },
},
{
item: entity('Q3'),
itemLabel: { value: 'Roman wreck' },
coord: { value: 'Point(13 41)' },
sunk: { value: '0300-01-01T00:00:00Z' },
sunkPrecision: { value: '9' },
},
],
},
});
assert.equal(bc.year, null, '300 BC is not the year 300');
assert.equal(bc.date, null, 'no day for a BC date');
assert.equal(bc.dating, '300 BC');
assert.equal(bc.ancient, true);
assert.equal(earlyAd.year, null);
assert.equal(earlyAd.dating, 'AD 50');
assert.equal(earlyAd.ancient, true);
assert.equal(roman.year, 300);
assert.equal(roman.dating, null);
});