Open Inventor Reference
SbTime Class Reference

Class for representation of a time. More...

#include <Inventor/SbTime.h>

List of all members.

Public Member Functions

 SbTime ()
 Default constructor.
 SbTime (double sec)
 Constructor taking seconds.
 SbTime (time_t sec, long usec)
 Constructor taking seconds + microseconds.
 SbTime (const struct timeval *tv)
 Constructors taking timeval.
void setToTimeOfDay ()
 Set to the current time (seconds since Jan 1, 1970).
void setValue (double sec)
 Set time from a double (in seconds).
void setValue (time_t sec, long usec)
 Set time from seconds + microseconds.
void setValue (const struct timeval *tv)
 Set time from a struct timeval.
void setMsecValue (unsigned long msec)
 Set time from milliseconds.
double getValue () const
 Get time in seconds as a double.
void getValue (time_t &sec, long &usec) const
 Get time in seconds & microseconds.
void getValue (struct timeval *tv) const
 Get time in a struct timeval.
unsigned long getMsecValue () const
 Get time in milliseconds (for Xt).
SbString format (const char *fmt="%S.%i") const
 Convert to a string.
SbString formatDate (const char *fmt="%A, %D %r") const
 Convert to a date string, interpreting the time as seconds since Jan 1, 1970.
SbTimeoperator+= (const SbTime &tm)
 Addition and subtraction of two times which modifies the time structure.
SbTimeoperator-= (const SbTime &tm)
 Addition and subtraction of two times which modifies the time structure.
SbTime operator- () const
 Unary negation.
SbTimeoperator*= (double s)
 Destructive multiplication and division by scalar.
SbTimeoperator/= (double s)
 Destructive multiplication and division by scalar.
double operator/ (const SbTime &tm) const
 division by another time
SbTime operator% (const SbTime &tm) const
 Modulus for two times (remainder when time1 is divided by time2).
int operator== (const SbTime &tm) const
 Equality operators.
int operator!= (const SbTime &tm) const
 Equality operators.
SbBool operator< (const SbTime &tm) const
 Relational operators.
SbBool operator> (const SbTime &tm) const
 Relational operators.
SbBool operator<= (const SbTime &tm) const
 Relational operators.
SbBool operator>= (const SbTime &tm) const
 Relational operators.

Static Public Member Functions

static SbTime getTimeOfDay ()
 Get the current time (seconds since Jan 1, 1970).
static SbTime zero ()
 Get a zero time.
static SbTime max ()
 Get a time far, far into the future.

Friends

INVENTOR_API SbTime operator+ (const SbTime &t0, const SbTime &t1)
 Addition.
INVENTOR_API SbTime operator- (const SbTime &t0, const SbTime &t1)
 Subtraction.
INVENTOR_API SbTime operator* (const SbTime &tm, double s)
 multiplication by scalar
INVENTOR_API SbTime operator* (double s, const SbTime &tm)
INVENTOR_API SbTime operator/ (const SbTime &tm, double s)
 division by scalar

Detailed Description

This class represents and performs operations on time. Operations may be done in seconds, seconds and microseconds, or using a struct timeval (defined in /usr/include/sys/time.h).

See Also
cftime

Definition at line 89 of file SbTime.h.


Constructor & Destructor Documentation

SbTime::SbTime ( ) [inline]

Definition at line 93 of file SbTime.h.

SbTime::SbTime ( double  sec)
SbTime::SbTime ( time_t  sec,
long  usec 
) [inline]
Parameters:
usecSystem long from <sys/time.h>

Definition at line 99 of file SbTime.h.

SbTime::SbTime ( const struct timeval *  tv) [inline]

Definition at line 122 of file SbTime.h.


Member Function Documentation

SbString SbTime::format ( const char *  fmt = "%S.%i") const

