docs-v2/content/flux/v0/stdlib/experimental/array/toduration.md

1.8 KiB

title description menu weight flux/v0/tags introduced
array.toDuration() function `array.toDuration()` converts all values in an array to durations.
flux_v0_ref
name parent identifier
array.toDuration experimental/array experimental/array/toDuration
201
type-conversions
0.184.0

array.toDuration() converts all values in an array to durations.

Supported array types and behaviors

  • [int] (parsed as nanosecond epoch timestamps)
  • [string] with values that use duration literal representation.
  • [uint] (parsed as nanosecond epoch timestamps)
Function type signature
(<-arr: [A]) => [duration]

{{% caption %}} For more information, see Function type signatures. {{% /caption %}}

Parameters

arr

Array of values to convert. Default is the piped-forward array (<-).

Examples

Convert an array of integers to durations

import "experimental/array"

arr = [80000000000, 56000000000, 132000000000]

array.toDuration(arr: arr)// Returns [1m20s, 56s, 2m12s]