UKismetMathLibrary::GetDuration
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Returns the absolute value (magnitude) of A as a new non-negative FTimespan. Despite the name, this is not a 'total duration' accessor — it is equivalent to Abs(A).
Caveats & Gotchas
- • The name 'GetDuration' is misleading — it does not return how long something took; it returns the absolute value of the timespan. Use it when you need the magnitude of a potentially negative time difference.
- • FTimespan::MinValue() cannot be negated safely in two's-complement int64 — passing it produces undefined behavior; treat it as an edge case to avoid.
Signature
static UE_INL_API FTimespan GetDuration( FTimespan A ); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| A | FTimespan | The timespan whose absolute value is returned. | — |
Return Type
FTimespan Example
Get the magnitude of a time difference regardless of order C++
FTimespan Diff = TimeA - TimeB; // may be negative
FTimespan AbsDiff = UKismetMathLibrary::GetDuration(Diff);
// AbsDiff is always >= FTimespan::Zero() Tags
Version History
Introduced in: 4.7
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?