diff --git a/docs/widgets/services/customapi.md b/docs/widgets/services/customapi.md index c392d942c..0deb8294e 100644 --- a/docs/widgets/services/customapi.md +++ b/docs/widgets/services/customapi.md @@ -62,10 +62,12 @@ widget: format: size ``` -Supported formats for the values are `text`, `number`, `float`, `percent`, `bytes`, `bitrate`, `size`, `date` and `relativeDate`. +Supported formats for the values are `text`, `number`, `float`, `percent`, `duration`, `bytes`, `bitrate`, `size`, `date` and `relativeDate`. The `dateStyle` and `timeStyle` options of the `date` format are passed directly to [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat) and the `style` and `numeric` options of `relativeDate` are passed to [Intl.RelativeTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat). +The `duration` format expects the duration to be specified in seconds. The `scale` transformation tool can be used if a conversion is required. + The `size` format will return the length of the array or string, or the number of keys in an object. This is then formatted as `number`. ## Example diff --git a/src/widgets/customapi/component.jsx b/src/widgets/customapi/component.jsx index 3f1825b25..ea187ae14 100644 --- a/src/widgets/customapi/component.jsx +++ b/src/widgets/customapi/component.jsx @@ -78,6 +78,9 @@ function formatValue(t, mapping, rawValue) { case "percent": value = t("common.percent", { value }); break; + case "duration": + value = t("common.duration", { value }); + break; case "bytes": value = t("common.bytes", { value }); break;