FTimespan

Implements a time span.

Windows
MacOS
Linux

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/Misc/Timespan.h

Include

#include "Misc/Timespan.h"

Syntax

struct FTimespan

Remarks

Implements a time span.

A time span is the difference between two dates and times. For example, the time span between 12:00:00 January 1, 2000 and 18:00:00 January 2, 2000 is 30.0 hours. Time spans are measured in positive or negative ticks depending on whether the difference is measured forward or backward. Each tick has a resolution of 0.1 microseconds (= 100 nanoseconds).

In conjunction with the companion class FDateTime, time spans can be used to perform date and time based arithmetic, such as calculating the difference between two dates or adding a certain amount of time to a given date.

When initializing time span values from single components, consider using the FromHours, FromMinutes, FromSeconds, Zero, MinValue and related methods instead of calling the overloaded constructors as they will make your code easier to read and understand.

Constructors

Name Description

Public function

FTimespan()

Default constructor (no initialization).

Public function

FTimespan

(
    int64 InTicks
)

Create and initialize a new time interval with the specified number of ticks.

Public function

FTimespan

(
    int32 Hours,
    int32 Minutes,
    int32 Seconds
)

Create and initialize a new time interval with the specified number of hours, minutes and seconds.

Public function

FTimespan

(
    int32 Days,
    int32 Hours,
    int32 Minutes,
    int32 Seconds
)

Create and initialize a new time interval with the specified number of days, hours, minutes and seconds.

Public function

FTimespan

(
    int32 Days,
    int32 Hours,
    int32 Minutes,
    int32 Seconds,
    int32 FractionNano
)

Create and initialize a new time interval with the specified number of days, hours, minutes and seconds.

Functions

Name Description

Protected function

void

 

Assign

(
    int32 Days,
    int32 Hours,
    int32 Minutes,
    int32 Seconds,
    int32 FractionNano
)

Assign the specified components to this time span.

Public function Const

bool

 

ExportTextItem

(
    FString& ValueStr,
    FTimespan const& DefaultValue,
    UObject* Parent,
    int32 PortFlags,
    UObject* ExportRootScope
)

Export this time span value to a string.

Public function Static

FTimespan

 

FromDays

(
    double Days
)

Create a time span that represents the specified number of days.

Public function Static

FTimespan

 

FromHours

(
    double Hours
)

Create a time span that represents the specified number of hours.

Public function Static

FTimespan

 

FromMicroseconds

(
    double Microseconds
)

Create a time span that represents the specified number of microseconds.

Public function Static

FTimespan

 

FromMilliseconds

(
    double Milliseconds
)

Create a time span that represents the specified number of milliseconds.

Public function Static

FTimespan

 

FromMinutes

(
    double Minutes
)

Create a time span that represents the specified number of minutes.

Public function Static

FTimespan

 

FromSeconds

(
    double Seconds
)

Create a time span that represents the specified number of seconds.

Public function Const

int32

 

GetDays()

Get the days component of this time span.

Public function

FTimespan

 

GetDuration()

Get a time span with the absolute value of this time span.

Public function Const

int32

 

GetFractionMicro()

Gets the fractional seconds (in microsecond resolution).

Public function Const

int32

 

GetFractionMilli()

Gets the fractional seconds (in millisecond resolution).

Public function Const

int32

 

GetFractionNano()

Gets the fractional seconds (in nanosecond resolution).

Public function Const

int32

 

GetFractionTicks()

Gets the fractional ticks (in 100 nanosecond resolution).

Public function Const

int32

 

GetHours()

Gets the hours component of this time span.

Public function Const

int32

 

GetMinutes()

Get the minutes component of this time span.

Public function Const

int32

 

GetSeconds()

Get the seconds component of this time span.

Public function Const

int64

 

GetTicks()

Get the number of ticks represented by this time span.

Public function Const

double

 

GetTotalDays()

Get the total number of days represented by this time span.

Public function Const

double

 

GetTotalHours()

Get the total number of hours represented by this time span.

Public function Const

double

 

GetTotalMicroseconds()

Get the total number of microseconds represented by this time span.

Public function Const

double

 

GetTotalMilliseconds()

Get the total number of milliseconds represented by this time span.

Public function Const

double

 

GetTotalMinutes()

Get the total number of minutes represented by this time span.

Public function Const

double

 

GetTotalSeconds()

Get the total number of seconds represented by this time span.

Public function

bool

 

ImportTextItem

(
    const TCHAR*& Buffer,
    int32 PortFlags,
    UObject* Parent,
    FOutputDevice* ErrorText
)

Import a time span value from a text buffer.

Public function Const

bool

 

IsZero()

Check whether this time span is zero.

Public function Static

FTimespan

 

MaxValue()

Return the maximum time span value.

Public function Static

FTimespan

 

MinValue()

Return the minimum time span value.

Public function

bool

 

NetSerialize

(
    FArchive& Ar,
    UPackageMap* Map,
    bool& bOutSuccess
)

Serializes this date and time for network transmission

Public function Static

bool

 

Parse

(
    const FString& TimespanString,
    FTimespan& OutTimespan
)

Convert a string to a time span.

Public function Static

double

 

Ratio

(
    FTimespan Dividend,
    FTimespan Divisor
)

Ratio between two time spans (handles zero values).

Public function

bool

 

Serialize

(
    FArchive& Ar
)

Serialize this time span from or into the specified archive.

Public function Const

FString

 

ToString()

Return the string representation of this time span using a default format.

Public function Const

FString

 

ToString

(
    const TCHAR* Format
)

Convert this time span to its string representation.

Public function Static

FTimespan

 

Zero()

Return the zero time span value.

Operators

Name Description

Public function Const

FTimespan

 

operator-

(
    const FTimespan& Other
)

Return the result of subtracting the given time span from this time span.

Public function Const

FTimespan

 

operator-()

Return the inverse of this time span.

Public function Const

bool

 

operator!=

(
    const FTimespan& Other
)

Compare this time span with the given time span for inequality.

Public function Const

FTimespan

 

operator%

(
    const FTimespan& Other
)

Return the result of calculating the modulus of this time span with another time span.

Public function

FTimespan &

 

operator%=

(
    const FTimespan& Other
)

Calculate this time span modulo another.

Public function Const

FTimespan

 

operator*

(
    double Scalar
)

Return the result of multiplying the this time span with the given scalar.

Public function

FTimespan &

 

operator*=

(
    double Scalar
)

Multiply this time span with the given scalar.

Public function Const

FTimespan

 

operator/

(
    double Scalar
)

Return the result of dividing the this time span by the given scalar.

Public function

FTimespan &

 

operator/=

(
    double Scalar
)

Divide this time span by the given scalar.

Public function Const

FTimespan

 

operator+

(
    const FTimespan& Other
)

Return the result of adding the given time span to this time span.

Public function

FTimespan &

 

operator+=

(
    const FTimespan& Other
)

Adds the given time span to this time span.

Public function Const

bool

 

operator<

(
    const FTimespan& Other
)

Check whether this time span is less than the given time span.

Public function Const

bool

 

operator<=

(
    const FTimespan& Other
)

Check whether this time span is less than or equal to the given time span.

Public function

FTimespan &

 

operator-=

(
    const FTimespan& Other
)

Subtract the given time span from this time span.

Public function Const

bool

 

operator==

(
    const FTimespan& Other
)

Compare this time span with the given time span for equality.

Public function Const

bool

 

operator>

(
    const FTimespan& Other
)

Check whether this time span is greater than the given time span.

Public function Const

bool

 

operator>=

(
    const FTimespan& Other
)

Check whether this time span is greater than or equal to the given time span.

See Also

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss