Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields  

sword::Time Class Reference

High precision timestamp. More...

Inheritance diagram for sword::Time:

sword::Comparable< Time >

Public Methods

 Time () throw ()
 Default constructor.

 Time (int64 value) throw ()
 Int64-value constructor.

int64 serial () const throw ()
 Int64-value read access.

void serial (int64 value) throw ()
 Int64-value write access.

int integer1900 () const throw ()
 get the time in the 1900-referential as an integer

Time & integer1900 (int value) throw ()
 set the time from a 1900-referential integer

double double1900 () const throw ()
 get the time in the 1900-referential as a double

Time & double1900 (double value) throw ()
 set the time from a 1900-referential double

bool valid () const throw ()
 Checks whether this time is valid.

void invalidate () throw ()
 Set this time as invalid.

void resetHour () throw ()
 Set the hour part (h:m:s) of this timestamp to 0:0:0.

Time & roundDay () throw ()
 Rounds this time value to the nearest day.

Time & roundHour () throw ()
 Rounds this time value to the nearest hour.

Time & roundMinute () throw ()
 Rounds this time value to the nearest minute.

Time & roundSecond () throw ()
 Rounds this time value to the nearest second.

Time & truncDay () throw ()
 Truncs this time value to the nearest day.

Time & truncHour () throw ()
 Truncs this time value to the nearest hour.

Time & truncMinute () throw ()
 Truncs this time value to the nearest minute.

Time & truncSecond () throw ()
 Truncs this time value to the nearest second.

time_t toC () const
void fromC (time_t value) throw ()
bool operator< (const Comparable< Time > &rhs) const
 '<' operation between this instance and rhs

bool operator<= (const Comparable< Time > &rhs) const
 '<=' operation between this instance and rhs

bool operator> (const Comparable< Time > &rhs) const
 '>' operation between this instance and rhs

bool operator>= (const Comparable< Time > &rhs) const
 '>=' operation between this instance and rhs

bool operator== (const Comparable< Time > &rhs) const
 '==' operation between this instance and rhs

bool operator!= (const Comparable< Time > &rhs) const
 '!=' operation between this instance and rhs


Static Public Methods

Time now ()
 Get the current time, in local time.

Time nowUTC ()
 Get the current time, in UTC.

TimeSpan timeZone ()
 Get the machine current time zone.

int compare (const Time &lhs, const Time &rhs)
 Comparison method (used for Ordered<> implementation).


Friends

TimeSpan operator- (const Time &lhs, const Time &rhs)
 Get the interval between this time and another.

Time operator+ (const Time &lhs, const TimeSpan &rhs)
 Adds an interval to this time.

Time operator+ (const TimeSpan &lhs, const Time &rhs)
 Adds an interval to this time.

IStreamoperator>> (IStream &lhs, Time &rhs)
 Streaming onto a sword::IStream.

OStreamoperator<< (OStream &lhs, const Time &rhs)
 Streaming onto a sword::OStream.


Detailed Description

High precision timestamp.

A sword::Time holds nothing but a point in time (also called timestamp). The precision is the millisecond. Whenever a timestamp is created it is marked invalid (non initialized), and this state can be tested.

Internally, the storage is a 64-bit signed integer which represents the number of milliseconds since an arbitrary origin (1 Jan 1970 00:00:00 UTC). It can be either positive (point in time after this origin) or negative (point in time before this origin). The authorised dates are approximately in a 292 million years interval backward and forward the origin. There is one special unauthorised value (-2^63-1, the minimum 64-bit signed integer value), which is used to mark an invalid (or non initialized date).

Apart from storing a time value, the Time class provides conversion with these other usefull time referentials:


Constructor & Destructor Documentation

sword::Time::Time   throw () [inline]
 

Default constructor.

The time is set to be invalid

sword::Time::Time int64    value throw () [inline]
 

Int64-value constructor.


Member Function Documentation

int sword::Time::compare const Time &    lhs,
const Time &    rhs
[inline, static]
 

Comparison method (used for Ordered<> implementation).

Time& sword::Time::double1900 double    value throw () [inline]
 

set the time from a 1900-referential double

double sword::Time::double1900   const throw () [inline]
 

get the time in the 1900-referential as a double

Time& sword::Time::integer1900 int    value throw () [inline]
 

set the time from a 1900-referential integer

int sword::Time::integer1900   const throw () [inline]
 

get the time in the 1900-referential as an integer

void sword::Time::invalidate   throw () [inline]
 

Set this time as invalid.

Time sword::Time::now   [inline, static]
 

Get the current time, in local time.

See also:
Time::nowUTC, Time::timeZone

Time sword::Time::nowUTC   [static]
 

Get the current time, in UTC.

See also:
Time::now, Time::timeZone

bool sword::Comparable< Time >::operator!= const Comparable< Time > &    rhs const [inherited]
 

'!=' operation between this instance and rhs

bool sword::Comparable< Time >::operator< const Comparable< Time > &    rhs const [inherited]
 

'<' operation between this instance and rhs

bool sword::Comparable< Time >::operator<= const Comparable< Time > &    rhs const [inherited]
 

'<=' operation between this instance and rhs

bool sword::Comparable< Time >::operator== const Comparable< Time > &    rhs const [inherited]
 

'==' operation between this instance and rhs

bool sword::Comparable< Time >::operator> const Comparable< Time > &    rhs const [inherited]
 

'>' operation between this instance and rhs

bool sword::Comparable< Time >::operator>= const Comparable< Time > &    rhs const [inherited]
 

'>=' operation between this instance and rhs

void sword::Time::resetHour   throw () [inline]
 

Set the hour part (h:m:s) of this timestamp to 0:0:0.

Time& sword::Time::roundDay   throw () [inline]
 

Rounds this time value to the nearest day.

Time& sword::Time::roundHour   throw () [inline]
 

Rounds this time value to the nearest hour.

Time& sword::Time::roundMinute   throw () [inline]
 

Rounds this time value to the nearest minute.

Time& sword::Time::roundSecond   throw () [inline]
 

Rounds this time value to the nearest second.

void sword::Time::serial int64    value throw () [inline]
 

Int64-value write access.

int64 sword::Time::serial   const throw () [inline]
 

Int64-value read access.

TimeSpan sword::Time::timeZone   [static]
 

Get the machine current time zone.

The timezone can be used to move from local time to Universal time using the formula "UTC + time zone = local time"

See also:
Time::now, Time::nowUTC

Time& sword::Time::truncDay   throw () [inline]
 

Truncs this time value to the nearest day.

Time& sword::Time::truncHour   throw () [inline]
 

Truncs this time value to the nearest hour.

Time& sword::Time::truncMinute   throw () [inline]
 

Truncs this time value to the nearest minute.

Time& sword::Time::truncSecond   throw () [inline]
 

Truncs this time value to the nearest second.

bool sword::Time::valid   const throw () [inline]
 

Checks whether this time is valid.


Friends And Related Function Documentation

Time operator+ const TimeSpan   lhs,
const Time &    rhs
[friend]
 

Adds an interval to this time.

Time operator+ const Time &    lhs,
const TimeSpan   rhs
[friend]
 

Adds an interval to this time.

TimeSpan operator- const Time &    lhs,
const Time &    rhs
[friend]
 

Get the interval between this time and another.

OStream& operator<< OStream   lhs,
const Time &    rhs
[friend]
 

Streaming onto a sword::OStream.

IStream& operator>> IStream   lhs,
Time &    rhs
[friend]
 

Streaming onto a sword::IStream.


Generated on Tue Dec 23 20:08:57 2003 for SWORD by doxygen1.3-rc2