28 #ifndef INCLUDED_BLPAPI_DATETIME 29 #define INCLUDED_BLPAPI_DATETIME 74 #ifndef INCLUDED_BLPAPI_CALL 78 #ifndef INCLUDED_BLPAPI_DEFS 82 #ifndef INCLUDED_BLPAPI_EXCEPTION 86 #ifndef INCLUDED_BLPAPI_STREAMPROXY 90 #ifndef INCLUDED_BLPAPI_TIMEPOINT 94 #ifndef INCLUDED_BLPAPI_TYPES 157 #ifndef INCLUDED_CASSERT 159 #define INCLUDED_CASSERT 162 #ifndef INCLUDED_CSTRING 164 #define INCLUDED_CSTRING 167 #ifndef INCLUDED_IOSFWD 169 #define INCLUDED_IOSFWD 249 static bool isLeapYear(
int year);
306 explicit Offset(
short minutesAheadOfUTC);
862 void setDay(
unsigned value);
968 unsigned parts()
const;
975 unsigned year()
const;
981 unsigned month()
const;
987 unsigned day()
const;
993 unsigned hours()
const;
1086 std::ostream&
print(
1087 std::ostream& stream,
int level = 0,
int spacesPerLevel = 4)
const;
1179 inline bool Datetime::isLeapYear(
int y)
1181 return 0 == y % 4 && (y <= 1752 || 0 != y % 100 || 0 == y % 400);
1185 unsigned newHours,
unsigned newMinutes,
unsigned newSeconds, TimeTag)
1187 std::memset(&d_value, 0,
sizeof(d_value));
1188 setTime(newHours, newMinutes, newSeconds);
1192 : d_msec(milliseconds)
1212 : d_minutesAheadOfUTC(minutesAheadOfUTC)
1219 || (
day <= 0) || (
day > 31)) {
1251 if (isLeapYear(
year)) {
1257 }
else if (
day > 28) {
1294 && (fractionOfSecond.
d_usec >= 0)
1295 && (fractionOfSecond.
d_usec < 1000 * 1000);
1303 && (fractionOfSecond.
d_nsec >= 0)
1304 && (fractionOfSecond.
d_nsec < 1000 * 1000 * 1000);
1312 && (fractionOfSecond.
d_psec >= 0)
1313 && (fractionOfSecond.
d_psec < 1000LL * 1000 * 1000 * 1000);
1563 std::memset(&d_value, 0,
sizeof(d_value));
1570 : d_value(original.d_value)
1581 : d_value(newRawValue)
1589 unsigned newMinutes,
1590 unsigned newSeconds)
1593 d_value.
datetime.
year = static_cast<blpapi_UInt16_t>(newYear);
1594 d_value.
datetime.
month = static_cast<blpapi_UChar_t>(newMonth);
1595 d_value.
datetime.
day = static_cast<blpapi_UChar_t>(newDay);
1596 d_value.
datetime.
hours = static_cast<blpapi_UChar_t>(newHours);
1608 unsigned newMinutes,
1609 unsigned newSeconds,
1610 unsigned newMilliSeconds)
1613 d_value.
datetime.
year = static_cast<blpapi_UInt16_t>(newYear);
1614 d_value.
datetime.
month = static_cast<blpapi_UChar_t>(newMonth);
1615 d_value.
datetime.
day = static_cast<blpapi_UChar_t>(newDay);
1616 d_value.
datetime.
hours = static_cast<blpapi_UChar_t>(newHours);
1620 = static_cast<blpapi_UInt16_t>(newMilliSeconds);
1630 unsigned newMinutes,
1631 unsigned newSeconds,
1635 d_value.
datetime.
year = static_cast<blpapi_UInt16_t>(newYear);
1636 d_value.
datetime.
month = static_cast<blpapi_UChar_t>(newMonth);
1637 d_value.
datetime.
day = static_cast<blpapi_UChar_t>(newDay);
1638 d_value.
datetime.
hours = static_cast<blpapi_UChar_t>(newHours);
1642 = static_cast<blpapi_UInt16_t>(fractionOfSecond.
d_msec);
1652 unsigned newMinutes,
1653 unsigned newSeconds,
1657 d_value.
datetime.
year = static_cast<blpapi_UInt16_t>(newYear);
1658 d_value.
datetime.
month = static_cast<blpapi_UChar_t>(newMonth);
1659 d_value.
datetime.
day = static_cast<blpapi_UChar_t>(newDay);
1660 d_value.
datetime.
hours = static_cast<blpapi_UChar_t>(newHours);
1664 = static_cast<blpapi_UInt16_t>(fractionOfSecond.
d_usec / 1000);
1665 d_value.
picoseconds = static_cast<blpapi_UInt32_t>(
1666 (fractionOfSecond.
d_usec % 1000) * 1000 * 1000);
1675 unsigned newMinutes,
1676 unsigned newSeconds,
1680 d_value.
datetime.
year = static_cast<blpapi_UInt16_t>(newYear);
1681 d_value.
datetime.
month = static_cast<blpapi_UChar_t>(newMonth);
1682 d_value.
datetime.
day = static_cast<blpapi_UChar_t>(newDay);
1683 d_value.
datetime.
hours = static_cast<blpapi_UChar_t>(newHours);
1687 fractionOfSecond.
d_nsec / 1000 / 1000);
1688 d_value.
picoseconds = static_cast<blpapi_UInt32_t>(
1689 (fractionOfSecond.
d_nsec % (1000 * 1000)) * 1000);
1698 unsigned newMinutes,
1699 unsigned newSeconds,
1703 d_value.
datetime.
year = static_cast<blpapi_UInt16_t>(newYear);
1704 d_value.
datetime.
month = static_cast<blpapi_UChar_t>(newMonth);
1705 d_value.
datetime.
day = static_cast<blpapi_UChar_t>(newDay);
1706 d_value.
datetime.
hours = static_cast<blpapi_UChar_t>(newHours);
1710 fractionOfSecond.
d_psec / 1000 / 1000 / 1000);
1711 d_value.
picoseconds = static_cast<blpapi_UInt32_t>(
1712 fractionOfSecond.
d_psec % (1000 * 1000 * 1000));
1719 std::memset(&d_value, 0,
sizeof(d_value));
1720 setDate(newYear, newMonth, newDay);
1724 unsigned newMinutes,
1725 unsigned newSeconds,
1726 unsigned newMilliSeconds)
1728 std::memset(&d_value, 0,
sizeof(d_value));
1729 setTime(newHours, newMinutes, newSeconds, newMilliSeconds);
1733 unsigned newMinutes,
1734 unsigned newSeconds,
1737 std::memset(&d_value, 0,
sizeof(d_value));
1738 setTime(newHours, newMinutes, newSeconds, fractionOfSecond);
1742 unsigned newMinutes,
1743 unsigned newSeconds,
1746 std::memset(&d_value, 0,
sizeof(d_value));
1747 setTime(newHours, newMinutes, newSeconds, fractionOfSecond);
1751 unsigned newMinutes,
1752 unsigned newSeconds,
1755 std::memset(&d_value, 0,
sizeof(d_value));
1756 setTime(newHours, newMinutes, newSeconds, fractionOfSecond);
1760 unsigned newMinutes,
1761 unsigned newSeconds,
1764 std::memset(&d_value, 0,
sizeof(d_value));
1765 setTime(newHours, newMinutes, newSeconds, fractionOfSecond);
1770 d_value = rhs.d_value;
1775 unsigned newYear,
unsigned newMonth,
unsigned newDay)
1777 d_value.
datetime.
day = static_cast<blpapi_UChar_t>(newDay);
1778 d_value.
datetime.
month = static_cast<blpapi_UChar_t>(newMonth);
1779 d_value.
datetime.
year = static_cast<blpapi_UInt16_t>(newYear);
1784 unsigned newHours,
unsigned newMinutes,
unsigned newSeconds)
1786 d_value.
datetime.
hours = static_cast<blpapi_UChar_t>(newHours);
1797 unsigned newMinutes,
1798 unsigned newSeconds,
1799 unsigned newMilliSeconds)
1801 d_value.
datetime.
hours = static_cast<blpapi_UChar_t>(newHours);
1805 = static_cast<blpapi_UInt16_t>(newMilliSeconds);
1811 unsigned newMinutes,
1812 unsigned newSeconds,
1815 d_value.
datetime.
hours = static_cast<blpapi_UChar_t>(newHours);
1819 = static_cast<blpapi_UInt16_t>(fractionOfSecond.
d_msec);
1825 unsigned newMinutes,
1826 unsigned newSeconds,
1829 d_value.
datetime.
hours = static_cast<blpapi_UChar_t>(newHours);
1833 = static_cast<blpapi_UInt16_t>(fractionOfSecond.
d_usec / 1000);
1834 d_value.
picoseconds = static_cast<blpapi_UInt32_t>(
1835 fractionOfSecond.
d_usec % 1000 * 1000 * 1000);
1840 unsigned newMinutes,
1841 unsigned newSeconds,
1844 d_value.
datetime.
hours = static_cast<blpapi_UChar_t>(newHours);
1848 fractionOfSecond.
d_nsec / 1000 / 1000);
1849 d_value.
picoseconds = static_cast<blpapi_UInt32_t>(
1850 fractionOfSecond.
d_nsec % (1000 * 1000) * 1000);
1855 unsigned newMinutes,
1856 unsigned newSeconds,
1859 d_value.
datetime.
hours = static_cast<blpapi_UChar_t>(newHours);
1863 fractionOfSecond.
d_psec / 1000 / 1000 / 1000);
1864 d_value.
picoseconds = static_cast<blpapi_UInt32_t>(
1865 fractionOfSecond.
d_psec % (1000 * 1000 * 1000));
1877 d_value.
datetime.
year = static_cast<blpapi_UInt16_t>(value);
1883 d_value.
datetime.
month = static_cast<blpapi_UChar_t>(value);
1889 d_value.
datetime.
day = static_cast<blpapi_UChar_t>(value);
1895 d_value.
datetime.
hours = static_cast<blpapi_UChar_t>(value);
1928 = static_cast<blpapi_UInt16_t>(value.
d_usec / 1000);
1930 = static_cast<blpapi_UInt32_t>(value.
d_usec % 1000 * 1000 * 1000);
1937 = static_cast<blpapi_UInt16_t>(value.
d_nsec / 1000 / 1000);
1938 d_value.
picoseconds = static_cast<blpapi_UInt32_t>(
1939 value.
d_nsec % (1000 * 1000) * 1000);
1946 = static_cast<blpapi_UInt16_t>(value.
d_psec / 1000 / 1000 / 1000);
1947 d_value.
picoseconds = static_cast<blpapi_UInt32_t>(
1948 value.
d_psec % (1000 * 1000 * 1000));
2029 static_cast<int>(
month()),
2030 static_cast<int>(
day()))) {
2043 && (
picoseconds() >= 1000LL * 1000 * 1000 * 1000)) {
2050 std::ostream& stream,
int level,
int spacesPerLevel)
const 2073 return !(lhs == rhs);
2085 return !(rhs < lhs);
2095 return !(lhs < rhs);
2100 return datetime.
print(stream, 0, -1);
2113 return Datetime(highPrecisionDatetime);
2119 #endif // #ifdef __cplusplus 2121 #endif // #ifndef INCLUDED_BLPAPI_DATETIME offset is set
Definition: blpapi_datetime.h:201
Definition: blpapi_timepoint.h:104
blpapi_UChar_t day
Definition: blpapi_datetime.h:110
blpapi_UInt16_t milliSeconds
Definition: blpapi_datetime.h:108
int d_msec
Definition: blpapi_datetime.h:273
void setDate(unsigned year, unsigned month, unsigned day)
Definition: blpapi_datetime.h:1774
#define BLPAPI_DATETIME_TIMEMILLI_PART
Definition: blpapi_defs.h:76
static bool isValidTime(int hours, int minutes, int seconds)
Definition: blpapi_datetime.h:1269
blpapi_UChar_t hours
Definition: blpapi_datetime.h:105
year is set
Definition: blpapi_datetime.h:198
bool operator!=(const CorrelationId &lhs, const CorrelationId &rhs)
Definition: blpapi_correlationid.h:582
unsigned short blpapi_UInt16_t
Definition: blpapi_types.h:66
#define BLPAPI_CALL_HIGHPRECISIONDATETIME_COMPARE(a1, a2)
Definition: blpapi_call.h:395
void setYear(unsigned value)
Definition: blpapi_datetime.h:1875
static bool isValidDate(int year, int month, int day)
Definition: blpapi_datetime.h:1216
int d_nsec
Definition: blpapi_datetime.h:289
#define BLPAPI_DATETIME_YEAR_PART
Definition: blpapi_defs.h:61
#define BLPAPI_CALL_HIGHPRECISIONDATETIME_FROMTIMEPOINT(a1, a2, a3)
Definition: blpapi_call.h:465
bool hasParts(unsigned parts) const
Definition: blpapi_datetime.h:1959
#define BLPAPI_DATETIME_DATE_PART
Definition: blpapi_defs.h:70
Common definitions used by the library.
bool operator==(const CorrelationId &lhs, const CorrelationId &rhs)
Definition: blpapi_correlationid.h:562
bool operator<=(const Datetime &lhs, const Datetime &rhs)
Definition: blpapi_datetime.h:2083
int d_usec
Definition: blpapi_datetime.h:281
#define BLPAPI_DATETIME_MILLISECONDS_PART
Definition: blpapi_defs.h:68
#define BLPAPI_DATETIME_HOURS_PART
Definition: blpapi_defs.h:65
bool operator<(const CorrelationId &lhs, const CorrelationId &rhs)
Definition: blpapi_correlationid.h:587
Definition: blpapi_abstractsession.h:215
const HighPrecision & highPrecisionValue() const
Definition: blpapi_datetime.h:2019
unsigned month() const
Definition: blpapi_datetime.h:1968
Datetime & operator=(const Datetime &rhs)
Definition: blpapi_datetime.h:1768
#define BLPAPI_DATETIME_TIME_PART
Definition: blpapi_defs.h:73
unsigned milliSeconds() const
Definition: blpapi_datetime.h:1978
blpapi_UChar_t seconds
Definition: blpapi_datetime.h:107
MILLISECONDS is a (legacy) synonym for FRACSECONDS
Definition: blpapi_datetime.h:208
Definition: blpapi_datetime.h:280
#define BLPAPI_DATETIME_TIMEFRACSECONDS_PART
Definition: blpapi_defs.h:78
blpapi_Int16_t offset
Definition: blpapi_datetime.h:112
day is set
Definition: blpapi_datetime.h:200
unsigned minutes() const
Definition: blpapi_datetime.h:1974
static Datetime fromTimePoint(const TimePoint &timePoint, Datetime::Offset offset=Datetime::Offset(0))
Definition: blpapi_datetime.h:2107
blpapi_UInt32_t picoseconds
Definition: blpapi_datetime.h:117
void setMinutes(unsigned value)
Definition: blpapi_datetime.h:1899
Datetime()
Definition: blpapi_datetime.h:1561
static Datetime createDatetime(unsigned year, unsigned month, unsigned day, unsigned hours, unsigned minutes, unsigned seconds)
Definition: blpapi_datetime.h:1316
bool operator>=(const Datetime &lhs, const Datetime &rhs)
Definition: blpapi_datetime.h:2093
static Datetime createTime(unsigned hours, unsigned minutes, unsigned seconds)
Definition: blpapi_datetime.h:1449
unsigned day() const
Definition: blpapi_datetime.h:1970
int(* blpapi_StreamWriter_t)(const char *data, int length, void *stream)
Definition: blpapi_streamproxy.h:53
Value
Definition: blpapi_datetime.h:196
#define BLPAPI_DATETIME_FRACSECONDS_PART
Definition: blpapi_defs.h:69
Definition: blpapi_datetime.h:272
month is set
Definition: blpapi_datetime.h:199
unsigned seconds() const
Definition: blpapi_datetime.h:1976
Definition: blpapi_datetime.h:1111
hours is set
Definition: blpapi_datetime.h:202
Provide a time point with respect to an epoch.
Nanoseconds(int nanoseconds)
Definition: blpapi_datetime.h:1201
Offset(short minutesAheadOfUTC)
Definition: blpapi_datetime.h:1211
unsigned milliseconds() const
Definition: blpapi_datetime.h:1983
unsigned long long picoseconds() const
Definition: blpapi_datetime.h:2000
Definition: blpapi_datetime.h:189
static Datetime createDate(unsigned year, unsigned month, unsigned day)
Definition: blpapi_datetime.h:1443
#define BLPAPI_DATETIME_OFFSET_PART
Definition: blpapi_defs.h:64
Definition: blpapi_datetime.h:288
hours, minutes, seconds, and fraction-of-second are set
Definition: blpapi_datetime.h:217
#define BLPAPI_CALL_HIGHPRECISIONDATETIME_PRINT(a1, a2, a3, a4, a5)
Definition: blpapi_call.h:397
#define BLPAPI_DATETIME_MINUTES_PART
Definition: blpapi_defs.h:66
unsigned microseconds() const
Definition: blpapi_datetime.h:1988
blpapi_UChar_t parts
Definition: blpapi_datetime.h:104
Definition: blpapi_datetime.h:304
blpapi_Datetime_t & rawValue()
Definition: blpapi_datetime.h:1952
std::ostream & operator<<(std::ostream &os, const CorrelationId &correlator)
Definition: blpapi_correlationid.h:592
#define BLPAPI_DATETIME_SECONDS_PART
Definition: blpapi_defs.h:67
seconds is set
Definition: blpapi_datetime.h:204
void setOffset(short minutesAheadOfUTC)
Definition: blpapi_datetime.h:1869
blpapi_UChar_t month
Definition: blpapi_datetime.h:109
BLPAPI_EXPORT int blpapi_Datetime_compare(blpapi_Datetime_t lhs, blpapi_Datetime_t rhs)
Definition: blpapi_datetime.h:102
Picoseconds(long long picoseconds)
Definition: blpapi_datetime.h:1206
BLPAPI_EXPORT int blpapi_HighPrecisionDatetime_compare(const blpapi_HighPrecisionDatetime_t *lhs, const blpapi_HighPrecisionDatetime_t *rhs)
blpapi_HighPrecisionDatetime_t & rawHighPrecisionValue()
Definition: blpapi_datetime.h:1954
void setFractionOfSecond(Milliseconds value)
Definition: blpapi_datetime.h:1918
BLPAPI_EXPORT int blpapi_HighPrecisionDatetime_print(const blpapi_HighPrecisionDatetime_t *datetime, blpapi_StreamWriter_t streamWriter, void *stream, int level, int spacesPerLevel)
void setSeconds(unsigned value)
Definition: blpapi_datetime.h:1905
short blpapi_Int16_t
Definition: blpapi_types.h:65
A signature for callback on print and default C++ implementation.
bool isValid() const
Definition: blpapi_datetime.h:2024
Definition: blpapi_datetime.h:296
TIMEMILLI is a (legacy) synonym for TIMEFRACSECONDS
Definition: blpapi_datetime.h:220
BLPAPI_EXPORT int blpapi_HighPrecisionDatetime_fromTimePoint(blpapi_HighPrecisionDatetime_t *datetime, const blpapi_TimePoint_t *timePoint, short offset)
unsigned year() const
Definition: blpapi_datetime.h:1966
short d_minutesAheadOfUTC
Definition: blpapi_datetime.h:305
blpapi_UInt16_t year
Definition: blpapi_datetime.h:111
blpapi_HighPrecisionDatetime_t HighPrecision
Definition: blpapi_datetime.h:271
Milliseconds(int milliseconds)
Definition: blpapi_datetime.h:1191
long long d_psec
Definition: blpapi_datetime.h:297
unsigned hours() const
Definition: blpapi_datetime.h:1972
void setTime(unsigned hours, unsigned minutes, unsigned seconds)
Definition: blpapi_datetime.h:1783
year, month, and day are set
Definition: blpapi_datetime.h:211
hours, minutes, and seconds are set
Definition: blpapi_datetime.h:214
bool operator>(const Datetime &lhs, const Datetime &rhs)
Definition: blpapi_datetime.h:2088
Defines Exceptions that can be thrown by the blpapi library.
unsigned char blpapi_UChar_t
Definition: blpapi_types.h:64
short offset() const
Definition: blpapi_datetime.h:2006
void setHours(unsigned value)
Definition: blpapi_datetime.h:1893
static int writeToStream(const char *data, int length, void *stream)
Definition: blpapi_streamproxy.h:93
fraction-of-second (both millisecond and picosecond) is set
Definition: blpapi_datetime.h:205
BLPAPI_EXPORT int blpapi_Datetime_print(const blpapi_Datetime_t *datetime, blpapi_StreamWriter_t streamWriter, void *stream, int level, int spacesPerLevel)
unsigned int blpapi_UInt32_t
Definition: blpapi_types.h:68
Microseconds(int microseconds)
Definition: blpapi_datetime.h:1196
#define BLPAPI_EXPORT
Definition: blpapi_defs.h:171
Definition: blpapi_datetime.h:245
Provide functions for dispatchtbl.
void setMonth(unsigned value)
Definition: blpapi_datetime.h:1881
std::ostream & print(std::ostream &stream, int level=0, int spacesPerLevel=4) const
Definition: blpapi_datetime.h:2049
unsigned nanoseconds() const
Definition: blpapi_datetime.h:1994
#define BLPAPI_DATETIME_MONTH_PART
Definition: blpapi_defs.h:62
blpapi_UChar_t minutes
Definition: blpapi_datetime.h:106
void setDay(unsigned value)
Definition: blpapi_datetime.h:1887
#define BLPAPI_DATETIME_DAY_PART
Definition: blpapi_defs.h:63
Definition: blpapi_datetime.h:115
void setMilliseconds(unsigned milliseconds)
Definition: blpapi_datetime.h:1911
unsigned parts() const
Definition: blpapi_datetime.h:1964
minutes is set
Definition: blpapi_datetime.h:203
blpapi_Datetime_t datetime
Definition: blpapi_datetime.h:116