Implements a date and time. 更多...
#include <DateTime.h>
Public 成员函数 | |
| CORE_API bool | ExportTextItem (FString &ValueStr, FDateTime const &DefaultValue, UObject *Parent, int32 PortFlags, UObject *ExportRootScope) const |
| Exports the date and time value to a string. 更多... | |
| FDateTime () | |
| Default constructor (no initialization). | |
| CORE_API | FDateTime (int32 Year, int32 Month, int32 Day, int32 Hour=0, int32 Minute=0, int32 Second=0, int32 Millisecond=0) |
| Creates and initializes a new instance with the specified year, month, day, hour, minute, second and millisecond. 更多... | |
| FDateTime (int64 InTicks) | |
| Creates and initializes a new instance with the specified number of ticks. 更多... | |
| FDateTime | GetDate () const |
| Gets the date part of this date. 更多... | |
| CORE_API void | GetDate (int32 &OutYear, int32 &OutMonth, int32 &OutDay) const |
| Gets the date components of this date. 更多... | |
| CORE_API int32 | GetDay () const |
| Gets this date's day part (1 to 31). 更多... | |
| CORE_API EDayOfWeek | GetDayOfWeek () const |
| Calculates this date's day of the week (Sunday - Saturday). 更多... | |
| CORE_API int32 | GetDayOfYear () const |
| Gets this date's day of the year. 更多... | |
| int32 | GetHour () const |
| Gets this date's hour part in 24-hour clock format (0 to 23). 更多... | |
| CORE_API int32 | GetHour12 () const |
| Gets this date's hour part in 12-hour clock format (1 to 12). 更多... | |
| double | GetJulianDay () const |
| Returns the Julian Day for this date. 更多... | |
| int32 | GetMillisecond () const |
| Gets this date's millisecond part (0 to 999). 更多... | |
| int32 | GetMinute () const |
| Gets this date's minute part (0 to 59). 更多... | |
| double | GetModifiedJulianDay () const |
| Returns the Modified Julian day. 更多... | |
| CORE_API int32 | GetMonth () const |
| Gets this date's the month part (1 to 12). 更多... | |
| EMonthOfYear | GetMonthOfYear () const |
| Gets the date's month of the year (January to December). 更多... | |
| int32 | GetSecond () const |
| Gets this date's second part. 更多... | |
| int64 | GetTicks () const |
| Gets this date's representation as number of ticks. 更多... | |
| FTimespan | GetTimeOfDay () const |
| Gets the time elapsed since midnight of this date. 更多... | |
| CORE_API int32 | GetYear () const |
| Gets this date's year part. 更多... | |
| CORE_API bool | ImportTextItem (const TCHAR *&Buffer, int32 PortFlags, UObject *Parent, FOutputDevice *ErrorText) |
| Imports a date and time value from a text buffer. 更多... | |
| bool | IsAfternoon () const |
| Gets whether this date's time is in the afternoon. 更多... | |
| bool | IsMorning () const |
| Gets whether this date's time is in the morning. 更多... | |
| CORE_API bool | NetSerialize (FArchive &Ar, class UPackageMap *Map, bool &bOutSuccess) |
| Serializes this date and time for network transmission | |
| bool | operator!= (const FDateTime &Other) const |
| Compares this date with the given date for inequality. 更多... | |
| FDateTime & | operator+ (const FDateTime &Other) |
| Adds the time from the given date to this date. 更多... | |
| FDateTime | operator+ (const FTimespan &Other) const |
| Returns result of adding the given time span to this date. 更多... | |
| FDateTime & | operator+= (const FTimespan &Other) |
| Adds the given time span to this date. 更多... | |
| FTimespan | operator- (const FDateTime &Other) const |
| Returns time span between this date and the given date. 更多... | |
| FDateTime | operator- (const FTimespan &Other) const |
| Returns result of subtracting the given time span from this date. 更多... | |
| FDateTime & | operator-= (const FTimespan &Other) |
| Subtracts the given time span from this date. 更多... | |
| bool | operator< (const FDateTime &Other) const |
| Checks whether this date is less than the given date. 更多... | |
| bool | operator<= (const FDateTime &Other) const |
| Checks whether this date is less than or equal to the given date. 更多... | |
| bool | operator== (const FDateTime &Other) const |
| Compares this date with the given date for equality. 更多... | |
| bool | operator> (const FDateTime &Other) const |
| Checks whether this date is greater than the given date. 更多... | |
| bool | operator>= (const FDateTime &Other) const |
| Checks whether this date is greater than or equal to the date span. 更多... | |
| CORE_API bool | Serialize (FArchive &Ar) |
| Serializes this date and time from or into the specified archive. 更多... | |
| CORE_API FString | ToHttpDate () const |
| Returns the RFC 1123 string representation of the FDateTime. 更多... | |
| CORE_API FString | ToIso8601 () const |
| Returns the ISO-8601 string representation of the FDateTime. 更多... | |
| CORE_API FString | ToString () const |
| Returns the string representation of this date using a default format. 更多... | |
| CORE_API FString | ToString (const TCHAR *Format) const |
| Returns the string representation of this date. 更多... | |
| CORE_API int64 | ToUnixTimestamp () const |
| Returns this date as the number of seconds since the Unix Epoch (January 1st of 1970). 更多... | |
静态 Public 成员函数 | |
| static CORE_API int32 | DaysInMonth (int32 Year, int32 Month) |
| Gets the number of days in the year and month. 更多... | |
| static CORE_API int32 | DaysInYear (int32 Year) |
| Gets the number of days in the given year. 更多... | |
| static FDateTime | FromJulianDay (double JulianDay) |
| Returns the proleptic Gregorian date for the given Julian Day. 更多... | |
| static FDateTime | FromUnixTimestamp (int64 UnixTime) |
| Returns the date from Unix time (seconds from midnight 1970-01-01) 更多... | |
| static CORE_API bool | IsLeapYear (int32 Year) |
| Checks whether the given year is a leap year. 更多... | |
| static FDateTime | MaxValue () |
| Returns the maximum date value. 更多... | |
| static FDateTime | MinValue () |
| Returns the minimum date value. 更多... | |
| static CORE_API FDateTime | Now () |
| Gets the local date and time on this computer. 更多... | |
| static CORE_API bool | Parse (const FString &DateTimeString, FDateTime &OutDateTime) |
| Converts a string to a date and time. 更多... | |
| static CORE_API bool | ParseHttpDate (const FString &HttpDate, FDateTime &OutDateTime) |
| Parses a date string in HTTP-date format (rfc1123-date | rfc850-date | asctime-date) https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1 更多... | |
| static CORE_API bool | ParseIso8601 (const TCHAR *DateTimeString, FDateTime &OutDateTime) |
| Parses a date string in ISO-8601 format. 更多... | |
| static FDateTime | Today () |
| Gets the local date on this computer. 更多... | |
| static CORE_API FDateTime | UtcNow () |
| Gets the UTC date and time on this computer. 更多... | |
| static CORE_API bool | Validate (int32 Year, int32 Month, int32 Day, int32 Hour, int32 Minute, int32 Second, int32 Millisecond) |
| Validates the given components of a date and time value. 更多... | |
静态 Protected 属性 | |
| static const int32 | DaysPerMonth [] |
| Holds the days per month in a non-leap year. | |
| static const int32 | DaysToMonth [] |
| Holds the cumulative days per month in a non-leap year. | |
友元 | |
| CORE_API uint32 | GetTypeHash (const FDateTime &DateTime) |
| Gets the hash for the specified date and time. 更多... | |
| CORE_API FArchive & | operator<< (FArchive &Ar, FDateTime &DateTime) |
| Serializes the given date and time from or into the specified archive. 更多... | |
| CORE_API void | operator<< (FStructuredArchive::FSlot Slot, FDateTime &DateTime) |
| Serializes the given date and time from or into the specified structured archive slot. 更多... | |
Implements a date and time.
Values of this type represent dates and times between Midnight 00:00:00, January 1, 0001 and Midnight 23:59:59.9999999, December 31, 9999 in the Gregorian calendar. Internally, the time values are stored in ticks of 0.1 microseconds (= 100 nanoseconds) since January 1, 0001.
To retrieve the current local date and time, use the FDateTime.Now() method. To retrieve the current UTC time, use the FDateTime.UtcNow() method instead.
This class also provides methods to convert dates and times from and to string representations, calculate the number of days in a given month and year, check for leap years and determine the time of day, day of week and month of year of a given date and time.
The companion struct FTimespan is provided for enabling date and time based arithmetic, such as calculating the difference between two dates or adding a certain amount of time to a given date.
Ranges of dates and times can be represented by the FDateRange class.
|
inline |
Creates and initializes a new instance with the specified number of ticks.
| Ticks | The ticks representing the date and time. |
| CORE_API FDateTime::FDateTime | ( | int32 | Year, |
| int32 | Month, | ||
| int32 | Day, | ||
| int32 | Hour = 0, |
||
| int32 | Minute = 0, |
||
| int32 | Second = 0, |
||
| int32 | Millisecond = 0 |
||
| ) |
Creates and initializes a new instance with the specified year, month, day, hour, minute, second and millisecond.
| Year | The year. |
| Month | The month. |
| Day | The day. |
| Hour | The hour (optional). |
| Minute | The minute (optional). |
| Second | The second (optional). |
| Millisecond | The millisecond (optional). |
|
static |
Gets the number of days in the year and month.
| Year | The year. |
| Month | The month. |
|
static |
| CORE_API bool FDateTime::ExportTextItem | ( | FString & | ValueStr, |
| FDateTime const & | DefaultValue, | ||
| UObject * | Parent, | ||
| int32 | PortFlags, | ||
| UObject * | ExportRootScope | ||
| ) | const |
Exports the date and time value to a string.
| ValueStr | Will hold the string value. |
| DefaultValue | The default value. |
| Parent | Not used. |
| PortFlags | Not used. |
| ExportRootScope | Not used. |
|
inlinestatic |
Returns the proleptic Gregorian date for the given Julian Day.
| JulianDay | The Julian Day. |
|
inlinestatic |
Returns the date from Unix time (seconds from midnight 1970-01-01)
| UnixTime | Unix time (seconds from midnight 1970-01-01) |
|
inline |
Gets the date part of this date.
The time part is truncated and becomes 00:00:00.000.
| CORE_API void FDateTime::GetDate | ( | int32 & | OutYear, |
| int32 & | OutMonth, | ||
| int32 & | OutDay | ||
| ) | const |
Gets the date components of this date.
| OutYear | Will contain the year. |
| OutMonth | Will contain the number of the month (1-12). |
| OutDay | Will contain the number of the day (1-31). |
| CORE_API int32 FDateTime::GetDay | ( | ) | const |
| CORE_API EDayOfWeek FDateTime::GetDayOfWeek | ( | ) | const |
Calculates this date's day of the week (Sunday - Saturday).
| CORE_API int32 FDateTime::GetDayOfYear | ( | ) | const |
|
inline |
Gets this date's hour part in 24-hour clock format (0 to 23).
| CORE_API int32 FDateTime::GetHour12 | ( | ) | const |
|
inline |
Returns the Julian Day for this date.
The Julian Day is the number of days since the inception of the Julian calendar at noon on Monday, January 1, 4713 B.C.E. The minimum Julian Day that can be represented in FDateTime is 1721425.5, which corresponds to Monday, January 1, 0001 in the Gregorian calendar.
|
inline |
|
inline |
|
inline |
Returns the Modified Julian day.
The Modified Julian Day is calculated by subtracting 2400000.5, which corresponds to midnight UTC on November 17, 1858 in the Gregorian calendar.
| CORE_API int32 FDateTime::GetMonth | ( | ) | const |
|
inline |
Gets the date's month of the year (January to December).
|
inline |
|
inline |
Gets this date's representation as number of ticks.
|
inline |
Gets the time elapsed since midnight of this date.
| Time | of day since midnight. |
| CORE_API int32 FDateTime::GetYear | ( | ) | const |
| CORE_API bool FDateTime::ImportTextItem | ( | const TCHAR *& | Buffer, |
| int32 | PortFlags, | ||
| UObject * | Parent, | ||
| FOutputDevice * | ErrorText | ||
| ) |
Imports a date and time 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 |
Gets whether this date's time is in the afternoon.
| true | if it is in the afternoon, false otherwise. |
|
static |
Checks whether the given year is a leap year.
A leap year is a year containing one additional day in order to keep the calendar synchronized with the astronomical year. All years divisible by 4, but not divisible by 100 - except if they are also divisible by 400 - are leap years.
| Year | The year to check. |
|
inline |
Gets whether this date's time is in the morning.
| true | if it is in the morning, false otherwise. |
|
inlinestatic |
Returns the maximum date value.
The maximum date value is December 31, 9999, 23:59:59.9999999.
|
inlinestatic |
|
static |
Gets the local date and time on this computer.
This method takes into account the local computer's time zone and daylight saving settings. For time zone independent time comparisons, and when comparing times between different computers, please use UtcNow() instead.
|
inline |
Compares this date with the given date for inequality.
| other | The date to compare with. |
Returns result of adding the given time span to this date.
Returns time span between this date and the given date.
Returns result of subtracting the given time span from this date.
|
inline |
Checks whether this date is less than the given date.
| other | The date to compare with. |
|
inline |
Checks whether this date is less than or equal to the given date.
| other | The date to compare with. |
|
inline |
Compares this date with the given date for equality.
| other | The date to compare with. |
|
inline |
Checks whether this date is greater than the given date.
| other | The date to compare with. |
|
inline |
Checks whether this date is greater than or equal to the date span.
| other | The date to compare with. |
|
static |
Converts a string to a date and time.
Currently, the string must be in the format written by either FDateTime.ToString() or FTimeStamp.TimestampToFString(). Other formats are not supported at this time.
| DateTimeString | The string to convert. |
| OutDateTime | Will contain the parsed date and time. |
|
static |
Parses a date string in HTTP-date format (rfc1123-date | rfc850-date | asctime-date) https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
HTTP-date = rfc1123-date | rfc850-date | asctime-date rfc1123-date = wkday "," SP date1 SP time SP "GMT" rfc850-date = weekday "," SP date2 SP time SP "GMT" asctime-date = wkday SP date3 SP time SP 4DIGIT date1 = 2DIGIT SP month SP 4DIGIT ; day month year (e.g., 02 Jun 1982) date2 = 2DIGIT "-" month "-" 2DIGIT ; day-month-year (e.g., 02-Jun-82) date3 = month SP (2DIGIT | (SP 1DIGIT)) ; month day (e.g., Jun 2) time = 2DIGIT ":" 2DIGIT ":" 2DIGIT ; 00:00:00 - 23:59:59 wkday = "Mon" | "Tue" | "Wed" | "Thu" | "Fri" | "Sat" | "Sun" weekday = "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday" month = "Jan" | "Feb" | "Mar" | "Apr" | "May" | "Jun" | "Jul" | "Aug" | "Sep" | "Oct" | "Nov" | "Dec"
| HttpDate | The string to be parsed |
| OutDateTime | FDateTime object (assumes UTC) corresponding to the input string. |
|
static |
Parses a date string in ISO-8601 format.
| DateTimeString | The string to be parsed |
| OutDateTime | FDateTime object (in UTC) corresponding to the input string (which may have been in any timezone). |
| CORE_API bool FDateTime::Serialize | ( | FArchive & | Ar | ) |
Serializes this date and time from or into the specified archive.
| Ar | The archive to serialize from or into. |
|
inlinestatic |
| CORE_API FString FDateTime::ToHttpDate | ( | ) | const |
| CORE_API FString FDateTime::ToIso8601 | ( | ) | const |
| CORE_API FString FDateTime::ToString | ( | ) | const |
| CORE_API FString FDateTime::ToString | ( | const TCHAR * | Format | ) | const |
|
inline |
Returns this date as the number of seconds since the Unix Epoch (January 1st of 1970).
|
static |
Gets the UTC date and time on this computer.
This method returns the Coordinated Universal Time (UTC), which does not take the local computer's time zone and daylight savings settings into account. It should be used when comparing dates and times that should be independent of the user's locale. To get the date and time in the current locale, use Now() instead.
This method will use an estimate if USE_ESTIMATED_UTCNOW is 1. To calculate the estimate it will initialize a base reference time and keep track of the offset from that time with FPlatformTime::Cycles64().
This is appropriate for platforms whose implementations of FPlatformTime::UtcTime are expensive. To use, enable bUseEstimatedUtcNow in TargetRules. The rebase time is stored in time.EstimatedUtcNowRebaseTimeSeconds (default setting is 600 seconds).
|
static |
Validates the given components of a date and time value.
The allow ranges for the components are: Year: 1 - 9999 Month: 1 - 12 Day: 1 - DaysInMonth(Month) Hour: 0 - 23 Minute: 0 - 59 Second: 0 - 59 Millisecond: 0 - 999
|
friend |
Gets the hash for the specified date and time.
| DateTime | The date and time to get the hash for. |
Serializes the given date and time from or into the specified archive.
| Ar | The archive to serialize from or into. |
| DateTime | The date and time value to serialize. |
|
friend |
Serializes the given date and time from or into the specified structured archive slot.
| Slot | The structured archive slot to serialize from or into. |
| DateTime | The date and time value to serialize. |