Navigation
API > API/Runtime > API/Runtime/Core
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.
| Name | FTimespan |
| Type | struct |
| Header File | /Engine/Source/Runtime/Core/Public/Misc/Timespan.h |
| Include Path | #include "Misc/Timespan.h" |
Syntax
struct FTimespan
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FTimespan
(
int32 Hours, |
Create and initialize a new time interval with the specified number of hours, minutes and seconds. | Misc/Timespan.h | |
FTimespan
(
int32 Days, |
Create and initialize a new time interval with the specified number of days, hours, minutes and seconds. | Misc/Timespan.h | |
FTimespan
(
int32 Days, |
Create and initialize a new time interval with the specified number of days, hours, minutes and seconds. | Misc/Timespan.h | |
FTimespan
(
int64 InTicks |
Create and initialize a new time interval with the specified number of ticks. | Misc/Timespan.h | |
FTimespan () |
Default constructor (zero initialization). | Misc/Timespan.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Ticks | int64 | The time span value in 100 nanoseconds resolution. | Misc/Timespan.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
bool ExportTextItem
(
FString& ValueStr, |
Export this time span value to a string. | Misc/Timespan.h | |
int32 GetDays() |
Get the days component of this time span. | Misc/Timespan.h | |
| Get a time span with the absolute value of this time span. | Misc/Timespan.h | ||
int32 GetFractionMicro () |
Gets the fractional seconds (in microsecond resolution). | Misc/Timespan.h | |
int32 GetFractionMilli () |
Gets the fractional seconds (in millisecond resolution). | Misc/Timespan.h | |
int32 GetFractionNano() |
Gets the fractional seconds (in nanosecond resolution). | Misc/Timespan.h | |
int32 GetFractionTicks() |
Gets the fractional ticks (in 100 nanosecond resolution). | Misc/Timespan.h | |
int32 GetHours () |
Gets the hours component of this time span. | Misc/Timespan.h | |
int32 GetMinutes () |
Get the minutes component of this time span. | Misc/Timespan.h | |
int32 GetSeconds () |
Get the seconds component of this time span. | Misc/Timespan.h | |
int64 GetTicks() |
Get the number of ticks represented by this time span. | Misc/Timespan.h | |
double GetTotalDays () |
Get the total number of days represented by this time span. | Misc/Timespan.h | |
double GetTotalHours () |
Get the total number of hours represented by this time span. | Misc/Timespan.h | |
double GetTotalMicroseconds () |
Get the total number of microseconds represented by this time span. | Misc/Timespan.h | |
double GetTotalMilliseconds () |
Get the total number of milliseconds represented by this time span. | Misc/Timespan.h | |
double GetTotalMinutes () |
Get the total number of minutes represented by this time span. | Misc/Timespan.h | |
double GetTotalSeconds () |
Get the total number of seconds represented by this time span. | Misc/Timespan.h | |
bool ImportTextItem
(
const TCHAR*& Buffer, |
Import a time span value from a text buffer. | Misc/Timespan.h | |
bool IsZero () |
Check whether this time span is zero. | Misc/Timespan.h | |
bool NetSerialize
(
FArchive& Ar, |
Serializes this date and time for network transmission | Misc/Timespan.h | |
bool Serialize
(
FArchive& Ar |
Serialize this time span from or into the specified archive. | Misc/Timespan.h | |
| Return the string representation of this time span using a default format. | Misc/Timespan.h | ||
| Convert this time span to its string representation. | Misc/Timespan.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void Assign
(
int32 Days, |
Assign the specified components to this time span. | Misc/Timespan.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Create a time span that represents the specified number of days. | Misc/Timespan.h | ||
| Create a time span that represents the specified number of hours. | Misc/Timespan.h | ||
static FTimespan FromMicroseconds
(
double Microseconds |
Create a time span that represents the specified number of microseconds. | Misc/Timespan.h | |
static FTimespan FromMilliseconds
(
double Milliseconds |
Create a time span that represents the specified number of milliseconds. | Misc/Timespan.h | |
static FTimespan FromMinutes
(
double Minutes |
Create a time span that represents the specified number of minutes. | Misc/Timespan.h | |
static FTimespan FromSeconds
(
double Seconds |
Create a time span that represents the specified number of seconds. | Misc/Timespan.h | |
| Return the maximum time span value. | Misc/Timespan.h | ||
| Return the minimum time span value. | Misc/Timespan.h | ||
| Convert a string to a time span. | Misc/Timespan.h | ||
| Ratio between two time spans (handles zero values). | Misc/Timespan.h | ||
| Return the zero time span value. | Misc/Timespan.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Return the result of subtracting the given time span from this time span. | Misc/Timespan.h | ||
FTimespan operator-() |
Return the inverse of this time span. | Misc/Timespan.h | |
bool operator!=
(
const FTimespan& Other |
Compare this time span with the given time span for inequality. | Misc/Timespan.h | |
| Return the result of calculating the modulus of this time span with another time span. | Misc/Timespan.h | ||
| Calculate this time span modulo another. | Misc/Timespan.h | ||
FTimespan operator*
(
double Scalar |
Return the result of multiplying the this time span with the given scalar. | Misc/Timespan.h | |
FTimespan & operator*=
(
double Scalar |
Multiply this time span with the given scalar. | Misc/Timespan.h | |
FTimespan operator/
(
double Scalar |
Return the result of dividing the this time span by the given scalar. | Misc/Timespan.h | |
FTimespan & operator/=
(
double Scalar |
Divide this time span by the given scalar. | Misc/Timespan.h | |
| Return the result of adding the given time span to this time span. | Misc/Timespan.h | ||
| Adds the given time span to this time span. | Misc/Timespan.h | ||
| Subtract the given time span from this time span. | Misc/Timespan.h | ||
bool operator==
(
const FTimespan& Other |
Compare this time span with the given time span for equality. | Misc/Timespan.h | |
bool operator>
(
const FTimespan& Other |
Check whether this time span is greater than the given time span. | Misc/Timespan.h | |
bool operator>=
(
const FTimespan& Other |
Check whether this time span is greater than or equal to the given time span. | Misc/Timespan.h |