The Timespan data type
A Timespan value represents a duration of time. The Timespan data type matches a specified range of durations and
includes all values within the given range. The default represents a positive or negative infinite duration. A Timespan value can be specified with strings or
numbers in various forms. The type takes up to two parameters.
Parameters
The full signature for Timespan is:
Timespan[ (<TIMESPAN START OR LENGTH>, (<TIMESPAN END>)) ]
| Position | Parameter | Data type | Default value | Description |
|---|---|---|---|---|
| 1 | Timespan start or length | String, Float,
Integer, or default | default (negative infinity in a span) | If only one parameter is passed, it is the length of the
timespan. If two parameters are passed, this is the start or
from value in a time range. |
| 2 | Timespan end | String, Float,
Integer, or default | default (positive infinity) or
none if only one value passed. | The end or to value in a time range.
|
Timespan values are interpreted depending on their format: A String in the format
D-HH:MM:SSrepresents a duration ofDdays,HHhours,MMminutes, andSSseconds.An Integer or Float represents a duration in seconds.
Timespan defined as a range (two parameters) matches
any Timespan durations that can fit within that
range. If either end of a range is defined
as default (infinity), it is an open range,
while any other range is a closed range. The range is inclusive.
In other words, Timespan[2] matches a duration of two
seconds, but Timespan[0, 2] can match anyTimespan from zero to two seconds, inclusive.
The Timespan type is not enumerable.
For information about converting values of other types to Timespan
using the new function, or for converting a
Timespan to a String using
strftime, see the function reference documentation.
Examples:
-
Timespan[2]Matches a
Timespanvalue of 2 seconds. -
Timespan[77.3]Matches a
Timespanvalue of 1 minute, 17 seconds, and 300 milliseconds (77.3 seconds). -
Timespan['1-00:00:00', '2-00:00:00']Matches a closed range of
Timespanvalues between 1 and 2 days.