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. | |
SbTime & | operator+= (const SbTime &tm) |
Addition of two times which modifies the time structure. | |
SbTime & | operator-= (const SbTime &tm) |
Subtraction of two times which modifies the time structure. | |
SbTime | operator- () const |
Unary negation. | |
SbTime & | operator*= (double s) |
Destructive multiplication by scalar. | |
SbTime & | operator/= (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. | |
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 ).
|
inline |
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::SbTime | ( | time_t | sec, |
long | usec | ||
) |
Constructor taking seconds and microseconds.
SbTime::SbTime | ( | const struct timeval * | tv | ) |
Constructor taking a struct timeval.
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.
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.
unsigned long SbTime::getMsecValue | ( | ) | const |
Get time in milliseconds (for Xt).
|
static |
Get the current time (seconds since Jan 1, 1970).
double SbTime::getValue | ( | ) | const |
Get time in seconds as a double.
void SbTime::getValue | ( | struct timeval * | tv | ) | const |
Get time in a struct timeval.
void SbTime::getValue | ( | time_t & | sec, |
long & | usec | ||
) | const |
Get time in seconds and microseconds.
|
static |
Deprecated.
Get a time far, far into the future. Replaced by SbTime::maxTime() method.
|
static |
Get a time far, far into the future.
Replace the deprecated SbTime::max() method.
int SbTime::operator!= | ( | const SbTime & | tm | ) | const |
Inequality operator.
Modulus for two times (remainder when time1 is divided by time2).
SbTime & SbTime::operator*= | ( | double | s | ) |
Destructive multiplication by scalar.
Addition of two times which modifies the time structure.
SbTime SbTime::operator- | ( | ) | const |
Unary negation.
Subtraction of two times which modifies the time structure.
double SbTime::operator/ | ( | const SbTime & | tm | ) | const |
Division by another time.
SbTime & SbTime::operator/= | ( | double | s | ) |
Destructive division by scalar.
int SbTime::operator== | ( | const SbTime & | tm | ) | const |
Equality operator.
void SbTime::setMsecValue | ( | unsigned long | msec | ) |
Set time from milliseconds.
void SbTime::setToTimeOfDay | ( | ) |
Set to the current time (seconds since Jan 1, 1970).
void SbTime::setValue | ( | const struct timeval * | tv | ) |
Set time from a struct timeval.
void SbTime::setValue | ( | double | sec | ) |
Set time from a double (in seconds).
void SbTime::setValue | ( | time_t | sec, |
long | usec | ||
) |
Set time from seconds + microseconds.
|
static |
Sleep for specified time (in msec).
|
static |
Sleep for specified time (in microsec).
|
static |
Get a zero time.