MIRA
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 (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 () static Time eternity()
 Returns the current utc based time. 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

typedef boost::posix_time::ptime Base

Constructor & Destructor Documentation

Time ( Date  d,
Duration  td 
)
inline

Construct from date and timespan.

Time ( Base  p)
inline

Construct from base class.

Time ( Date  d)
inlineexplicit

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

Time ( const Base::time_rep_type &  rhs)
inline

Construct from time representation.

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

Construct from special value.

Time ( )
inline

Default constructor constructs to not_a_date_time.

Member Function Documentation

MIRA_SPLIT_REFLECT_MEMBER void reflectRead ( Reflector &  r)
inline
void reflectWrite ( Reflector &  r)
inline
static Time now ( )
inlinestatic

Returns the current utc based time.

Returns
The current time. Returns 9999/12/31 23:59:59.999999
Examples:
tutorials/Point2Visualization.C, and tutorials/Point3Visualization.C.
static Time invalid ( )
inlinestatic

Returns an invalid time.

static Time unixEpoch ( )
inlinestatic

Returns the unix epoch 1.1.1970 0:0:0.000.

Returns
Unix epoch time.
uint32 toUnixTimestamp ( ) const
inline

Converts the current time to a unix timestamp in seconds.

Returns
timestamp in seconds.
static Time fromUnixTimestamp ( uint32  seconds)
inlinestatic

Creates a time representation out of a unix timestamp.

Parameters
[in]secondsThe unix timestamp in seconds.
uint64 toUnixNS ( ) const
inline

Converts the current time to a unix timestamp in nanoseconds.

Returns
timestamp in nanoseconds.
static Time fromUnixNS ( uint64  nanoseconds)
inlinestatic

Creates a time representation out of a unix timestamp.

Parameters
[in]nanosecondsThe unix timestamp in nanoseconds.
Time toLocal ( ) const
inline

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

Returns
The time in local time zone.
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.
bool isValid ( ) const
inline

Returns true if this contains a valid time.

Returns
true if this is a valid time, false otherwise
Duration operator- ( const Time t) const
inline
Time operator+ ( const DateDuration d) const
inline
Time operator+= ( const DateDuration d)
inline
Time operator- ( const DateDuration d) const
inline
Time operator-= ( const DateDuration d)
inline
Time operator+ ( const Duration d) const
inline
Time operator+= ( const Duration d)
inline
Time operator- ( const Duration d) const
inline
Time operator-= ( const Duration d)
inline

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