Phone API Reference - Extended - util.formatDuration

Desk Phone API features described in this section are deprecated and supported only on the following models: D40, d45, d50, d60, d62, d65, d70

util.formatDuration

Description

Takes a number of seconds and returns a formatted string representing that amount of time in hours and seconds. There are two possible formats: long and short.

Basic Example: 

var timeString = util.formatDuration(parameters);

 

long format returns a string showing hours (if greater than 0), minutes (if seconds > 60) and seconds. Time durations are shown as strings (e.g., Hour, Minute) and seconds are not displayed if the number of hours > 0.

short format returns a string showing hours (if greater than 0), minutes (if seconds > 60) and seconds. Time durations are shown as letters (e.g., h for hours) and seconds are not displayed if the number of hours > 0, or if number of minutes > 10.

Parameters

Name

Required

Type

Default

Description

Name

Required

Type

Default

Description

seconds

Yes

integer

 

Length of time to be formatted.

format

No

string

short

Format of response string. Can be long or short (default).

 

Examples

util.formatDuration in all formats

// returns the string '3h, 25m' var short = util.formatDuration({     'seconds' : 12345,     'format' : 'short' });    // returns the string '3 hours, 25 minutes' var long = util.formatDuration({     'seconds' : 12345,     'format' : 'long' });

Return to Documentation Home I Return to Sangoma Support