Description
The Duration object documentation says that the object form accepts any of the following keys:
year, years, month, months, day, days, minute, minutes, second, seconds, millisecond, milliseconds, ms
The keys hour / hours and week / weeks are missing from this list, even though they are supported.
The list is incomplete in both versions of the docs:
Current source (v7.1.0)
In @full-ui/headless-calendar@7.1.0, createDuration() passes object input to parseObject(), which accepts hour / hours and week / weeks:
function parseObject(obj) {
let duration = {
years: obj.years || obj.year || 0,
months: obj.months || obj.month || 0,
days: obj.days || obj.day || 0,
milliseconds: (obj.hours || obj.hour || 0) * 60 * 60 * 1000 + // hours
(obj.minutes || obj.minute || 0) * 60 * 1000 + // minutes
(obj.seconds || obj.second || 0) * 1000 + // seconds
(obj.milliseconds || obj.millisecond || obj.ms || 0), // ms
};
let weeks = obj.weeks || obj.week;
if (weeks) {
duration.days += weeks * 7;
duration.specifiedWeeks = true;
}
return duration;
}
The published TypeScript type also includes these keys:
interface DurationObjectInput {
years?: number;
year?: number;
months?: number;
month?: number;
weeks?: number;
week?: number;
days?: number;
day?: number;
hours?: number;
hour?: number;
minutes?: number;
minute?: number;
seconds?: number;
second?: number;
milliseconds?: number;
millisecond?: number;
ms?: number;
}
v6 behaves the same way (checked in 6.1.15).
Example
This works as expected, but going by the docs it doesn't look valid:
new Calendar(el, {
slotMinTime: { hours: 6 },
slotMaxTime: { hours: 22 },
});
Suggested fix
Update the list of accepted keys in the object form (in both the v7 and v6 docs) to:
year, years, month, months, week, weeks, day, days, hour, hours, minute, minutes, second, seconds, millisecond, milliseconds, ms
Description
The Duration object documentation says that the object form accepts any of the following keys:
The keys
hour/hoursandweek/weeksare missing from this list, even though they are supported.The list is incomplete in both versions of the docs:
Current source (v7.1.0)
In
@full-ui/headless-calendar@7.1.0,createDuration()passes object input toparseObject(), which acceptshour/hoursandweek/weeks:The published TypeScript type also includes these keys:
v6 behaves the same way (checked in 6.1.15).
Example
This works as expected, but going by the docs it doesn't look valid:
Suggested fix
Update the list of accepted keys in the object form (in both the v7 and v6 docs) to: