Read the unit of a singular possessive duration like "a month's time"
This commit is contained in:
1 parent
548a58524d
commit
b0c21b9e23
2 files changed
+10
-1
No files matched your search
@@ -32,7 +32,8 @@ const halfUnits = {
|
|||||||
|
|
||||||
const parseUnit = function (m) {
|
const parseUnit = function (m) {
|
||||||
let unit = m.match('#Duration').text('normal')
|
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'
|
// support shorthands like 'min'
|
||||||
if (Object.hasOwn(aliases, unit)) {
|
if (Object.hasOwn(aliases, unit)) {
|
||||||
unit = aliases[unit]
|
unit = aliases[unit]
|
||||||
|
|||||||
@@ -167,3 +167,11 @@ test('a range does not stop other dates from splitting', (t) => {
|
|||||||
t.equal(res.length, 3, 'three dates found')
|
t.equal(res.length, 3, 'three dates found')
|
||||||
t.end()
|
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()
|
||||||
|
})
|
||||||
Reference in new issue
Block a user