Ark Server API (ASA) - Wiki
|
#include <DateTime.h>
Static Public Member Functions | |
static int32 | DaysInMonth (int32 Year, int32 Month) |
static int32 | DaysInYear (int32 Year) |
static FDateTime | FromJulianDay (double JulianDay) |
static FDateTime | FromUnixTimestamp (int64 UnixTime) |
static bool | IsLeapYear (int32 Year) |
static FDateTime | MaxValue () |
static FDateTime | MinValue () |
static FDateTime | Now () |
static bool | Parse (const FString &DateTimeString, FDateTime &OutDateTime) |
static bool | ParseHttpDate (const FString &HttpDate, FDateTime &OutDateTime) |
static bool | ParseIso8601 (const TCHAR *DateTimeString, FDateTime &OutDateTime) |
static FDateTime | Today () |
static FDateTime | UtcNow () |
static bool | Validate (int32 Year, int32 Month, int32 Day, int32 Hour, int32 Minute, int32 Second, int32 Millisecond) |
Static Protected Attributes | |
static const int32 | DaysPerMonth [] |
static const int32 | DaysToMonth [] |
static const TCHAR * | ShortDayNames [] |
static const TCHAR * | LongDayNames [] |
static const TCHAR * | ShortMonthNames [] |
static const TCHAR * | LongMonthNames [] |
Private Attributes | |
int64 | Ticks |
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.
Definition at line 75 of file DateTime.h.
|
inline |
Default constructor (zero initialization).
Definition at line 80 of file DateTime.h.
|
inline |
Creates and initializes a new instance with the specified number of ticks.
InTicks | The ticks representing the date and time. |
Definition at line 89 of file DateTime.h.
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). |
Gets the number of days in the year and month.
Year | The year. |
Month | The month. |
Gets the number of days in the given year.
Year | The year. |
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. |
Returns the proleptic Gregorian date for the given Julian Day.
JulianDay | The Julian Day. |
Definition at line 597 of file DateTime.h.
Returns the date from Unix time (seconds from midnight 1970-01-01)
UnixTime | Unix time (seconds from midnight 1970-01-01) |
Definition at line 609 of file DateTime.h.
|
inline |
Gets the date part of this date.
The time part is truncated and becomes 00:00:00.000.
Definition at line 261 of file DateTime.h.
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). |
int32 FDateTime::GetDay | ( | ) | const |
EDayOfWeek FDateTime::GetDayOfWeek | ( | ) | const |
Calculates this date's day of the week (Sunday - Saturday).
int32 FDateTime::GetDayOfYear | ( | ) | const |
Gets this date's day of the year.
|
inline |
Gets this date's hour part in 24-hour clock format (0 to 23).
Definition at line 305 of file DateTime.h.
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.
Definition at line 328 of file DateTime.h.
|
inline |
|
inline |
Gets this date's minute part (0 to 59).
Definition at line 364 of file DateTime.h.
|
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.
Definition at line 342 of file DateTime.h.
int32 FDateTime::GetMonth | ( | ) | const |
|
inline |
Gets the date's month of the year (January to December).
Definition at line 383 of file DateTime.h.
|
inline |
|
inline |
Gets this date's representation as number of ticks.
Definition at line 404 of file DateTime.h.
|
inline |
Gets the time elapsed since midnight of this date.
Definition at line 415 of file DateTime.h.
int32 FDateTime::GetYear | ( | ) | const |
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.
Definition at line 446 of file DateTime.h.
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.
Definition at line 457 of file DateTime.h.
Returns the maximum date value.
The maximum date value is December 31, 9999, 23:59:59.9999999.
Definition at line 633 of file DateTime.h.
Returns the minimum date value.
The minimum date value is January 1, 0001, 00:00:00.0.
Definition at line 645 of file DateTime.h.
bool FDateTime::NetSerialize | ( | FArchive & | Ar, |
class UPackageMap * | Map, | ||
bool & | bOutSuccess ) |
Serializes this date and time for network transmission
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.
Compares this date with the given date for inequality.
Other | The date to compare with. |
Definition at line 190 of file DateTime.h.
Returns result of adding the given time span to this date.
Definition at line 114 of file DateTime.h.
Adds the given time span to this date.
Definition at line 125 of file DateTime.h.
Returns time span between this date and the given date.
Definition at line 144 of file DateTime.h.
Returns result of subtracting the given time span from this date.
Definition at line 155 of file DateTime.h.
Subtracts the given time span from this date.
Definition at line 166 of file DateTime.h.
Checks whether this date is less than the given date.
Other | The date to compare with. |
Definition at line 223 of file DateTime.h.
Checks whether this date is less than or equal to the given date.
Other | The date to compare with. |
Definition at line 234 of file DateTime.h.
Compares this date with the given date for equality.
Other | The date to compare with. |
Definition at line 179 of file DateTime.h.
Checks whether this date is greater than the given date.
Other | The date to compare with. |
Definition at line 201 of file DateTime.h.
Checks whether this date is greater than or equal to the date span.
Other | The date to compare with. |
Definition at line 212 of file DateTime.h.
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. |
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). |
Serializes this date and time from or into the specified archive.
Ar | The archive to serialize from or into. |
Gets the local date on this computer.
The time component is set to 00:00:00
Definition at line 716 of file DateTime.h.
Returns the string representation of this date.
Uses strftime-like syntax: a - Weekday, eg) Sun A - Weekday, eg) Sunday w - Weekday, 0-6 (Sunday is 0) y - Year, YY Y - Year, YYYY b - Month, eg) Jan B - Month, eg) January m - Month, 01-12 d - Day, 01-31 e - Day, 1-31 l - 12h Hour, 1-12 I - 12h Hour, 01-12 H - 24h Hour, 00-23 M - Minute, 00-59 S - Second, 00-60 p - AM or PM P - am or PM j - Day of the Year, 001-366
Format | The format of the returned string. |
FString FDateTime::ToHttpDate | ( | ) | const |
Returns the RFC 1123 string representation of the FDateTime.
The resulting string assumes that the FDateTime is in UTC.
FString FDateTime::ToIso8601 | ( | ) | const |
Returns the ISO-8601 string representation of the FDateTime.
The resulting string assumes that the FDateTime is in UTC.
FString FDateTime::ToString | ( | ) | const |
Returns the string representation of this date.
ToString uses a non-standard format syntax (see below). If you need strftime-like syntax, then use ToFormattedString: a - am or pm A - AM or PM d - Day, 01-31 D - Day of the Year, 001-366 m - Month, 01-12 y - Year, YY Y - Year, YYYY h - 12h Hour, 01-12 H - 24h Hour, 00-23 M - Minute, 00-59 S - Second, 00-60 s - Millisecond, 000-999
Format | The format of the returned string. |
void FDateTime::ToString | ( | const TCHAR * | Format, |
FStringBuilderBase & | Result ) const |
|
inline |
Returns this date as the number of seconds since the Unix Epoch (January 1st of 1970).
Definition at line 564 of file DateTime.h.
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
Gets the hash for the specified date and time.
DateTime | The date and time to get the hash for. |
Definition at line 788 of file DateTime.h.
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. |
Definition at line 766 of file DateTime.h.
|
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. |
Definition at line 777 of file DateTime.h.
Definition at line 810 of file DateTime.h.
Holds the days per month in a non-leap year.
Definition at line 796 of file DateTime.h.
Holds the cumulative days per month in a non-leap year.
Definition at line 799 of file DateTime.h.
|
staticprotected |
Definition at line 803 of file DateTime.h.
|
staticprotected |
Definition at line 807 of file DateTime.h.
|
staticprotected |
Holds the long and short day names.
Definition at line 802 of file DateTime.h.
|
staticprotected |
Holds the long and short month names.
Definition at line 806 of file DateTime.h.
|
private |
Holds the ticks in 100 nanoseconds resolution since January 1, 0001 A.D.
Definition at line 815 of file DateTime.h.