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

The timestamp class encapsulates a date in time as microseconds since Unix epoch. More...

#include <Timestamp.h>

Classes

struct  CompareMode
 

Public Member Functions

 PL_DECLARE_POD_TYPE ()
 
 plTimestamp ()
 Creates an invalidated timestamp.
 
bool IsValid () const
 Returns whether the timestamp is valid.
 
plInt64 GetInt64 (plSIUnitOfTime::Enum unitOfTime) const
 Returns the number of 'unitOfTime' since Unix epoch.
 
bool Compare (const plTimestamp &rhs, CompareMode::Enum mode) const
 Returns whether this timestamp is considered equal to 'rhs' in the given mode.
 
void operator+= (const plTime &timeSpan)
 Adds the time value of "timeSpan" to this data value.
 
void operator-= (const plTime &timeSpan)
 Subtracts the time value of "timeSpan" from this date value.
 
const plTime operator- (const plTimestamp &other) const
 Returns the time span between this timestamp and "other".
 
const plTimestamp operator+ (const plTime &timeSpan) const
 Returns a timestamp that is "timeSpan" further into the future from this timestamp.
 
const plTimestamp operator- (const plTime &timeSpan) const
 Returns a timestamp that is "timeSpan" further into the past from this timestamp.
 

Static Public Member Functions

static const plTimestamp CurrentTimestamp ()
 Returns the current timestamp. Returned value will always be valid.
 
static plTimestamp MakeInvalid ()
 Returns an invalid timestamp.
 
static plTimestamp MakeFromInt (plInt64 iTimeValue, plSIUnitOfTime::Enum unitOfTime)
 Returns a timestamp initialized from 'iTimeValue' in 'unitOfTime' since Unix epoch.
 

Detailed Description

The timestamp class encapsulates a date in time as microseconds since Unix epoch.

The value is represented by an plInt64 and allows storing time stamps from roughly -291030 BC to 293970 AC. Use this class to efficiently store a timestamp that is valid across platforms.

Member Function Documentation

◆ Compare()

bool plTimestamp::Compare ( const plTimestamp & rhs,
CompareMode::Enum mode ) const

Returns whether this timestamp is considered equal to 'rhs' in the given mode.

Use CompareMode::FileTime when working with file time stamps across platforms. It will use the lowest resolution supported by all platforms to make sure the timestamp of a file is considered equal regardless on which platform it was retrieved.

◆ CurrentTimestamp()

PL_FOUNDATION_INTERNAL_HEADER const plTimestamp plTimestamp::CurrentTimestamp ( )
static

Returns the current timestamp. Returned value will always be valid.

Depending on the platform the precision varies between seconds and nanoseconds.


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