date-vir 8.3.1 → 8.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -150,9 +150,33 @@ function findLargestDiff({ datesOrDuration, options, largestToSmallestSelectedUn
150
150
  const innerDiff = createDiff(datesOrDuration, options, {
151
151
  [unit]: true,
152
152
  });
153
- if (innerDiff[unit]) {
154
- return innerDiff;
153
+ /* node:coverage disable: the `|| 0` fallback isn't reachable since we always request `unit`. */
154
+ const roundedValue = Math.abs(innerDiff[unit] || 0);
155
+ /* node:coverage enable */
156
+ if (!roundedValue) {
157
+ continue;
158
+ }
159
+ /**
160
+ * When rounding pushes a fractional value (< 1) up to an integer >= 1 it inflates the
161
+ * displayed unit (e.g. 0.67 years becomes "1 year" for an 8-month duration). Require the
162
+ * unrounded value to be close enough to the integer (>= 0.9, matching `roundNarrow`) before
163
+ * accepting the promotion. Values that already round below 1 (like 0.1 days with
164
+ * `decimalCount: 1`) still qualify.
165
+ */
166
+ if (roundedValue >= 1) {
167
+ const unroundedDiff = createDiff(datesOrDuration, {
168
+ decimalCount: undefined,
169
+ }, {
170
+ [unit]: true,
171
+ });
172
+ /* node:coverage disable: the `|| 0` fallback isn't reachable since we always request `unit`. */
173
+ const unroundedValue = Math.abs(unroundedDiff[unit] || 0);
174
+ /* node:coverage enable */
175
+ if (unroundedValue < 0.9) {
176
+ continue;
177
+ }
155
178
  }
179
+ return innerDiff;
156
180
  }
157
181
  return {};
158
182
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "date-vir",
3
- "version": "8.3.1",
3
+ "version": "8.3.3",
4
4
  "description": "Easy and explicit dates and times.",
5
5
  "keywords": [
6
6
  "date",
@@ -17,7 +17,7 @@
17
17
  "type": "git",
18
18
  "url": "git+https://github.com/electrovir/date-vir.git"
19
19
  },
20
- "license": "(MIT or CC0 1.0)",
20
+ "license": "(MIT OR CC0-1.0)",
21
21
  "author": {
22
22
  "name": "electrovir",
23
23
  "url": "https://github.com/electrovir"
@@ -34,25 +34,25 @@
34
34
  "test:docs": "virmator docs check"
35
35
  },
36
36
  "dependencies": {
37
- "@augment-vir/assert": "^31.68.4",
37
+ "@augment-vir/assert": "^31.69.0",
38
38
  "@augment-vir/common": "^31.68.4",
39
- "@date-vir/duration": "^8.3.1",
39
+ "@date-vir/duration": "^8.3.3",
40
40
  "@types/luxon": "^3.7.1",
41
41
  "luxon": "^3.7.2",
42
- "object-shape-tester": "^6.11.0",
42
+ "object-shape-tester": "^6.13.0",
43
43
  "type-fest": "^5.5.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@augment-vir/test": "^31.68.4",
46
+ "@augment-vir/test": "^31.69.0",
47
47
  "@web/dev-server-esbuild": "^1.0.5",
48
48
  "@web/test-runner": "^0.20.2",
49
49
  "@web/test-runner-commands": "^0.9.0",
50
50
  "@web/test-runner-playwright": "^0.11.1",
51
51
  "@web/test-runner-visual-regression": "^0.10.0",
52
- "element-vir": "^26.15.1",
52
+ "element-vir": "^26.17.0",
53
53
  "istanbul-smart-text-reporter": "^1.1.5",
54
- "markdown-code-example-inserter": "^3.0.3",
55
- "typedoc": "^0.28.18",
54
+ "markdown-code-example-inserter": "^3.0.5",
55
+ "typedoc": "^0.28.19",
56
56
  "typescript": "^5.9.3"
57
57
  },
58
58
  "engines": {