Plasma Engine  2.0
Loading...
Searching...
No Matches
plDateTime Class Reference

The plDateTime class can be used to convert plTimestamp into a human readable form. More...

#include <Timestamp.h>

Public Member Functions

 plDateTime ()
 Creates an empty date time instance with an invalid date.
 
bool IsValid () const
 Checks whether all values are within valid ranges.
 
const plTimestamp GetTimestamp () const
 Converts this instance' values into a plTimestamp.
 
plResult SetFromTimestamp (plTimestamp timestamp)
 Sets this instance to the given timestamp.
 
plUInt32 GetYear () const
 Returns the currently set year.
 
void SetYear (plInt16 iYear)
 Sets the year to the given value.
 
plUInt8 GetMonth () const
 Returns the currently set month.
 
void SetMonth (plUInt8 uiMonth)
 Sets the month to the given value. Asserts that the value is in the valid range [1, 12].
 
plUInt8 GetDay () const
 Returns the currently set day.
 
void SetDay (plUInt8 uiDay)
 Sets the day to the given value. Asserts that the value is in the valid range [1, 31].
 
plUInt8 GetDayOfWeek () const
 Returns the currently set day of week.
 
void SetDayOfWeek (plUInt8 uiDayOfWeek)
 Sets the day of week to the given value. Asserts that the value is in the valid range [0, 6].
 
plUInt8 GetHour () const
 Returns the currently set hour.
 
void SetHour (plUInt8 uiHour)
 Sets the hour to the given value. Asserts that the value is in the valid range [0, 23].
 
plUInt8 GetMinute () const
 Returns the currently set minute.
 
void SetMinute (plUInt8 uiMinute)
 Sets the minute to the given value. Asserts that the value is in the valid range [0, 59].
 
plUInt8 GetSecond () const
 Returns the currently set second.
 
void SetSecond (plUInt8 uiSecond)
 Sets the second to the given value. Asserts that the value is in the valid range [0, 59].
 
plUInt32 GetMicroseconds () const
 Returns the currently set microseconds.
 
void SetMicroseconds (plUInt32 uiMicroSeconds)
 Sets the microseconds to the given value. Asserts that the value is in the valid range [0, 999999].
 

Static Public Member Functions

static plDateTime MakeZero ()
 Returns a date time that is all zero.
 
static plDateTime MakeFromTimestamp (plTimestamp timestamp)
 Sets this instance to the given timestamp.
 

Detailed Description

The plDateTime class can be used to convert plTimestamp into a human readable form.

Note: As plTimestamp is microseconds since Unix epoch, the values in this class will always be in UTC.

Constructor & Destructor Documentation

◆ plDateTime()

plDateTime::plDateTime ( )
default

Creates an empty date time instance with an invalid date.

Day, Month and Year will be invalid and must be set.

Member Function Documentation

◆ GetTimestamp()

const plTimestamp plDateTime::GetTimestamp ( ) const
nodiscard

Converts this instance' values into a plTimestamp.

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.

◆ MakeFromTimestamp()

plDateTime plDateTime::MakeFromTimestamp ( plTimestamp timestamp)
staticnodiscard

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.

◆ SetFromTimestamp()

plResult plDateTime::SetFromTimestamp ( plTimestamp 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 PL_FAILURE will be returned. Anything after 1970 and before the not so distant future should be safe.


The documentation for this class was generated from the following files: