Humanize ISO8601 duration

Grafana Cloud v10.2.0-62263 (c4fefd8da9)

Is there a possibiliy to format (humanize) a ISO8601 duration value?

I’m using the Infinity datasource to retrieve information about an Azure Service Bus Queue via Azure REST API. Some of the values are formatted as ISO8601 duration value. I can’t find a solution to format (humanize) these values in a dashboard.

I have the following data which should be formatted as follows:

PT1M - 1 minute
PT1M35S - 1 minute 35 seconds
P10675199DT2H48M5.4775807S - unbounded

The last one is the “undefined” value, im my case it should be formatted as “unbounded”.

Check this out using jsonata.

https://try.jsonata.org/E-CE7gqfX

Thanks alot to pointing me in the right direction. At the end I use the following solution:

(
    $humanize := function($x) {(

        $matches := $match($x, /(-)?P(?:([.,\d]+)Y)?(?:([.,\d]+)M)?(?:([.,\d]+)W)?(?:([.,\d]+)D)?T(?:([.,\d]+)H)?(?:([.,\d]+)M)?(?:([.,\d]+)S)?/);
        $result := "";
        $days := $matches.groups[4];
        $hours := $matches.groups[5];
        $minutes := $matches.groups[6];
        $seconds := $matches.groups[7];

        $result := $days != null ? $days & " day" : "";
        $result := $hours != null ? $result & " " & $hours & " h" : "";
        $result := $minutes != null ? $result & " " & $minutes & " min" : $result;
        $result := $seconds != null ? $result & " " & $seconds & " sec" : $result;

        $result := $days = "10675199" ? "unbounded" : $result;

        $trim($result);
    )};

    $map($, function($v, $i, $a) {
        {
            "a": $humanize($v.a) ,
            "b":  $humanize($v.b),
            "c":  $humanize($v.c),
            "d":  $humanize($v.d),
            "e":  $humanize($v.e),
            "f":  $humanize($v.f)
        }
    })
)