Open Inventor Reference
SbTime Class Reference

Class for representation of a time. More...

#include <Inventor/SbTime.h>

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).
 
bool operator== (const SbTime &tm) const
 Equality operators.
 
bool operator!= (const SbTime &tm) const
 Equality operators.
 
bool operator< (const SbTime &tm) const
 Relational operators.
 
bool operator> (const SbTime &tm) const
 Relational operators.
 
bool operator<= (const SbTime &tm) const
 Relational operators.
 
bool 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() [1/4]

SbTime::SbTime ( )
inline

Definition at line 93 of file SbTime.h.

◆ SbTime() [2/4]

SbTime::SbTime ( double  sec)

◆ SbTime() [3/4]

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

Definition at line 99 of file SbTime.h.

◆ SbTime() [4/4]

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

Definition at line 122 of file SbTime.h.

Member Function Documentation

◆ format()

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.

◆ formatDate()

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.

◆ getMsecValue()

unsigned long SbTime::getMsecValue ( ) const
inline

Definition at line 182 of file SbTime.h.

◆ getTimeOfDay()

static SbTime SbTime::getTimeOfDay ( )
static

◆ getValue() [1/3]

double SbTime::getValue ( ) const
inline

Definition at line 170 of file SbTime.h.

Referenced by operator/().

◆ getValue() [2/3]

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

Definition at line 178 of file SbTime.h.

◆ getValue() [3/3]

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

< System long

Definition at line 174 of file SbTime.h.

◆ max()

static SbTime SbTime::max ( )
inlinestatic

Definition at line 144 of file SbTime.h.

References INT32_MAX.

◆ operator!=()

bool SbTime::operator!= ( const SbTime tm) const
inline

Definition at line 266 of file SbTime.h.

◆ operator%()

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

Definition at line 258 of file SbTime.h.

◆ operator*=()

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

Definition at line 243 of file SbTime.h.

◆ operator+=()

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

Definition at line 225 of file SbTime.h.

◆ operator-()

SbTime SbTime::operator- ( ) const
inline

Definition at line 233 of file SbTime.h.

◆ operator-=()

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

Definition at line 229 of file SbTime.h.

◆ operator/()

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

Definition at line 254 of file SbTime.h.

References getValue().

◆ operator/=()

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

Definition at line 250 of file SbTime.h.

◆ operator<()

bool SbTime::operator< ( const SbTime tm) const
inline

Definition at line 290 of file SbTime.h.

References FALSE, and TRUE.

◆ operator<=()

bool SbTime::operator<= ( const SbTime tm) const
inline

Definition at line 310 of file SbTime.h.

References FALSE, and TRUE.

◆ operator==()

bool SbTime::operator== ( const SbTime tm) const
inline

Definition at line 262 of file SbTime.h.

◆ operator>()

bool SbTime::operator> ( const SbTime tm) const
inline

Definition at line 301 of file SbTime.h.

References FALSE, and TRUE.

◆ operator>=()

bool SbTime::operator>= ( const SbTime tm) const
inline

Definition at line 321 of file SbTime.h.

References FALSE, and TRUE.

◆ setMsecValue()

void SbTime::setMsecValue ( unsigned long  msec)
inline

Definition at line 165 of file SbTime.h.

◆ setToTimeOfDay()

void SbTime::setToTimeOfDay ( )

◆ setValue() [1/3]

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

Definition at line 161 of file SbTime.h.

◆ setValue() [2/3]

void SbTime::setValue ( double  sec)
inline

Definition at line 148 of file SbTime.h.

◆ setValue() [3/3]

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

Definition at line 157 of file SbTime.h.

◆ zero()

static SbTime SbTime::zero ( )
inlinestatic

Definition at line 132 of file SbTime.h.

Friends And Related Symbol Documentation

◆ operator* [1/2]

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

◆ operator* [2/2]

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

Definition at line 285 of file SbTime.h.

◆ operator+

INVENTOR_API SbTime operator+ ( const SbTime t0,
const SbTime t1 
)
friend

◆ operator-

INVENTOR_API SbTime operator- ( const SbTime t0,
const SbTime t1 
)
friend

◆ operator/

INVENTOR_API SbTime operator/ ( const SbTime tm,
double  s 
)
friend

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