![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <Timespan.h>
Static Public Member Functions | |
| static FTimespan | FromDays (double Days) |
| static FTimespan | FromHours (double Hours) |
| static FTimespan | FromMicroseconds (double Microseconds) |
| static FTimespan | FromMilliseconds (double Milliseconds) |
| static FTimespan | FromMinutes (double Minutes) |
| static FTimespan | FromSeconds (double Seconds) |
| static FTimespan | MaxValue () |
| static FTimespan | MinValue () |
| static CORE_API bool | Parse (const FString &TimespanString, FTimespan &OutTimespan) |
| static double | Ratio (FTimespan Dividend, FTimespan Divisor) |
| static FTimespan | Zero () |
Protected Member Functions | |
| void CORE_API | Assign (int32 Days, int32 Hours, int32 Minutes, int32 Seconds, int32 FractionNano) |
Friends | |
| class | UObject |
| struct | Z_Construct_UScriptStruct_FTimespan_Statics |
| CORE_API FArchive & | operator<< (FArchive &Ar, FTimespan &Timespan) |
| CORE_API uint32 | GetTypeHash (const FTimespan &Timespan) |
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.
|
inline |
Default constructor (zero initialization).
|
inline |
Create and initialize a new time interval with the specified number of hours, minutes and seconds.
For better readability, consider using FromHours, FromMinutes and FromSeconds.
| Hours | The hours component. |
| Minutes | The minutes component. |
| Seconds | The seconds component. |
Create and initialize a new time interval with the specified number of days, hours, minutes and seconds.
For better readability, consider using FromDays, FromHours, FromMinutes and FromSeconds.
| Days | The days component. |
| Hours | The hours component. |
| Minutes | The minutes component. |
| Seconds | The seconds component. |
|
inline |
Create and initialize a new time interval with the specified number of days, hours, minutes and seconds.
| Days | The days component. |
| Hours | The hours component. |
| Minutes | The minutes component. |
| Seconds | The seconds component. |
| FractionNano | The fractional seconds (in nanosecond resolution). |
|
protected |
Assign the specified components to this time span.
| Days | The days component. |
| Hours | The hours component. |
| Minutes | The minutes component. |
| Seconds | The seconds component. |
| FractionNano | The fractional seconds (in nanosecond resolution). |
| bool FTimespan::ExportTextItem | ( | FString & | ValueStr, |
| FTimespan const & | DefaultValue, | ||
| UObject * | Parent, | ||
| int32 | PortFlags, | ||
| UObject * | ExportRootScope | ||
| ) | const |
Export this time span value to a string.
| ValueStr | Will hold the string value. |
| DefaultValue | The default value. |
| Parent | Not used. |
| PortFlags | Not used. |
| ExportRootScope | Not used. |
Create a time span that represents the specified number of days.
| Days | The number of days. |
Create a time span that represents the specified number of hours.
| Hours | The number of hours. |
Create a time span that represents the specified number of microseconds.
| Microseconds | The number of microseconds. |
Create a time span that represents the specified number of milliseconds.
| Milliseconds | The number of milliseconds. |
Create a time span that represents the specified number of minutes.
| Minutes | The number of minutes. |
Create a time span that represents the specified number of seconds.
| Seconds | The number of seconds. |
|
inline |
Get the days component of this time span.
|
inline |
Get a time span with the absolute value of this time span.
This method may overflow the timespan if its value is equal to MinValue.
|
inline |
Gets the fractional seconds (in microsecond resolution).
|
inline |
Gets the fractional seconds (in millisecond resolution).
|
inline |
Gets the fractional seconds (in nanosecond resolution).
|
inline |
Gets the fractional ticks (in 100 nanosecond resolution).
|
inline |
|
inline |
|
inline |
|
inline |
Get the number of ticks represented by this time span.
|
inline |
|
inline |
Get the total number of hours represented by this time span.
|
inline |
Get the total number of microseconds represented by this time span.
|
inline |
Get the total number of milliseconds represented by this time span.
|
inline |
Get the total number of minutes represented by this time span.
|
inline |
Get the total number of seconds represented by this time span.
| bool FTimespan::ImportTextItem | ( | const TCHAR *& | Buffer, |
| int32 | PortFlags, | ||
| UObject * | Parent, | ||
| FOutputDevice * | ErrorText | ||
| ) |
Import a time span value from a text buffer.
| Buffer | The text buffer to import from. |
| PortFlags | Not used. |
| Parent | Not used. |
| ErrorText | The output device for error logging. |
|
inline |
Check whether this time span is zero.
Return the minimum time span value.
The minimum time span value is slightly less than -10,675,199 days.
| bool FTimespan::NetSerialize | ( | FArchive & | Ar, |
| class UPackageMap * | Map, | ||
| bool & | bOutSuccess | ||
| ) |
Serializes this date and time for network transmission
Compare this time span with the given time span for inequality.
| Other | The time span to compare with. |
Return the result of calculating the modulus of this time span with another time span.
| Other | The time span to divide by. |
Calculate this time span modulo another.
| Other | The time span to divide by. |
Return the result of multiplying the this time span with the given scalar.
| Scalar | The scalar to multiply with. |
Multiply this time span with the given scalar.
| Scalar | The scalar to multiply with. |
Return the result of adding the given time span to this time span.
Adds the given time span to this time span.
|
inline |
Return the inverse of this time span.
The value of this time span must be greater than FTimespan::MinValue(), or else an overflow will occur.
Return the result of subtracting the given time span from this time span.
| Other | The time span to compare with. |
Subtract the given time span from this time span.
| Other | The time span to subtract. |
Return the result of dividing the this time span by the given scalar.
| Scalar | The scalar to divide by. |
Divide this time span by the given scalar.
| Scalar | The scalar to divide by. |
Check whether this time span is less than the given time span.
| Other | The time span to compare with. |
Check whether this time span is less than or equal to the given time span.
| Other | The time span to compare with. |
Compare this time span with the given time span for equality.
| Other | The time span to compare with. |
Check whether this time span is greater than the given time span.
| Other | The time span to compare with. |
Check whether this time span is greater than or equal to the given time span.
| Other | The time span to compare with. |
Convert a string to a time span.
The string must be in one of the following formats: p[d.]hh::mm::ss.fff p[d.]hh::mm::ss.uuuuuu p[d.]hh::mm::ss.nnnnnnnnn
Note that 'p' is the plus or minus sign, and the date component may be omitted for time spans that are shorter than one day.
| TimespanString | The string to convert. |
| OutTimespan | Will contain the parsed time span. |
Ratio between two time spans (handles zero values).
| Dividend | The dividend. |
| Divisor | The divisor. |
Serialize this time span from or into the specified archive.
| Ar | The archive to serialize from or into. |
| FString FTimespan::ToString | ( | ) | const |
Return the string representation of this time span using a default format.
The returned string has the following format: p[d.]hh:mm:ss.fff
Note that 'p' is the plus or minus sign, and the date component is omitted for time spans that are shorter than one day.
Examples: -42.15:11:36.457 (45 days, 15 hours, 11 minutes, 36.457 seconds in the past) +42.15:11:36.457 (45 days, 15 hours, 11 minutes, 36.457 seconds in the future) +15:11:36.457 (15 hours, 11 minutes, 36.457 seconds in the future) +00:11:36.457 (11 minutes, 36.457 seconds in the future) +00:00:36.457 (36.457 seconds in the future)
| FString FTimespan::ToString | ( | const TCHAR * | Format | ) | const |
Convert this time span to its string representation.
The following formatting codes are available: d - prints the days component D - prints the zero-padded days component (00000000..10675199) h - prints the zero-padded hours component (00..23) m - prints the zero-padded minutes component (00..59) s - prints the zero-padded seconds component (00..59) f - prints the zero-padded fractional seconds (000..999) u - prints the zero-padded fractional seconds (000000..999999) n - prints the zero-padded fractional seconds (000000000..999999999)
Depending on whether the time span is positive or negative, a plus or minus sign character will always be added in front of the generated string.
| Format | The format of the returned string. |
Get the hash for the specified time span.
| Timespan | The timespan to get the hash for. |
Serialize the given time span from or into the specified archive.
| Ar | The archive to serialize from or into. |
| Timespan | The time span value to serialize. |