aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/components/DateString/compactDateString.ts3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/components/DateString/compactDateString.ts b/src/components/DateString/compactDateString.ts
index 8bff4b7..29c3c44 100644
--- a/src/components/DateString/compactDateString.ts
+++ b/src/components/DateString/compactDateString.ts
@@ -15,13 +15,14 @@ const resolve = (value: number, metricIndex = 0): string => {
const nextMetric = metrics[metricIndex + 1];
const newValue = value / metric.ratio;
- if (newValue < nextMetric.ratio * PRECISION) {
+ if (newValue < nextMetric?.ratio * PRECISION || !nextMetric) {
const rounded = Math.round(newValue);
const isPlural = rounded > 1;
const count = isPlural ? rounded : 'a';
const ending = isPlural ? 's' : '';
return `${count} ${metric.name}${ending} ago`;
}
+
return resolve(newValue, metricIndex + 1);
};