![]() |
ezEngine
Release 25.03
|
The ezDateTime class can be used to convert ezTimestamp into a human readable form. More...
#include <Timestamp.h>
Public Member Functions | |
ezDateTime () | |
Creates an empty date time instance with an invalid date. More... | |
bool | IsValid () const |
Checks whether all values are within valid ranges. | |
const ezTimestamp | GetTimestamp () const |
Converts this instance' values into a ezTimestamp. More... | |
ezResult | SetFromTimestamp (ezTimestamp timestamp) |
Sets this instance to the given timestamp. More... | |
ezUInt32 | GetYear () const |
Returns the currently set year. | |
void | SetYear (ezInt16 iYear) |
Sets the year to the given value. | |
ezUInt8 | GetMonth () const |
Returns the currently set month. | |
void | SetMonth (ezUInt8 uiMonth) |
Sets the month to the given value. Asserts that the value is in the valid range [1, 12]. | |
ezUInt8 | GetDay () const |
Returns the currently set day. | |
void | SetDay (ezUInt8 uiDay) |
Sets the day to the given value. Asserts that the value is in the valid range [1, 31]. | |
ezUInt8 | GetDayOfWeek () const |
Returns the currently set day of week. | |
void | SetDayOfWeek (ezUInt8 uiDayOfWeek) |
Sets the day of week to the given value. Asserts that the value is in the valid range [0, 6]. | |
ezUInt8 | GetHour () const |
Returns the currently set hour. | |
void | SetHour (ezUInt8 uiHour) |
Sets the hour to the given value. Asserts that the value is in the valid range [0, 23]. | |
ezUInt8 | GetMinute () const |
Returns the currently set minute. | |
void | SetMinute (ezUInt8 uiMinute) |
Sets the minute to the given value. Asserts that the value is in the valid range [0, 59]. | |
ezUInt8 | GetSecond () const |
Returns the currently set second. | |
void | SetSecond (ezUInt8 uiSecond) |
Sets the second to the given value. Asserts that the value is in the valid range [0, 59]. | |
ezUInt32 | GetMicroseconds () const |
Returns the currently set microseconds. | |
void | SetMicroseconds (ezUInt32 uiMicroSeconds) |
Sets the microseconds to the given value. Asserts that the value is in the valid range [0, 999999]. | |
Static Public Member Functions | |
static ezDateTime | MakeZero () |
Returns a date time that is all zero. | |
static ezDateTime | MakeFromTimestamp (ezTimestamp timestamp) |
Sets this instance to the given timestamp. More... | |
The ezDateTime class can be used to convert ezTimestamp into a human readable form.
Note: As ezTimestamp is microseconds since Unix epoch, the values in this class will always be in UTC.
|
default |
Creates an empty date time instance with an invalid date.
Day, Month and Year will be invalid and must be set.
const ezTimestamp ezDateTime::GetTimestamp | ( | ) | const |
Converts this instance' values into a ezTimestamp.
The conversion is done via the OS and can fail for values that are outside the supported range. In this case, the returned value will be invalid. Anything after 1970 and before the not so distant future should be safe.
|
static |
Sets this instance to the given timestamp.
This calls SetFromTimestamp() internally and asserts that the conversion succeeded. Use SetFromTimestamp() directly, if you need to be able to react to invalid data.
ezResult ezDateTime::SetFromTimestamp | ( | ezTimestamp | timestamp | ) |
Sets this instance to the given timestamp.
The conversion is done via the OS and will fail for invalid dates and values outside the supported range, in which case EZ_FAILURE will be returned. Anything after 1970 and before the not so distant future should be safe.