|
BDE 4.39.x Production Release
|
#include <bsls_timeinterval.h>
Each instance of this value-semantic type represents a time interval with nanosecond resolution. In the "canonical representation" of a time interval, the seconds field may have any 64-bit signed integer value, with the nanoseconds field limited to the range [ -999,999,999..999,999,999 ], and with the additional constraint that the two fields are either both non-negative or both non-positive.
Static Public Member Functions | |
| static BSLS_KEYWORD_CONSTEXPR bool | isValid (bsls::Types::Int64 seconds, int nanoseconds) |
| static int | maxSupportedBdexVersion (int versionSelector) |
| static int | maxSupportedBdexVersion () |
| static int | maxSupportedVersion () |
|
inline |
Create a time interval having the value of 0 seconds and 0 nanoseconds.
|
inline |
Create a time interval having the value given by the sum of the specified integral number of seconds and nanoseconds.
isValid).
|
explicit |
Create a time interval having the value represented by the specified real number of seconds. The fractional part of seconds, if any, is rounded to the nearest whole number of nanoseconds.
|
default |
|
default |
|
inline |
Add to this time interval the number of seconds represented by the specified integral number of days, and return a reference providing modifiable access to this object.
days, and the total number of seconds in the resulting time interval, can both be represented with 64-bit signed integers. days may be negative.
|
inline |
Add to this time interval the number of seconds represented by the specified integral number of hours, and return a reference providing modifiable access to this object.
hours, and the total number of seconds in the resulting time interval, can both be represented with 64-bit signed integers. hours may be negative. | TimeInterval & bsls::TimeInterval::addInterval | ( | bsls::Types::Int64 | seconds, |
| int | nanoseconds = 0 |
||
| ) |
Add to this time interval the specified integral number of seconds, and the optionally specified integral number of nanoseconds. If unspecified, nanoseconds is 0. Return a reference providing modifiable access to this object.
seconds() + seconds, and the total number of seconds in the resulting time interval, can both be represented with 64-bit signed integers.
|
inline |
Add to this time interval the specified integral number of microseconds, and return a reference providing modifiable access to this object.
microseconds may be negative.
|
inline |
Add to this time interval the specified integral number of milliseconds, and return a reference providing modifiable access to this object.
milliseconds may be negative.
|
inline |
Add to this time interval the number of seconds represented by the specified integral number of minutes, and return a reference providing modifiable access to this object.
minutes, and the total number of seconds in the resulting time interval, can both be represented with 64-bit signed integers. minutes may be negative.
|
inline |
Add to this time interval the specified integral number of nanoseconds, and return a reference providing modifiable access to this object.
nanoseconds may be negative.
|
inline |
Add to this time interval the specified integral number of seconds, and return a reference providing modifiable access to this object.
seconds may be negative. | STREAM & bsls::TimeInterval::bdexStreamIn | ( | STREAM & | stream, |
| int | version | ||
| ) |
Assign to this object the value read from the specified input stream using the specified version format, and return a reference to stream. If stream is initially invalid, this operation has no effect. If version is not supported, this object is unaltered and stream is invalidated, but otherwise unmodified. If version is supported but stream becomes invalid during this operation, this object has an undefined, but valid, state.
stream. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers. | STREAM & bsls::TimeInterval::bdexStreamOut | ( | STREAM & | stream, |
| int | version | ||
| ) | const |
Write the value of this object, using the specified version format, to the specified output stream, and return a reference to stream. If stream is initially invalid, this operation has no effect. If version is not supported, stream is invalidated, but otherwise unmodified.
version is not written to stream. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers.
|
inlinestatic |
Return true if a TimeInterval object can be constructed from the specified seconds and nanoseconds, and false otherwise. A time interval can be constructed from seconds and nanoseconds if their sum results in a time interval whose total number of seconds can be represented with a 64-bit signed integer.
|
inlinestatic |
Return the most current BDEX streaming version number supported by this class.
|
inlinestatic |
Return the maximum valid BDEX format version, as indicated by the specified versionSelector, to be passed to the bdexStreamOut method.
versionSelector be formatted as "YYYYMMDD", a date representation. Also note that versionSelector should be a compile-time-chosen value that selects a format version supported by both externalizer and unexternalizer. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers.
|
inlinestatic |
Return the most current BDEX streaming version number supported by this class.
|
inline |
Return the nanoseconds field in the canonical representation of the value of this time interval.
|
inline |
Add to this time interval the value of the specified rhs time interval, and return a reference providing modifiable access to this object.
|
inline |
Add to this time interval the value of the specified rhs real number of seconds, and return a reference providing modifiable access to this object. The fractional part of rhs, if any, is rounded to the nearest whole number of nanoseconds before being added to this object.
rhs can be converted to a valid TimeInterval object, and the total number of seconds in the resulting time interval can be represented with a 64-bit signed integer.
|
inline |
Subtract from this time interval the value of the specified rhs time interval, and return a reference providing modifiable access to this object.
LLONG_MIN != rhs.seconds(), and the total number of seconds in the resulting time interval can be represented with a 64-bit signed integer.
|
inline |
Subtract from this time interval the value of the specified rhs real number of seconds, and return a reference providing modifiable access to this object. The fractional part of rhs, if any, is rounded to the nearest whole number of nanoseconds before being subtracted from this object.
rhs can be converted to a valid TimeInterval object whose seconds field is greater than LLONG_MIN, and the total number of seconds in the resulting time interval can be represented with a 64-bit signed integer.
|
default |
|
inline |
Assign to this time interval the value of the specified rhs real number of seconds, and return a reference providing modifiable access to this object. The fractional part of rhs, if any, is rounded to the nearest whole number of nanoseconds.
rhs can be converted to a valid TimeInterval object. | std::ostream & bsls::TimeInterval::print | ( | std::ostream & | stream, |
| int | level = 0, |
||
| int | spacesPerLevel = 4 |
||
| ) | const |
Write the value of this object to the specified output stream in a human-readable format, and return a reference providing modifiable access to stream. Optionally specify an initial indentation level, whose absolute value is incremented recursively for nested objects. If level is specified, optionally specify spacesPerLevel, whose absolute value indicates the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level). If stream is not valid on entry, this operation has no effect.
|
inline |
Return the seconds field in the canonical representation of the value of this time interval.
|
inline |
Set this time interval to have the value given by the sum of the specified integral number of seconds, and the optionally specified integral number of nanoseconds. If unspecified, nanoseconds is 0.
isValid).
|
inline |
Set this time interval to have the value given by the sum of the specified integral number of seconds, and the optionally specified integral number of nanoseconds, where seconds and nanoseconds form a canonical representation of a time interval (see {Representation}). If unspecified, nanoseconds is 0.
-999,999,999 <= nanoseconds <= +999,999,999 and seconds and nanoseconds are either both non-negative or both non-positive.setInterval chosen to minimize runtime performance cost.
|
inline |
Set the overall value of this object to indicate the specified integral number of days.
days can be represented with a 64-bit signed integer. days may be negative.
|
inline |
Set the overall value of this object to indicate the specified integral number of hours.
hours can be represented with a 64-bit signed integer. hours may be negative.
|
inline |
Set the overall value of this object to indicate the specified integral number of microseconds.
microseconds may be negative.
|
inline |
Set the overall value of this object to indicate the specified integral number of milliseconds.
milliseconds may be negative.
|
inline |
Set the overall value of this object to indicate the specified integral number of minutes.
minutes can be represented with a 64-bit signed integer. minutes may be negative.
|
inline |
Set the overall value of this object to indicate the specified integral number of nanoseconds.
nanoseconds may be negative.
|
inline |
Set the overall value of this object to indicate the specified integral number of seconds.
seconds may be negative.
|
inline |
Format this time to the specified output stream, and return a reference to the modifiable stream.
|
inline |
Return the value of this time interval as an integral number of days, rounded towards zero.
|
inline |
Return the value of this time interval as an integral number of hours, rounded towards zero.
|
inline |
Return the value of this time interval as an integral number of microseconds, rounded towards zero.
|
inline |
Return the value of this time interval as an integral number of milliseconds, rounded towards zero.
|
inline |
Return the value of this time interval as an integral number of minutes, rounded towards zero.
|
inline |
Return the value of this time interval as an integral number of nanoseconds.
|
inline |
Return the value of this time interval as an integral number of seconds, rounded towards zero.
seconds.
|
inline |
Return the value of this time interval as a real number of seconds.
double may lose precision.