BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlt::TimeTz Class Reference

#include <bdlt_timetz.h>

Public Member Functions

 TimeTz ()
 Create a TimeTz object having the (default) attribute values.
 
 TimeTz (const Time &localTime, int offset)
 
 TimeTz (const TimeTz &original)
 
 ~TimeTz ()
 Destroy this object.
 
TimeTzoperator= (const TimeTz &rhs)
 
void setTimeTz (const Time &localTime, int offset)
 
int setTimeTzIfValid (const Time &localTime, int offset)
 
template<class STREAM >
STREAM & bdexStreamIn (STREAM &stream, int version)
 
Time localTime () const
 
int offset () const
 Return the time zone offset of this object in minutes from UTC.
 
Time utcTime () const
 
template<class STREAM >
STREAM & bdexStreamOut (STREAM &stream, int version) const
 
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
 
Time gmtTime () const
 
int validateAndSetTimeTz (const Time &localTime, int offset)
 

Static Public Member Functions

static bool isValid (const Time &localTime, int offset)
 
static int maxSupportedBdexVersion (int versionSelector)
 
static int maxSupportedBdexVersion ()
 

Detailed Description

This value-semantic class describes a time value in a particular time zone, which is indicated using an offset from UTC (in minutes). The offset is available via the offset method, and is defined by the relationship: localTime() - offset() == utcTime. The time and offset values are logically assumed to correspond to geographically valid values, however, this constraint is not enforced.

This class:

  • supports a complete set of value-semantic operations
  • supports BDEX streaming For terminology see bsldoc_glossary .

See bdlt_timetz

Constructor & Destructor Documentation

◆ TimeTz() [1/3]

bdlt::TimeTz::TimeTz ( )
inline

◆ TimeTz() [2/3]

bdlt::TimeTz::TimeTz ( const Time localTime,
int  offset 
)
inline

Create a TimeTz object whose local time and offset attributes have the specified localTime and offset values respectively. The behavior is undefined unless offset is in the range ( -1440 .. 1440 ), and offset is 0 if localTime has the value 24:00:00.000. Note that this method provides no validation, and it is the user's responsibility to ensure that offset represents a valid time zone and that localTime represents a valid time in that time zone.

◆ TimeTz() [3/3]

bdlt::TimeTz::TimeTz ( const TimeTz original)
inline

Construct a TimeTz object having the same value as the specified original TimeTz object.

◆ ~TimeTz()

bdlt::TimeTz::~TimeTz ( )
inline

Member Function Documentation

◆ bdexStreamIn()

template<class STREAM >
STREAM & bdlt::TimeTz::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. Note that no version is read from stream. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers.

◆ bdexStreamOut()

template<class STREAM >
STREAM & bdlt::TimeTz::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. Note that version is not written to stream. See the bslx package-level documentation for more information on BDEX streaming of value-semantic types and containers.

◆ gmtTime()

Time bdlt::TimeTz::gmtTime ( ) const
inline
Deprecated:
replaced by utcTime.

Return a Time object having the value of the UTC time represented by this object. Note that the returned value is equal to localTime() - offset() minutes.

◆ isValid()

bool bdlt::TimeTz::isValid ( const Time localTime,
int  offset 
)
inlinestatic

Return true if the specified localTime and the specified time zone offset represent a valid TimeTz value, and false otherwise. A localTime and offset represent a valid TimeTz value if offset is in the range ( -1440 .. 1440 ), and offset is 0 if localTime has the value 24:00:00.000. Note that a true result from this function does not guarantee that offset corresponds to any geographical or historical time zone. Also note that a true result from this function does not guarantee that localTime itself is a valid Time object.

◆ localTime()

Time bdlt::TimeTz::localTime ( ) const
inline

Return a Time object having the value of the local time attribute of this object. Note that the Time value returned is the value stored in this object, and may be different from the local time of the system.

◆ maxSupportedBdexVersion() [1/2]

int bdlt::TimeTz::maxSupportedBdexVersion ( )
inlinestatic
Deprecated:
Use maxSupportedBdexVersion(int) instead.

Return the most current BDEX streaming version number supported by this class.

◆ maxSupportedBdexVersion() [2/2]

int bdlt::TimeTz::maxSupportedBdexVersion ( int  versionSelector)
inlinestatic

Return the maximum valid BDEX format version, as indicated by the specified versionSelector, to be passed to the bdexStreamOut method. Note that it is highly recommended that 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.

◆ offset()

int bdlt::TimeTz::offset ( ) const
inline

◆ operator=()

TimeTz & bdlt::TimeTz::operator= ( const TimeTz rhs)
inline

Assign to this object the value of the specified rhs object, and return a reference providing modifiable access to this object.

◆ print()

bsl::ostream & bdlt::TimeTz::print ( bsl::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 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. Note that the format is not fully specified, and can change without notice.

◆ setTimeTz()

void bdlt::TimeTz::setTimeTz ( const Time localTime,
int  offset 
)
inline

Set the local time and time zone offset attributes of this object to the specified localTime and offset values respectively. The behavior is undefined unless offset is in the range ( -1440 .. 1440 ). Note that this method provides no validation, and it is the user's responsibility to assure the consistency of the resulting value.

◆ setTimeTzIfValid()

int bdlt::TimeTz::setTimeTzIfValid ( const Time localTime,
int  offset 
)
inline

Set the local time and the time zone offset of this object to the specified localTime and offset values respectively if localTime and offset represent a valid TimeTz value, and leave the object unmodified otherwise. Return 0 on success, and a non-zero value otherwise.

◆ utcTime()

Time bdlt::TimeTz::utcTime ( ) const
inline

Return a Time object having the value of the UTC time represented by this object. Note that the returned value is equal to localTime() - offset() minutes.

◆ validateAndSetTimeTz()

int bdlt::TimeTz::validateAndSetTimeTz ( const Time localTime,
int  offset 
)
inline
Deprecated:
replaced by setTimeTzIfValid.

Set the local time and the time zone offset of this object to the specified localTime and offset values respectively if localTime and offset represent a valid TimeTz value. Return 0 on success, and a non-zero value with no effect on this object otherwise.


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