Reference › Function reference › Platform

Platform.casting.remainingSeconds

dependency

Call as

Platform.casting.remainingSeconds(ending)

Record the dependency Platform.casting.remainingSeconds, 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

Converts the millisecond end time of a cast or channel into the seconds left, measured against a fresh GetTime() and clamped at zero. Returns nil with "restricted-value", "cast-time-unavailable" (nil end time), "invalid-api-result", "missing-api" or "api-error" when the end time or the clock cannot be read.

Arguments

NameTypeWhat it does
endingnumber | nilCast end time in milliseconds (GetTime() scale times 1000).

Returns

1number | nilSeconds remaining, never negative; nil when unavailable.
2string | nilReason when the result 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.

  • Not available on that edition (the reason is in the tooltip)
  • Only while Blizzard's deprecation fallbacks are on
Game APIClassic EraTBC AnniversaryClassic progressionForeverRetail
GetTimeClassic EraTBC AnniversaryClassic progressionForeverRetail

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

Dependencies

Source

Platform/casting.lua, line 23. Read only in game; Duplicate makes an editable copy.

Platform.casting.remainingSeconds(ending)
    if not platform:CanReadValue(ending) then return nil,'restricted-value' end
    if ending==nil then return nil,'cast-time-unavailable' end
    if not finite(ending) or ending<0 then return nil,'invalid-api-result' end
    if type(GetTime)~='function' then return nil,'missing-api' end
    local ok,now=pcall(GetTime)
    if not ok then return nil,'api-error' end
    if not platform:CanReadValue(now) then return nil,'restricted-value' end
    if not finite(now) or now<0 then return nil,'invalid-api-result' end
    return math.max(0,ending/1000-now)

Back to Function reference