RealDocs

UKismetMathLibrary::BreakTimespan

function Engine Blueprint Since 4.7
#include "Kismet/KismetMathLibrary.h"
Access: public Specifiers: staticUFUNCTIONBlueprintPure

Description

Decomposes an FTimespan into its individual days, hours, minutes, seconds, and milliseconds components. Each output is the component value only, not the total accumulated value.

Caveats & Gotchas

  • For negative timespans all components will be negative or zero — e.g. a span of -1.5 hours yields Days=0, Hours=-1, Minutes=-30, Seconds=0, Milliseconds=0.
  • Sub-millisecond precision (nanoseconds) is silently discarded; use BreakTimespan2 if you need the full nanosecond fraction.

Signature

static ENGINE_API void BreakTimespan(FTimespan InTimespan, int32& Days, int32& Hours, int32& Minutes, int32& Seconds, int32& Milliseconds);

Parameters

Name Type Description Default
InTimespan FTimespan The timespan to decompose.
Days int32& Receives the days component.
Hours int32& Receives the hours component (0–23).
Minutes int32& Receives the minutes component (0–59).
Seconds int32& Receives the seconds component (0–59).
Milliseconds int32& Receives the milliseconds component (0–999).

Return Type

void

Example

Display elapsed time as H:M:S C++
int32 Days, Hours, Minutes, Seconds, Milliseconds;
UKismetMathLibrary::BreakTimespan(ElapsedTime, Days, Hours, Minutes, Seconds, Milliseconds);
FString TimeStr = FString::Printf(TEXT("%02d:%02d:%02d"), Hours + Days * 24, Minutes, Seconds);

Version History

Introduced in: 4.7

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.