added week and months to unit plugin

This commit is contained in:
Leyla Becker 2026-02-22 16:51:39 -06:00
parent 37b300b8e9
commit 602e92f986
2 changed files with 13 additions and 3 deletions

View file

@ -37,7 +37,11 @@ function unitLabel(unit, plural) {
'°F': '°F', '°C': '°C',
'inch': plural ? 'inches' : 'inch',
'cm': 'cm', 'mm': 'mm',
'minute': 'min', 'hour': 'hr', 'day': plural ? 'days' : 'day',
'minute': 'min',
'hour': 'hr',
'day': plural ? 'days' : 'day',
'week': plural ? 'weeks' : 'week',
'month': plural ? 'months' : 'month',
'second': plural ? 'seconds' : 'sec',
'parts by volume': 'parts by volume',
'parts by weight': 'parts by weight',
@ -211,6 +215,8 @@ function toMinutes(value, unit) {
function collapsedTime(value, unit) {
if (unit === 'day') return formatValueUnit(value, 'day');
if (unit === 'week') return formatValueUnit(value, 'week');
if (unit === 'month') return formatValueUnit(value, 'month');
if (unit === 'second') return formatValueUnit(value, 'second');
const mins = toMinutes(value, unit);
if (mins === null) return formatValueUnit(value, unit);
@ -219,6 +225,8 @@ function collapsedTime(value, unit) {
function expandedTime(value, unit) {
if (unit === 'day') return formatValueUnit(value, 'day');
if (unit === 'week') return formatValueUnit(value, 'week');
if (unit === 'month') return formatValueUnit(value, 'month');
if (unit === 'second') return formatValueUnit(value, 'second');
const mins = toMinutes(value, unit);
if (mins === null) return formatValueUnit(value, unit);