Call as
Platform.casting.durationSeconds(starting, ending)
Record the dependency Platform.casting.durationSeconds, then call it by that name. A namespaced call does not pass self: use a colon call or pass the object yourself.
What it does
Computes the total length of a cast or channel in seconds from the millisecond start and end times in a UnitCastingInfo or UnitChannelInfo result. Returns nil with "restricted-value" when either time is secret, "cast-time-unavailable" when either is nil, or "invalid-api-result" when a time is not a finite number, the start is negative or the end is not after the start.
Arguments
| Name | Type | What it does |
|---|---|---|
starting | number | nil | Cast start time in milliseconds (GetTime() scale times 1000). |
ending | number | nil | Cast end time in milliseconds (GetTime() scale times 1000). |
Returns
| 1 | number | nil | Total cast length in seconds, or nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason when the length is nil. |
Editions
Built In helpers are registered on every edition. What differs is the game API they read; where one is missing the helper falls back or returns nil with a reason.
It reads no game API directly.
Secret values (Retail and Forever)
On Retail and Forever the game hands addons secret values. This helper checks what it reads (addon.Platform:CanReadValue) and returns nil with a reason such as restricted-value instead of a secret it cannot compare. Treat nil as unavailable, not as false.
How the addon calls it
Platform.casting.GetUnitCastObservationrecord.durationSeconds,record.durationReason=durationSeconds(tuple[4],tuple[5])
Dependencies
finite→Platform.casting.finiteplatform(builtin:Platform/casting.lua:platform)
Source
Platform/casting.lua, line 42. Read only in game; Duplicate makes an editable copy.
Platform.casting.durationSeconds(starting, ending)
if not platform:CanReadValue(starting) or not platform:CanReadValue(ending) then return nil,'restricted-value' end
if starting==nil or ending==nil then return nil,'cast-time-unavailable' end
if not finite(starting) or not finite(ending) or starting<0 or ending<=starting then return nil,'invalid-api-result' end
return (ending-starting)/1000