Skip to content

Commit

Permalink
handle 0 value durations
Browse files Browse the repository at this point in the history
  • Loading branch information
steppy452 committed Sep 11, 2024
1 parent 8b3df2c commit cb91620
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/data/Duration/Duration.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export default {

export const Simple = () => (
<Fragment>
<Duration value="0" />
<br />
<Duration value="1" />
<br />
<Duration value="125" />
<br />
<Duration value="256" />
Expand Down
4 changes: 3 additions & 1 deletion src/data/Duration/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit cb91620

Please sign in to comment.