Quick Links:

bal | bbl | bdl | bsl

Public Types | Static Public Member Functions

bdlt::EpochUtil Struct Reference

#include <bdlt_epochutil.h>

List of all members.

Public Types

typedef bsls::Types::Int64 TimeT64

Static Public Member Functions

static const Datetimeepoch ()
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)

Detailed Description

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.

See Component bdlt_epochutil


Member Typedef Documentation


Member Function Documentation

static const Datetime& bdlt::EpochUtil::epoch (  )  [static]

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.

static Datetime bdlt::EpochUtil::convertFromTimeT ( bsl::time_t  time  )  [static]

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.

static void bdlt::EpochUtil::convertFromTimeT ( Datetime result,
bsl::time_t  time 
) [static]

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.

static bsl::time_t bdlt::EpochUtil::convertToTimeT ( const Datetime datetime  )  [static]

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.

static int bdlt::EpochUtil::convertToTimeT ( bsl::time_t *  result,
const Datetime datetime 
) [static]

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.

static Datetime bdlt::EpochUtil::convertFromTimeT64 ( TimeT64  time  )  [static]

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.

static int bdlt::EpochUtil::convertFromTimeT64 ( Datetime result,
TimeT64  time 
) [static]

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.

static TimeT64 bdlt::EpochUtil::convertToTimeT64 ( const Datetime datetime  )  [static]

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.

static void bdlt::EpochUtil::convertToTimeT64 ( TimeT64 result,
const Datetime datetime 
) [static]

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.

static Datetime bdlt::EpochUtil::convertFromTimeInterval ( const bsls::TimeInterval timeInterval  )  [static]

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.

static void bdlt::EpochUtil::convertFromTimeInterval ( Datetime result,
const bsls::TimeInterval timeInterval 
) [static]

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.

static bsls::TimeInterval bdlt::EpochUtil::convertToTimeInterval ( const Datetime datetime  )  [static]

Return, as a bsls::TimeInterval, the relative time computed as the difference between the specified absolute datetime and the epoch.

static Datetime bdlt::EpochUtil::convertFromDatetimeInterval ( const DatetimeInterval datetimeInterval  )  [static]

Return, as a Datetime, the absolute datetime computed as the sum of the specified relative datetimeInterval and the epoch. The behavior is undefined unless the conversion result can be represented as a Datetime.

static void bdlt::EpochUtil::convertFromDatetimeInterval ( Datetime result,
const DatetimeInterval datetimeInterval 
) [static]

Load into the specified result the absolute datetime converted to a Datetime, computed as the sum of the specified relative datetimeInterval and the epoch. The behavior is undefined unless the conversion result can be represented as a Datetime.

static DatetimeInterval bdlt::EpochUtil::convertToDatetimeInterval ( const Datetime datetime  )  [static]

Return, as a DatetimeInterval, the relative time computed as the difference between the specified absolute datetime and the epoch.

static int bdlt::EpochUtil::convertToTimeInterval ( bsls::TimeInterval result,
const Datetime datetime 
) [static]

DEPRECATED: Use convertToTimeInterval(datetime) instead.

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).

static int bdlt::EpochUtil::convertToDatetimeInterval ( DatetimeInterval result,
const Datetime datetime 
) [static]

DEPRECATED: Use convertToDatetimeInterval(datetime) instead.

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).


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