8#ifndef INCLUDED_BDLT_DATE
9#define INCLUDED_BDLT_DATE
259#include <bdlscm_version.h>
274#include <bsl_iosfwd.h>
310 template <
class HASHALG>
324 static bool isValidSerial(
int serialDate);
326#ifndef BDE_OPENSOURCE_PUBLICATION
327 #ifdef BDE_USE_PROLEPTIC_DATES
328 #error 'BDE_USE_PROLEPTIC_DATES' option disallowed for Bloomberg code.
332#ifdef BDE_USE_PROLEPTIC_DATES
340 static int convertProlepticDateToPosix(
int serialDate);
349 static int convertPosixDateToProleptic(
int serialDate);
357 explicit Date(
int serialDate);
491 template <
class STREAM>
534 template <
class STREAM>
550 bsl::ostream&
print(bsl::ostream& stream,
552 int spacesPerLevel = 4)
const;
554#ifndef BDE_OPENSOURCE_PUBLICATION
585#ifndef BDE_OMIT_INTERNAL_DEPRECATED
603 bsl::ostream&
streamOut(bsl::ostream& stream)
const;
698template <
class HASHALG>
711bool Date::isValidSerial(
int serialDate)
717#ifdef BDE_USE_PROLEPTIC_DATES
719int Date::convertProlepticDateToPosix(
int serialDate)
721 if (1 != serialDate) {
730int Date::convertPosixDateToProleptic(
int serialDate)
732 if (serialDate > 3) {
736 else if (serialDate > 0) {
746: d_serialDate(serialDate)
753bool Date::isValidYearDay(
int year,
int dayOfYear)
755 return SerialDateImpUtil::isValidYearDay(year, dayOfYear);
759bool Date::isValidYearMonthDay(
int year,
int month,
int day)
761 return SerialDateImpUtil::isValidYearMonthDay(year, month, day);
767int Date::maxSupportedBdexVersion(
int )
795: d_serialDate(original.d_serialDate)
809 d_serialDate = rhs.d_serialDate;
816 BSLS_REVIEW(Date::isValidSerial(d_serialDate + numDays));
818 d_serialDate += numDays;
825 BSLS_REVIEW(Date::isValidSerial(d_serialDate - numDays));
827 d_serialDate -= numDays;
860 enum { k_SUCCESS = 0, k_FAILURE = -1 };
883 enum { k_SUCCESS = 0, k_FAILURE = -1 };
895template <
class STREAM>
901 int tmpSerialDate = 0;
903 stream.getInt24(tmpSerialDate);
905#ifdef BDE_USE_PROLEPTIC_DATES
906 tmpSerialDate = convertPosixDateToProleptic(tmpSerialDate);
909 if (stream && Date::isValidSerial(tmpSerialDate)) {
910 d_serialDate = tmpSerialDate;
984template <
class STREAM>
990#ifndef BDE_OPENSOURCE_PUBLICATION
997#ifdef BDE_USE_PROLEPTIC_DATES
998 stream.putInt24(convertProlepticDateToPosix(d_serialDate));
1000 stream.putInt24(d_serialDate);
1005 stream.invalidate();
1012#ifndef BDE_OPENSOURCE_PUBLICATION
1034#ifndef BDE_OMIT_INTERNAL_DEPRECATED
1044 return print(stream, 0, -1);
1067 return lhs.d_serialDate == rhs.d_serialDate;
1073 return lhs.d_serialDate != rhs.d_serialDate;
1079 return date.print(stream, 0, -1);
1085 return lhs.d_serialDate < rhs.d_serialDate;
1091 return lhs.d_serialDate <= rhs.d_serialDate;
1097 return lhs.d_serialDate > rhs.d_serialDate;
1103 return lhs.d_serialDate >= rhs.d_serialDate;
1129 BSLS_REVIEW(Date::isValidSerial(date.d_serialDate + numDays));
1131 return Date(date.d_serialDate + numDays);
1137 BSLS_REVIEW(Date::isValidSerial(numDays + date.d_serialDate));
1139 return Date(numDays + date.d_serialDate);
1145 BSLS_REVIEW(Date::isValidSerial(date.d_serialDate - numDays));
1147 return Date(date.d_serialDate - numDays);
1153 return lhs.d_serialDate - rhs.d_serialDate;
1157template <
class HASHALG>
1161 using ::BloombergLP::bslh::hashAppend;
Definition bdlt_date.h:294
void setYearDay(int year, int dayOfYear)
Definition bdlt_date.h:850
friend bool operator>=(const Date &, const Date &)
friend bool operator>(const Date &, const Date &)
void getYearMonthDay(int *year, int *month, int *day) const
Definition bdlt_date.h:955
friend Date operator-(const Date &, int)
bsl::ostream & streamOut(bsl::ostream &stream) const
Definition bdlt_date.h:1042
~Date()
Destroy this object.
Definition bdlt_date.h:800
static int maxSupportedBdexVersion()
Definition bdlt_date.h:1028
friend int operator-(const Date &, const Date &)
int dayOfYear() const
Return the day of the year in the range [1 .. 366] of this date.
Definition bdlt_date.h:940
static bool isValid(int year, int dayOfYear)
Definition bdlt_date.h:1016
bsl::ostream & print(bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
static bool isValidYearDay(int year, int dayOfYear)
Definition bdlt_date.h:753
friend void hashAppend(HASHALG &hashAlg, const Date &)
int day() const
Return the day of the month in the range [1 .. 31] of this date.
Definition bdlt_date.h:927
int setYearMonthDayIfValid(int year, int month, int day)
Definition bdlt_date.h:881
void setYearMonthDay(int year, int month, int day)
Definition bdlt_date.h:871
int validateAndSetYearDay(int year, int dayOfYear)
Definition bdlt_date.h:1048
Date & operator--()
Definition bdlt_date.h:841
int addDaysIfValid(int numDays)
Date & operator++()
Definition bdlt_date.h:832
Date & operator=(const Date &rhs)
Definition bdlt_date.h:807
static int maxSupportedVersion()
Definition bdlt_date.h:1036
MonthOfYear::Enum monthOfYear() const
Definition bdlt_date.h:971
int year() const
Return the year in the range [1 .. 9999] of this date.
Definition bdlt_date.h:977
static bool isValidYearMonthDay(int year, int month, int day)
Definition bdlt_date.h:759
friend bool operator!=(const Date &, const Date &)
STREAM & bdexStreamOut(STREAM &stream, int version) const
Definition bdlt_date.h:985
int validateAndSetYearMonthDay(int year, int month, int day)
Definition bdlt_date.h:1054
friend Date operator+(const Date &, int)
Date & operator-=(int numDays)
Definition bdlt_date.h:823
Date()
Definition bdlt_date.h:774
int month() const
Return the month of the year in the range [1 .. 12] of this date.
Definition bdlt_date.h:965
int setYearDayIfValid(int year, int dayOfYear)
Definition bdlt_date.h:858
friend bool operator<(const Date &, const Date &)
friend bool operator==(const Date &, const Date &)
Date & operator+=(int numDays)
Definition bdlt_date.h:814
friend Date operator+(int, const Date &)
void getYearDay(int *year, int *dayOfYear) const
Definition bdlt_date.h:946
friend bool operator<=(const Date &, const Date &)
DayOfWeek::Enum dayOfWeek() const
Definition bdlt_date.h:933
STREAM & bdexStreamIn(STREAM &stream, int version)
Definition bdlt_date.h:896
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_ASSERT_OPT(X)
Definition bsls_assert.h:1856
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_PRECONDITIONS_END()
Definition bsls_preconditions.h:131
#define BSLS_PRECONDITIONS_BEGIN()
Definition bsls_preconditions.h:130
#define BSLS_REVIEW(X)
Definition bsls_review.h:949
void hashAppend(HASH_ALGORITHM &hashAlg, const baljsn::EncoderTestAddress &object)
Definition baljsn_encoder_testtypes.h:9236
Definition bbldc_basicisma30360.h:112
bool operator>(const Date &lhs, const Date &rhs)
bool operator<(const Date &lhs, const Date &rhs)
Calendar_BusinessDayConstIter operator++(Calendar_BusinessDayConstIter &iterator, int)
Definition bdlt_calendar.h:2156
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)
Calendar_BusinessDayConstIter operator--(Calendar_BusinessDayConstIter &iterator, int)
Definition bdlt_calendar.h:2165
Definition bdlbb_blob.h:576
Enum
Enumerated day-of-week values.
Definition bdlt_dayofweek.h:123
Enum
Define the list of month-of-year values.
Definition bdlt_monthofyear.h:134
Definition bdlt_posixdateimputil.h:525
static bool isValidSerial(int serialDay)
Definition bdlt_posixdateimputil.h:760
static void serialToYmd(int *year, int *month, int *day, int serialDay)
static int serialToYear(int serialDay)
static int serialToMonth(int serialDay)
static int ymdToSerial(int year, int month, int day)
static int serialToDay(int serialDay)
static int ydToSerial(int year, int dayOfYear)
static int serialToDayOfWeek(int serialDay)
static void serialToYd(int *year, int *dayOfYear, int serialDay)
static int serialToDayOfYear(int serialDay)
Definition bdlt_posixdateimputil.h:768
Definition bslmf_isbitwisecopyable.h:298