ezEngine  Milestone 7
ezTimestamp 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

 EZ_DECLARE_POD_TYPE ()
 
 ezTimestamp ()
 Creates an invalidated timestamp.
 
 ezTimestamp (ezInt64 iTimeValue, ezSIUnitOfTime::Enum unitOfTime)
 Creates an new timestamp with the given time in the given unit of time since Unix epoch.
 
void Invalidate ()
 Invalidates the timestamp.
 
bool IsValid () const
 Returns whether the timestamp is valid.
 
ezInt64 GetInt64 (ezSIUnitOfTime::Enum unitOfTime) const
 Returns the number of 'unitOfTime' since Unix epoch.
 
void SetInt64 (ezInt64 iTimeValue, ezSIUnitOfTime::Enum unitOfTime)
 Sets the timestamp as 'iTimeValue' in 'unitOfTime' since Unix epoch.
 
bool IsEqual (const ezTimestamp &rhs, CompareMode::Enum mode) const
 Returns whether this timestamp is considered equal to 'rhs' in the given mode. More...
 
void operator+= (const ezTime &timeSpan)
 Adds the time value of "timeSpan" to this data value.
 
void operator-= (const ezTime &timeSpan)
 Subtracts the time value of "timeSpan" from this date value.
 
const ezTime operator- (const ezTimestamp &other) const
 Returns the time span between this timestamp and "other".
 
const ezTimestamp operator+ (const ezTime &timeSpan) const
 Returns a timestamp that is "timeSpan" further into the future from this timestamp.
 
const ezTimestamp operator- (const ezTime &timeSpan) const
 Returns a timestamp that is "timeSpan" further into the past from this timestamp.
 

Static Public Member Functions

static const ezTimestamp CurrentTimestamp ()
 Returns the current timestamp. Returned value will always be valid. More...
 

Private Attributes

ezInt64 m_iTimestamp
 The date is stored as microseconds since Unix epoch.
 

Detailed Description

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

The value is represented by an ezInt64 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

const ezTimestamp ezTimestamp::CurrentTimestamp ( )
static

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

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

bool ezTimestamp::IsEqual ( const ezTimestamp 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.


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