8#ifndef INCLUDED_BDLT_TIME
9#define INCLUDED_BDLT_TIME
150#include <bdlscm_version.h>
168#include <bsl_iosfwd.h>
169#include <bsl_cstring.h>
170#include <bsl_sstream.h>
198 k_DEFAULT_FRACTIONAL_SECOND_PRECISION = 6
221 template <
class HASHALG>
383 int milliseconds = 0,
484 template <
class STREAM>
535 int fractionalSecondPrecision = 6)
const;
548 template <
class STREAM>
565 bsl::ostream&
print(bsl::ostream& stream,
567 int spacesPerLevel = 4)
const;
569#ifndef BDE_OPENSOURCE_PUBLICATION
580#ifndef BDE_OMIT_INTERNAL_DEPRECATED
592 bsl::ostream&
streamOut(bsl::ostream& stream)
const;
615template <
class HASHALG>
702 d_value = totalMicroseconds | k_REP_MASK;
711 return invalidMicrosecondsFromMidnight();
714 return d_value & (~k_REP_MASK);
720 return microsecondsFromMidnight() | k_REP_MASK;
750 if (versionSelector >= 20170401) {
764Time::Time(
int hour,
int minute,
int second,
int millisecond,
int microsecond)
777: d_value(original.d_value)
779 d_value = updatedRepresentation();
786 d_value = rhs.d_value;
787 d_value = updatedRepresentation();
809 enum { k_SUCCESS = 0, k_FAILURE = -1 };
821 enum { k_SUCCESS = 0, k_FAILURE = -1 };
833 enum { k_SUCCESS = 0, k_FAILURE = -1 };
845 enum { k_SUCCESS = 0, k_FAILURE = -1 };
857 enum { k_SUCCESS = 0, k_FAILURE = -1 };
873 enum { k_SUCCESS = 0, k_FAILURE = -1 };
885template <
class STREAM>
892 stream.getInt64(tmp);
897 setMicrosecondsFromMidnight(tmp);
905 stream.getInt32(tmp);
908 &&
static_cast<unsigned int>(tmp) <=
928 return static_cast<int>(microsecondsFromMidnight()
935 return static_cast<int>( microsecondsFromMidnight()
942 return static_cast<int>( microsecondsFromMidnight()
950 return static_cast<int>( microsecondsFromMidnight()
958 return static_cast<int>( microsecondsFromMidnight()
965template <
class STREAM>
971 stream.putInt64(microsecondsFromMidnight());
974 stream.putInt32(
static_cast<int>(microsecondsFromMidnight()
985#ifndef BDE_OPENSOURCE_PUBLICATION
995#ifndef BDE_OMIT_INTERNAL_DEPRECATED
1005 return stream << *
this;
1023 return result += rhs;
1030 return result +=
lhs;
1037 return result -=
rhs;
1043 DatetimeInterval timeInterval;
1045 timeInterval.setTotalMicroseconds(
1049 return timeInterval;
1058 return lhsValue == rhsValue;
1067 return lhsValue != rhsValue;
1074 !=
lhs.microsecondsFromMidnight());
1076 !=
rhs.microsecondsFromMidnight());
1081 return lhsValue < rhsValue;
1088 !=
lhs.microsecondsFromMidnight());
1090 !=
rhs.microsecondsFromMidnight());
1095 return lhsValue <= rhsValue;
1102 !=
lhs.microsecondsFromMidnight());
1104 !=
rhs.microsecondsFromMidnight());
1109 return lhsValue > rhsValue;
1116 !=
lhs.microsecondsFromMidnight());
1118 !=
rhs.microsecondsFromMidnight());
1123 return lhsValue >= rhsValue;
1129 return time.print(stream, 0, -1);
1133template <
class HASHALG>
1137 using ::BloombergLP::bslh::hashAppend;
1138 hashAppend(hashAlg,
object.microsecondsFromMidnight());
Definition bdlt_datetimeinterval.h:201
Definition bdlt_time.h:195
static int maxSupportedBdexVersion()
Definition bdlt_time.h:989
friend bool operator!=(const Time &, const Time &)
int setMicrosecondIfValid(int microsecond)
Definition bdlt_time.h:819
void getTime(int *hour, int *minute=0, int *second=0, int *millisecond=0, int *microsecond=0) const
bsl::ostream & streamOut(bsl::ostream &stream) const
Definition bdlt_time.h:1003
friend bool operator<=(const Time &, const Time &)
void setSecond(int second)
void setTime(int hour, int minute=0, int second=0, int millisecond=0, int microsecond=0)
STREAM & bdexStreamIn(STREAM &stream, int version)
Definition bdlt_time.h:886
int setTimeIfValid(int hour, int minute=0, int second=0, int millisecond=0, int microsecond=0)
Definition bdlt_time.h:867
int addInterval(const DatetimeInterval &interval)
void setMinute(int minute)
int addSeconds(int seconds)
Time & operator=(const Time &rhs)
Definition bdlt_time.h:784
int microsecond() const
Return the value of the microsecond attribute of this time object.
Definition bdlt_time.h:933
friend bool operator>=(const Time &, const Time &)
static int maxSupportedVersion()
Definition bdlt_time.h:997
int setMillisecondIfValid(int millisecond)
Definition bdlt_time.h:831
int addMinutes(int minutes)
int setMinuteIfValid(int minute)
Definition bdlt_time.h:843
static bool isValid(int hour, int minute=0, int second=0, int millisecond=0, int microsecond=0)
Definition bdlt_time.h:725
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
int second() const
Return the value of the second attribute of this time object.
Definition bdlt_time.h:956
void setMillisecond(int millisecond)
Time & operator+=(const DatetimeInterval &rhs)
Definition bdlt_time.h:793
int validateAndSetTime(int hour, int minute=0, int second=0, int millisecond=0)
Definition bdlt_time.h:1009
Time()
Create a Time object having the value 24:00:00.000000.
Definition bdlt_time.h:758
int addMicroseconds(bsls::Types::Int64 microseconds)
friend void hashAppend(HASHALG &hashAlg, const Time &)
int addTime(int hours, int minutes=0, int seconds=0, int milliseconds=0, bsls::Types::Int64 microseconds=0)
int printToBuffer(char *result, int numBytes, int fractionalSecondPrecision=6) const
int millisecond() const
Return the value of the millisecond attribute of this time object.
Definition bdlt_time.h:940
int addMilliseconds(int milliseconds)
int setSecondIfValid(int second)
Definition bdlt_time.h:855
Time & operator-=(const DatetimeInterval &rhs)
Definition bdlt_time.h:800
void setMicrosecond(int microsecond)
~Time()=default
Destroy this Time object.
friend bool operator<(const Time &, const Time &)
STREAM & bdexStreamOut(STREAM &stream, int version) const
Definition bdlt_time.h:966
int minute() const
Return the value of the minute attribute of this time object.
Definition bdlt_time.h:948
int setHourIfValid(int hour)
Definition bdlt_time.h:807
friend bool operator==(const Time &, const Time &)
friend bool operator>(const Time &, const Time &)
int hour() const
Return the value of the hour attribute of this time object.
Definition bdlt_time.h:926
friend DatetimeInterval operator-(const Time &, const Time &)
Definition bsls_atomic.h:896
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1917
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
#define BSLS_REVIEW(X)
Definition bsls_review.h:1019
void hashAppend(HASH_ALGORITHM &hashAlgorithm, const BigEndianInt16 &object)
Definition bbldc_basicisma30360.h:112
bool operator>(const Date &lhs, const Date &rhs)
bool operator<(const Date &lhs, const Date &rhs)
bool operator==(const Calendar &lhs, const Calendar &rhs)
Date operator-(const Date &date, int numDays)
bool operator>=(const Date &lhs, const Date &rhs)
Date operator+(const Date &date, int numDays)
bsl::ostream & operator<<(bsl::ostream &stream, const Calendar &calendar)
bool operator<=(const Date &lhs, const Date &rhs)
void hashAppend(HASHALG &hashAlg, const Calendar &object)
bool operator!=(const Calendar &lhs, const Calendar &rhs)
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
ALLOCATOR & lhs
Definition bslstl_string.h:3917
Definition bdlbb_blob.h:579
Definition bdlt_timeunitratio.h:201
static const bsls::Types::Int64 k_S_PER_M
Definition bdlt_timeunitratio.h:287
static const int k_S_PER_M_32
Definition bdlt_timeunitratio.h:341
static const int k_H_PER_D_32
Definition bdlt_timeunitratio.h:348
static const int k_US_PER_MS_32
Definition bdlt_timeunitratio.h:332
static const int k_MS_PER_D_32
Definition bdlt_timeunitratio.h:339
static const bsls::Types::Int64 k_MS_PER_S
Definition bdlt_timeunitratio.h:282
static const bsls::Types::Int64 k_US_PER_H
Definition bdlt_timeunitratio.h:279
static const int k_M_PER_H_32
Definition bdlt_timeunitratio.h:345
static const bsls::Types::Int64 k_M_PER_H
Definition bdlt_timeunitratio.h:291
static const bsls::Types::Int64 k_US_PER_MS
Definition bdlt_timeunitratio.h:275
static const int k_MS_PER_S_32
Definition bdlt_timeunitratio.h:336
static const bsls::Types::Int64 k_US_PER_D
Definition bdlt_timeunitratio.h:280
static const bsls::Types::Int64 k_US_PER_S
Definition bdlt_timeunitratio.h:277
static const bsls::Types::Int64 k_US_PER_M
Definition bdlt_timeunitratio.h:278
long long Int64
Definition bsls_types.h:134