The default format is seconds with 3 digits of fraction precision. fmt is a character string that consists of field descriptors and text characters, in a manner analogous to cftime (3C) and printf (3S). Each field descriptor consists of a % character followed by another character which specifies the replacement for the field descriptor. All other characters are copied from fmt into the result. The following field descriptors are supported:

 %   the `%' character
 D   total number of days
 H   total number of hours 
 M   total number of minutes
 S   total number of seconds
 I   total number of milliseconds
 U   total number of microseconds
 h   hours remaining after the days (00-23)
 m   minutes remaining after the hours (00-59)
 s   seconds remaining after the minutes (00-59)
 i   milliseconds remaining after the seconds (000-999)
 u   microseconds remaining after the seconds (000000-999999)

The uppercase descriptors are formatted with a leading `em' for negative times; the lowercase descriptors are formatted fixed width, with leading zeros. For example, a reasonable format string might be "elapsedtime:%Mminutes,%sseconds". The default value of fmt, "%S.%i", formats the time as seconds with 3 digits of fractional precision.

SbString SbTime::formatDate ( const char *  fmt = "%A, %D %r") const

The default format gives "Tuesday, 01/26/93 11:23:41 AM". See the cftime() reference page for explanation of the format string.

unsigned long SbTime::getMsecValue ( ) const [inline]

Definition at line 182 of file SbTime.h.

static SbTime SbTime::getTimeOfDay ( ) [static]
double SbTime::getValue ( ) const [inline]

Definition at line 170 of file SbTime.h.

Referenced by operator/().

void SbTime::getValue ( time_t &  sec,
long &  usec 
) const [inline]

< System long

Definition at line 174 of file SbTime.h.

void SbTime::getValue ( struct timeval *  tv) const [inline]

Definition at line 178 of file SbTime.h.

static SbTime SbTime::max ( ) [inline, static]

Definition at line 144 of file SbTime.h.

References INT32_MAX.

int SbTime::operator!= ( const SbTime tm) const [inline]

Definition at line 267 of file SbTime.h.

SbTime SbTime::operator% ( const SbTime tm) const [inline]

Definition at line 259 of file SbTime.h.

SbTime& SbTime::operator*= ( double  s) [inline]

Definition at line 244 of file SbTime.h.

SbTime& SbTime::operator+= ( const SbTime tm) [inline]

Definition at line 225 of file SbTime.h.

SbTime SbTime::operator- ( ) const [inline]

Definition at line 233 of file SbTime.h.

SbTime& SbTime::operator-= ( const SbTime tm) [inline]

Definition at line 229 of file SbTime.h.

double SbTime::operator/ ( const SbTime tm) const [inline]

Definition at line 255 of file SbTime.h.

References getValue().

SbTime& SbTime::operator/= ( double  s) [inline]

Definition at line 251 of file SbTime.h.

SbBool SbTime::operator< ( const SbTime tm) const [inline]

Definition at line 286 of file SbTime.h.

References FALSE, and TRUE.

SbBool SbTime::operator<= ( const SbTime tm) const [inline]

Definition at line 306 of file SbTime.h.

References FALSE, and TRUE.

int SbTime::operator== ( const SbTime tm) const [inline]

Definition at line 263 of file SbTime.h.

SbBool SbTime::operator> ( const SbTime tm) const [inline]

Definition at line 296 of file SbTime.h.

References FALSE, and TRUE.

SbBool SbTime::operator>= ( const SbTime tm) const [inline]

Definition at line 316 of file SbTime.h.

References FALSE, and TRUE.

void SbTime::setMsecValue ( unsigned long  msec) [inline]

Definition at line 165 of file SbTime.h.

void SbTime::setToTimeOfDay ( )
void SbTime::setValue ( double  sec) [inline]

Definition at line 148 of file SbTime.h.

void SbTime::setValue ( time_t  sec,
long  usec 
) [inline]
Parameters:
usecSystem long

Definition at line 157 of file SbTime.h.

void SbTime::setValue ( const struct timeval *  tv) [inline]

Definition at line 161 of file SbTime.h.

static SbTime SbTime::zero ( ) [inline, static]

Definition at line 132 of file SbTime.h.


Friends And Related Function Documentation

INVENTOR_API SbTime operator* ( const SbTime tm,
double  s 
) [friend]
INVENTOR_API SbTime operator* ( double  s,
const SbTime tm 
) [friend]

Definition at line 240 of file SbTime.h.

INVENTOR_API SbTime operator+ ( const SbTime t0,
const SbTime t1 
) [friend]
INVENTOR_API SbTime operator- ( const SbTime t0,
const SbTime t1 
) [friend]
INVENTOR_API SbTime operator/ ( const SbTime tm,
double  s 
) [friend]

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