|
BDE 4.14.0 Production release
|
#include <bdlt_epochutil.h>
Public Types | |
| typedef bsls::Types::Int64 | TimeT64 |
Static Public Member Functions | |
| static const Datetime & | epoch () |
| static Datetime | convertFromTimeT (bsl::time_t time) |
| static void | convertFromTimeT (Datetime *result, bsl::time_t time) |
| static bsl::time_t | convertToTimeT (const Datetime &datetime) |
| static int | convertToTimeT (bsl::time_t *result, const Datetime &datetime) |
| static Datetime | convertFromTimeT64 (TimeT64 time) |
| static int | convertFromTimeT64 (Datetime *result, TimeT64 time) |
| static TimeT64 | convertToTimeT64 (const Datetime &datetime) |
| static void | convertToTimeT64 (TimeT64 *result, const Datetime &datetime) |
| static Datetime | convertFromTimeInterval (const bsls::TimeInterval &timeInterval) |
| static void | convertFromTimeInterval (Datetime *result, const bsls::TimeInterval &timeInterval) |
| static bsls::TimeInterval | convertToTimeInterval (const Datetime &datetime) |
| static Datetime | convertFromDatetimeInterval (const DatetimeInterval &datetimeInterval) |
| static void | convertFromDatetimeInterval (Datetime *result, const DatetimeInterval &datetimeInterval) |
| static DatetimeInterval | convertToDatetimeInterval (const Datetime &datetime) |
| static int | convertToTimeInterval (bsls::TimeInterval *result, const Datetime &datetime) |
| static int | convertToDatetimeInterval (DatetimeInterval *result, const Datetime &datetime) |
This struct provides a namespace for a suite of non-primitive functions providing conversions between absolute Datetime values and corresponding relative time intervals with respect to the Unix standard epoch time, returned by the epoch method. These methods are alias-safe, thread-safe, and exception-neutral. Functions are provided for returning converted values by value or through a result pointer.
TimeT64 is an alias for a 64-bit integral type representing seconds from the epoch in UTC. Note that, in contrast with bsl::time_t, this type can be used in conversions to and from Datetime values that are less than the epoch (corresponding to negative TimeT64 values).
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Return, as a Datetime, the absolute datetime computed as the sum of the specified relative timeInterval and the epoch. The behavior is undefined unless the conversion result can be represented as a Datetime. Note that the conversion is potentially lossy as the resolution of bsls::TimeInterval is greater than that of Datetime.
|
inlinestatic |
Load into the specified result the absolute datetime converted to a Datetime, computed as the sum of the specified relative timeInterval and the epoch. The behavior is undefined unless the conversion result can be represented as a Datetime. Note that the conversion is potentially lossy as the resolution of bsls::TimeInterval is greater than that of Datetime.
|
inlinestatic |
Return, as a Datetime, the absolute datetime computed as the sum of the specified relative time and the epoch. The behavior is undefined unless 0 <= time and, for the resultant Datetime dt, 0 == convertToTimeT(&time, dt) (i.e., time is representable as a 32-bit int). Note that the returned value will use Coordinated Universal Time (UTC) as a reference.
|
inlinestatic |
Load into the specified result the absolute datetime converted to a Datetime, computed as the sum of the specified relative time and the epoch. The behavior is undefined unless 0 <= time and 0 == convertToTimeT(&time, *result) (i.e., time is representable as a 32-bit int). Note that result will use Coordinated Universal Time (UTC) as a reference.
Load into the specified result the absolute datetime converted to a Datetime, computed as the sum of the specified relative time and the epoch. Return 0 on success, and a non-zero value (with no effect on result) if time cannot be represented in the destination format. Note that result will use Coordinated Universal Time (UTC) as a reference.
Return, as a Datetime, the absolute datetime computed as the sum of the specified relative time and the epoch. The behavior is undefined unless the converted time can be represented in the destination format. Note that the returned value will use Coordinated Universal Time (UTC) as a reference. Also note that if error detection is desired, the overloaded version that loads the converted time into a supplied destination object should be used.
|
inlinestatic |
Return, as a DatetimeInterval, the relative time computed as the difference between the specified absolute datetime and the epoch.
|
inlinestatic |
If datetime - epoch() >= DatetimeInterval(), load into the specified result the relative time converted to a DatetimeInterval, computed as the difference between the specified absolute datetime and the epoch, and return 0. Otherwise, return a non-zero value (with no effect on result).
|
inlinestatic |
If datetime - epoch() >= DatetimeInterval(), load into the specified result the relative time converted to a bsls::TimeInterval, computed as the difference between the specified absolute datetime and the epoch, and return 0. Otherwise, return a non-zero value (with no effect on result).
|
inlinestatic |
Return, as a bsls::TimeInterval, the relative time computed as the difference between the specified absolute datetime and the epoch.
|
inlinestatic |
Load into the specified result the relative time computed as the difference between the specified absolute datetime and the epoch. Return 0 on success, and a non-zero value (with no effect on result) if datetime - epoch() < DatetimeInterval() or datetime cannot be represented in the destination format on all supported platforms (i.e., the computed *result is not representable as a 32-bit int). Note that datetime is assumed to use Coordinated Universal Time (UTC) as a reference.
|
inlinestatic |
Return the relative time computed as the difference between the specified absolute datetime and the epoch. The behavior is undefined unless datetime - epoch() >= DatetimeInterval() and the converted datetime can be represented in the destination format on all supported platforms (i.e., the resultant value is representable as a 32-bit int). Note that datetime is assumed to use Coordinated Universal Time (UTC) as a reference. Also note that if error detection is desired, the overloaded version that loads the converted datetime into a supplied destination object should be used.
|
inlinestatic |
Return the relative time computed as the difference between the specified absolute datetime and the epoch. Note that datetime is assumed to use Coordinated Universal Time (UTC) as a reference.
Load into the specified result the relative time computed as the difference between the specified absolute datetime and the epoch. Note that datetime is assumed to use Coordinated Universal Time (UTC) as a reference.
|
inlinestatic |
Return a reference providing non-modifiable access to the epoch time: midnight on January 1, 1970. Note that this value exists before any code is executed and will continue to exist, unchanged, until the program exits.