MIRA
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Time Class Reference

Wrapper class for boost::posix_time::ptime for adding more functionality to it. More...

#include <utils/Time.h>

Inheritance diagram for Time:
Inheritance graph
[legend]

Public Types

typedef boost::posix_time::ptime Base
 

Public Member Functions

 Time (Date d, Duration td)
 Construct from date and timespan. More...
 
 Time (const Base &p)
 Construct from base class. More...
 
 Time (Date d)
 Construct a time at start of the given day (midnight) More...
 
 Time (const Base::time_rep_type &rhs)
 Construct from time representation. More...
 
 Time (const boost::posix_time::special_values sv)
 Construct from special value. More...
 
 Time ()
 Default constructor constructs to not_a_date_time. More...
 
template<typename Reflector >
MIRA_SPLIT_REFLECT_MEMBER void reflectRead (Reflector &r)
 
template<typename Reflector >
void reflectWrite (Reflector &r)
 
uint32 toUnixTimestamp () const
 Converts the current time to a unix timestamp in seconds. More...
 
uint64 toUnixNS () const
 Converts the current time to a unix timestamp in nanoseconds. More...
 
Time toLocal () const
 Converts to local time zone based on the settings of the machine. More...
 
Time toTimeZone (const std::string &zone)
 Converts to given time zone. More...
 
bool isValid () const
 Returns true if this contains a valid time. More...
 
Operators
Duration operator- (const Time &t) const
 
Time operator+ (const DateDuration &d) const
 
Time operator+= (const DateDuration &d)
 
Time operator- (const DateDuration &d) const
 
Time operator-= (const DateDuration &d)
 
Time operator+ (const Duration &d) const
 
Time operator+= (const Duration &d)
 
Time operator- (const Duration &d) const
 
Time operator-= (const Duration &d)
 

Static Public Member Functions

static Time now ()
 Returns the current utc based time. More...
 
static Time eternity ()
 Returns 9999/12/31 23:59:59.999999. More...
 
static Time invalid ()
 Returns an invalid time. More...
 
static Time unixEpoch ()
 Returns the unix epoch 1.1.1970 0:0:0.000. More...
 
static Time fromUnixTimestamp (uint32 seconds)
 Creates a time representation out of a unix timestamp. More...
 
static Time fromUnixNS (uint64 nanoseconds)
 Creates a time representation out of a unix timestamp. More...
 

Detailed Description

Wrapper class for boost::posix_time::ptime for adding more functionality to it.

If not stated otherwise the time represented by this class is in UTC time.

For more information on the underlying boost::posix_time classes refer to http://boost.org/doc/libs/1_44_0/doc/html/date_time/posix_time.html .

The underlying datatype in boost::posix_time::ptime is int64.

Examples:
tutorials/Point2Visualization.C, and tutorials/Point3Visualization.C.

Member Typedef Documentation

◆ Base

typedef boost::posix_time::ptime Base

Constructor & Destructor Documentation

◆ Time() [1/6]

Time ( Date  d,
Duration  td 
)
inline

Construct from date and timespan.

◆ Time() [2/6]

Time ( const Base p)
inline

Construct from base class.

◆ Time() [3/6]

Time ( Date  d)
inlineexplicit

Construct a time at start of the given day (midnight)

◆ Time() [4/6]

Time ( const Base::time_rep_type &  rhs)
inline

Construct from time representation.

◆ Time() [5/6]

Time ( const boost::posix_time::special_values  sv)
inline

Construct from special value.

◆ Time() [6/6]

Time ( )
inline

Default constructor constructs to not_a_date_time.

Member Function Documentation

◆ reflectRead()

MIRA_SPLIT_REFLECT_MEMBER void reflectRead ( Reflector &  r)
inline

◆ reflectWrite()

void reflectWrite ( Reflector &  r)
inline

◆ now()

static Time now ( )
inlinestatic

Returns the current utc based time.

Returns
The current time.
Examples:
tutorials/Point2Visualization.C, and tutorials/Point3Visualization.C.

◆ eternity()

static Time eternity ( )
inlinestatic

Returns 9999/12/31 23:59:59.999999.

◆ invalid()

static Time invalid ( )
inlinestatic

Returns an invalid time.

◆ unixEpoch()

static Time unixEpoch ( )
inlinestatic

Returns the unix epoch 1.1.1970 0:0:0.000.

Returns
Unix epoch time.

◆ toUnixTimestamp()

uint32 toUnixTimestamp ( ) const
inline

Converts the current time to a unix timestamp in seconds.

Returns
timestamp in seconds.

◆ fromUnixTimestamp()

static Time fromUnixTimestamp ( uint32  seconds)
inlinestatic

Creates a time representation out of a unix timestamp.

Parameters
[in]secondsThe unix timestamp in seconds.

◆ toUnixNS()

uint64 toUnixNS ( ) const
inline

Converts the current time to a unix timestamp in nanoseconds.

Returns
timestamp in nanoseconds.

◆ fromUnixNS()

static Time fromUnixNS ( uint64  nanoseconds)
inlinestatic

Creates a time representation out of a unix timestamp.

Parameters
[in]nanosecondsThe unix timestamp in nanoseconds.

◆ toLocal()

Time toLocal ( ) const
inline

Converts to local time zone based on the settings of the machine.

Returns
The time in local time zone.

◆ toTimeZone()

Time toTimeZone ( const std::string &  zone)
inline

Converts to given time zone.

Parameters
[in]zoneThe time zone to convert to e.g. "CET+1" (= name CET, 1 hour ahead of GMT).
Returns
The time in the requested time zone.

◆ isValid()

bool isValid ( ) const
inline

Returns true if this contains a valid time.

Returns
true if this is a valid time, false otherwise

◆ operator-() [1/3]

Duration operator- ( const Time t) const
inline

◆ operator+() [1/2]

Time operator+ ( const DateDuration d) const
inline

◆ operator+=() [1/2]

Time operator+= ( const DateDuration d)
inline

◆ operator-() [2/3]

Time operator- ( const DateDuration d) const
inline

◆ operator-=() [1/2]

Time operator-= ( const DateDuration d)
inline

◆ operator+() [2/2]

Time operator+ ( const Duration d) const
inline

◆ operator+=() [2/2]

Time operator+= ( const Duration d)
inline

◆ operator-() [3/3]

Time operator- ( const Duration d) const
inline

◆ operator-=() [2/2]

Time operator-= ( const Duration d)
inline

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