From cb916208940b34aec2fff6e82dc79992aa203a61 Mon Sep 17 00:00:00 2001 From: Stephanie Yang Date: Wed, 11 Sep 2024 15:02:15 -0400 Subject: [PATCH] handle 0 value durations --- src/data/Duration/Duration.story.tsx | 4 ++++ src/data/Duration/utils.ts | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/data/Duration/Duration.story.tsx b/src/data/Duration/Duration.story.tsx index e562d874..2c0b3607 100644 --- a/src/data/Duration/Duration.story.tsx +++ b/src/data/Duration/Duration.story.tsx @@ -8,6 +8,10 @@ export default { export const Simple = () => ( + +
+ +

diff --git a/src/data/Duration/utils.ts b/src/data/Duration/utils.ts index 152b4640..f7671a2f 100644 --- a/src/data/Duration/utils.ts +++ b/src/data/Duration/utils.ts @@ -27,7 +27,9 @@ export function formatDuration(time: DurationFormatTypes, emptyValue = 'N/A') { const [valueStr, unitStr] = humanized.split(' '); const value = parseFloat(valueStr); - if (value === 1) { + if (value === 0) { + return '0 ms'; + } else if (value === 1) { return humanized; }