---
url: "https://vueda.dev/v3/reference/api/js/utils/duration/functions/normalizeDuration.md"
title: "normalizeDuration"
---

# normalizeDuration

## Overview

Normalizes any serialized duration into a sign plus whole days, hours, minutes, and
seconds, so a display component can word it without knowing which serializer sent it.

Two shapes arrive from the server. DRF's `DurationField` sends a Django duration string
(`[-]D HH:MM:SS[.ffffff]`, days omitted when zero), where a negative duration carries its
sign on the day count while the clock part stays positive, so `-1 23:00:00` means minus
one hour. VUEDA's `DurationSecondsField` sends a number of seconds instead. Both reduce
to a total, which this function then splits back into units.

Sub-second precision is dropped: the seconds component truncates toward zero.

## Signature

`normalizeDuration(value)`

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| <span id="param-value">value</span> | `string \| number` | yes | A Django duration string, a number of seconds, or an empty value. |

### Returns

`The normalized parts, or null when the value is empty or unparseable.`

## Source

`client/lib/utils/duration.js:68`
