Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
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 and microseconds.
 
 SbTime (const struct timeval *tv)
 Constructor taking a struct 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 and 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=DEFAULT_FORMAT_DATE) const
 Convert to a date string, interpreting the time as seconds since Jan 1, 1970.
 
SbTimeoperator+= (const SbTime &tm)
 Addition of two times which modifies the time structure.
 
SbTimeoperator-= (const SbTime &tm)
 Subtraction of two times which modifies the time structure.
 
SbTime operator- () const
 Unary negation.
 
SbTimeoperator*= (double s)
 Destructive multiplication by scalar.
 
SbTimeoperator/= (double s)
 Destructive 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 operator.
 
int operator!= (const SbTime &tm) const
 Inequality operator.
 
SbBool operator< (const SbTime &tm) const
 Relational (less than) operator.
 
SbBool operator> (const SbTime &tm) const
 Relational (greater than) operator.
 
SbBool operator<= (const SbTime &tm) const
 Relational (less than or equal to) operator.
 
SbBool operator>= (const SbTime &tm) const
 Relational (greater than or equal to) operator.
 

Static Public Member Functions

static SbTime getTimeOfDay ()
 Get the current time (seconds since Jan 1, 1970).
 
static SbTime zero ()
 Get a zero time.
 
static void sleep (const int msec)
 Sleep for specified time (in msec).
 
static void usleep (size_t usec)
 Sleep for specified time (in microsec).
 
static SbTime max ()
 Deprecated.
 
static SbTime maxTime ()
 Get a time far, far into the future.
 

Friends

SbTime operator+ (const SbTime &t0, const SbTime &t1)
 Addition of two times.
 
SbTime operator- (const SbTime &t0, const SbTime &t1)
 Subtraction of two times.
 
SbTime operator* (const SbTime &tm, double s)
 Multiplication by scalar.
 
SbTime operator* (double s, const SbTime &tm)
 Multiplication by scalar.
 
SbTime operator/ (const SbTime &tm, double s)
 Division by scalar.
 

Detailed Description

Class for representation of a time.

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

SEE ALSO

SbElapsedTime

Definition at line 91 of file SbTime.h.

Constructor & Destructor Documentation

◆ SbTime() [1/4]

SbTime::SbTime ( )
inline

Default constructor.

The time value is not initialized.

Definition at line 97 of file SbTime.h.

◆ SbTime() [2/4]

SbTime::SbTime ( double  sec)

Constructor taking seconds.

NOTE that an integer parameter will not automatically cast to a double to invoke the constructor taking seconds; that is, SbTime(1) will result in a compilation error. SbTime(1.0) must be used instead. This is to avoid errors in upgrading from an earlier release, in which SbTime(1) had different semantics. In future releases, this distinction will be eliminated, and the effect of SbTime(1.0) and that of SbTime(1) will be identical.

◆ SbTime() [3/4]

SbTime::SbTime ( time_t  sec,
long  usec 
)

Constructor taking seconds and microseconds.

◆ SbTime() [4/4]

SbTime::SbTime ( const struct timeval *  tv)

Constructor taking a struct timeval.

Member Function Documentation

◆ format()

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

Convert to a string.

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 printf(). 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 ‘-’ for negative times; the lowercase descriptors are formatted fixed width, with leading zeros. For example, a reasonable format string might be "elapsed time: \%M minutes, \%s seconds". 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 = DEFAULT_FORMAT_DATE) const

Convert to a date string, interpreting the time as seconds since Jan 1, 1970.

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

◆ getMsecValue()

unsigned long SbTime::getMsecValue ( ) const

Get time in milliseconds (for Xt).

◆ getTimeOfDay()

static SbTime SbTime::getTimeOfDay ( )
static

Get the current time (seconds since Jan 1, 1970).

◆ getValue() [1/3]

double SbTime::getValue ( ) const

Get time in seconds as a double.

◆ getValue() [2/3]

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

Get time in a struct timeval.

◆ getValue() [3/3]

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

Get time in seconds and microseconds.

◆ max()

static SbTime SbTime::max ( )
static

Deprecated.

Get a time far, far into the future. Replaced by SbTime::maxTime() method.

◆ maxTime()

static SbTime SbTime::maxTime ( )
static

Get a time far, far into the future.

Replace the deprecated SbTime::max() method.

◆ operator!=()

int SbTime::operator!= ( const SbTime tm) const

Inequality operator.

◆ operator%()

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

Modulus for two times (remainder when time1 is divided by time2).

◆ operator*=()

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

Destructive multiplication by scalar.

◆ operator+=()

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

Addition of two times which modifies the time structure.

◆ operator-()

SbTime SbTime::operator- ( ) const

Unary negation.

◆ operator-=()

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

Subtraction of two times which modifies the time structure.

◆ operator/()

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

Division by another time.

◆ operator/=()

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

Destructive division by scalar.

◆ operator<()

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

Relational (less than) operator.

Definition at line 356 of file SbTime.h.

◆ operator<=()

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

Relational (less than or equal to) operator.

Definition at line 376 of file SbTime.h.

◆ operator==()

int SbTime::operator== ( const SbTime tm) const

Equality operator.

◆ operator>()

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

Relational (greater than) operator.

Definition at line 367 of file SbTime.h.

◆ operator>=()

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

Relational (greater than or equal to) operator.

Definition at line 387 of file SbTime.h.

◆ setMsecValue()

void SbTime::setMsecValue ( unsigned long  msec)

Set time from milliseconds.

◆ setToTimeOfDay()

void SbTime::setToTimeOfDay ( )

Set to the current time (seconds since Jan 1, 1970).

◆ setValue() [1/3]

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

Set time from a struct timeval.

◆ setValue() [2/3]

void SbTime::setValue ( double  sec)

Set time from a double (in seconds).

◆ setValue() [3/3]

void SbTime::setValue ( time_t  sec,
long  usec 
)

Set time from seconds + microseconds.

◆ sleep()

static void SbTime::sleep ( const int  msec)
static

Sleep for specified time (in msec).

◆ usleep()

static void SbTime::usleep ( size_t  usec)
static

Sleep for specified time (in microsec).

◆ zero()

static SbTime SbTime::zero ( )
static

Get a zero time.

Friends And Related Symbol Documentation

◆ operator* [1/2]

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

Multiplication by scalar.

◆ operator* [2/2]

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

Multiplication by scalar.

◆ operator+

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

Addition of two times.

◆ operator-

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

Subtraction of two times.

◆ operator/

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

Division by scalar.


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