From b0c21b9e2315c91f37c3cc18542b17be21c50394 Mon Sep 17 00:00:00 2001 From: dualfroz Date: Fri, 2 Oct 2026 16:08:52 +0200 Subject: [PATCH] Read the unit of a singular possessive duration like "a month's time" --- plugins/dates/src/api/parse/one/01-tokenize/01-shift.js | 3 ++- plugins/dates/tests/regressions.test.js | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/dates/src/api/parse/one/01-tokenize/01-shift.js b/plugins/dates/src/api/parse/one/01-tokenize/01-shift.js index 0aa8488..5c2a0a8 100644 --- a/plugins/dates/src/api/parse/one/01-tokenize/01-shift.js +++ b/plugins/dates/src/api/parse/one/01-tokenize/01-shift.js @@ -32,7 +32,8 @@ const halfUnits = { const parseUnit = function (m) { let unit = m.match('#Duration').text('normal') - unit = unit.replace(/s$/, '') + // 'weeks', or "a month's time" + unit = unit.replace(/'?s$/, '') // support shorthands like 'min' if (Object.hasOwn(aliases, unit)) { unit = aliases[unit] diff --git a/plugins/dates/tests/regressions.test.js b/plugins/dates/tests/regressions.test.js index 13fec18..8dd9ec3 100644 --- a/plugins/dates/tests/regressions.test.js +++ b/plugins/dates/tests/regressions.test.js @@ -167,3 +167,11 @@ test('a range does not stop other dates from splitting', (t) => { t.equal(res.length, 3, 'three dates found') t.end() }) + +test('singular possessive durations', (t) => { + t.equal(getStart("in a month's time"), '2026-08-11T00:00:00.000-04:00', "a month's time") + t.equal(getStart("in a week's time"), '2026-07-18T00:00:00.000-04:00', "a week's time") + t.equal(getStart("in a year's time"), '2027-07-11T00:00:00.000-04:00', "a year's time") + t.equal(getStart("in two weeks' time"), '2026-07-25T00:00:00.000-04:00', "two weeks' time") + t.end() +})