BLPAPI C++  3.23.2
blpapi_datetime.h
Go to the documentation of this file.
1 /* Copyright 2012. Bloomberg Finance L.P.
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy
4  * of this software and associated documentation files (the "Software"), to
5  * deal in the Software without restriction, including without limitation the
6  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7  * sell copies of the Software, and to permit persons to whom the Software is
8  * furnished to do so, subject to the following conditions: The above
9  * copyright notice and this permission notice shall be included in all copies
10  * or substantial portions of the Software.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
18  * IN THE SOFTWARE.
19  */
20 
28 #ifndef INCLUDED_BLPAPI_DATETIME
29 #define INCLUDED_BLPAPI_DATETIME
30 
74 #ifndef INCLUDED_BLPAPI_CALL
75 #include <blpapi_call.h>
76 #endif
77 
78 #ifndef INCLUDED_BLPAPI_DEFS
79 #include <blpapi_defs.h>
80 #endif
81 
82 #ifndef INCLUDED_BLPAPI_EXCEPTION
83 #include <blpapi_exception.h>
84 #endif
85 
86 #ifndef INCLUDED_BLPAPI_STREAMPROXY
87 #include <blpapi_streamproxy.h>
88 #endif
89 
90 #ifndef INCLUDED_BLPAPI_TIMEPOINT
91 #include <blpapi_timepoint.h>
92 #endif
93 
94 #ifndef INCLUDED_BLPAPI_TYPES
95 #include <blpapi_types.h>
96 #endif
97 
98 #ifdef __cplusplus
99 extern "C" {
100 #endif
101 
112  blpapi_Int16_t offset; // (signed) minutes ahead of UTC
113 };
114 
117  blpapi_UInt32_t picoseconds; // picosecond offset into current
118  // *millisecond* i.e. the picosecond offset
119  // into the current full second is
120  // '1000000000LL * milliSeconds + picoseconds'
121 };
122 
124 
127 
130  blpapi_StreamWriter_t streamWriter,
131  void *stream,
132  int level,
133  int spacesPerLevel);
134 
138  const blpapi_HighPrecisionDatetime_t *rhs);
139 
143  blpapi_StreamWriter_t streamWriter,
144  void *stream,
145  int level,
146  int spacesPerLevel);
147 
151  const blpapi_TimePoint_t *timePoint,
152  short offset);
153 
154 #ifdef __cplusplus
155 } // extern "C"
156 
157 #ifndef INCLUDED_CASSERT
158 #include <cassert>
159 #define INCLUDED_CASSERT
160 #endif
161 
162 #ifndef INCLUDED_CSTRING
163 #include <cstring> // for std::memset
164 #define INCLUDED_CSTRING
165 #endif
166 
167 #ifndef INCLUDED_IOSFWD
168 #include <iosfwd>
169 #define INCLUDED_IOSFWD
170 #endif
171 
179 namespace BloombergLP {
180 namespace blpapi {
181 
190 
196  enum Value {
197 
207 
210 
213 
216 
219 
222  };
223 };
224 
245 class Datetime {
246 
248 
249  static bool isLeapYear(int year);
250 
251  struct TimeTag { };
252  Datetime(unsigned hours, unsigned minutes, unsigned seconds, TimeTag);
270  public:
272  struct Milliseconds {
273  int d_msec;
274  explicit Milliseconds(int milliseconds);
279  };
280  struct Microseconds {
281  int d_usec;
282  explicit Microseconds(int microseconds);
287  };
288  struct Nanoseconds {
289  int d_nsec;
290  explicit Nanoseconds(int nanoseconds);
295  };
296  struct Picoseconds {
297  long long d_psec;
298  explicit Picoseconds(long long picoseconds);
303  };
304  struct Offset {
306  explicit Offset(short minutesAheadOfUTC);
311  };
312 
313  static bool isValidDate(int year, int month, int day);
322  static bool isValidTime(int hours, int minutes, int seconds);
323  static bool isValidTime(
324  int hours, int minutes, int seconds, int milliSeconds);
325  static bool isValidTime(int hours,
326  int minutes,
327  int seconds,
328  Milliseconds fractionOfSecond);
329  static bool isValidTime(int hours,
330  int minutes,
331  int seconds,
332  Microseconds fractionOfSecond);
333  static bool isValidTime(
334  int hours, int minutes, int seconds, Nanoseconds fractionOfSecond);
335  static bool isValidTime(
336  int hours, int minutes, int seconds, Picoseconds fractionOfSecond);
346  static Datetime createDatetime(unsigned year,
347  unsigned month,
348  unsigned day,
349  unsigned hours,
350  unsigned minutes,
351  unsigned seconds);
366  static Datetime createDatetime(unsigned year,
367  unsigned month,
368  unsigned day,
369  unsigned hours,
370  unsigned minutes,
371  unsigned seconds,
372  Offset offset);
388  static Datetime createDatetime(unsigned year,
389  unsigned month,
390  unsigned day,
391  unsigned hours,
392  unsigned minutes,
393  unsigned seconds,
394  Milliseconds fractionOfSecond);
395  static Datetime createDatetime(unsigned year,
396  unsigned month,
397  unsigned day,
398  unsigned hours,
399  unsigned minutes,
400  unsigned seconds,
401  Microseconds fractionOfSecond);
402  static Datetime createDatetime(unsigned year,
403  unsigned month,
404  unsigned day,
405  unsigned hours,
406  unsigned minutes,
407  unsigned seconds,
408  Nanoseconds fractionOfSecond);
409  static Datetime createDatetime(unsigned year,
410  unsigned month,
411  unsigned day,
412  unsigned hours,
413  unsigned minutes,
414  unsigned seconds,
415  Picoseconds fractionOfSecond);
431  static Datetime createDatetime(unsigned year,
432  unsigned month,
433  unsigned day,
434  unsigned hours,
435  unsigned minutes,
436  unsigned seconds,
437  Milliseconds fractionOfSecond,
438  Offset offset);
439  static Datetime createDatetime(unsigned year,
440  unsigned month,
441  unsigned day,
442  unsigned hours,
443  unsigned minutes,
444  unsigned seconds,
445  Microseconds fractionOfSecond,
446  Offset offset);
447  static Datetime createDatetime(unsigned year,
448  unsigned month,
449  unsigned day,
450  unsigned hours,
451  unsigned minutes,
452  unsigned seconds,
453  Nanoseconds fractionOfSecond,
454  Offset offset);
455  static Datetime createDatetime(unsigned year,
456  unsigned month,
457  unsigned day,
458  unsigned hours,
459  unsigned minutes,
460  unsigned seconds,
461  Picoseconds fractionOfSecond,
462  Offset offset);
477  static Datetime createDate(unsigned year, unsigned month, unsigned day);
488  static Datetime createTime(
489  unsigned hours, unsigned minutes, unsigned seconds);
501  static Datetime createTime(
502  unsigned hours, unsigned minutes, unsigned seconds, Offset offset);
515  static Datetime createTime(unsigned hours,
516  unsigned minutes,
517  unsigned seconds,
518  unsigned milliseconds);
530  static Datetime createTime(unsigned hours,
531  unsigned minutes,
532  unsigned seconds,
533  unsigned milliseconds,
534  Offset offset);
547  static Datetime createTime(unsigned hours,
548  unsigned minutes,
549  unsigned seconds,
550  Milliseconds fractionOfSecond);
551  static Datetime createTime(unsigned hours,
552  unsigned minutes,
553  unsigned seconds,
554  Microseconds fractionOfSecond);
555  static Datetime createTime(unsigned hours,
556  unsigned minutes,
557  unsigned seconds,
558  Nanoseconds fractionOfSecond);
559  static Datetime createTime(unsigned hours,
560  unsigned minutes,
561  unsigned seconds,
562  Picoseconds fractionOfSecond);
574  static Datetime createTime(unsigned hours,
575  unsigned minutes,
576  unsigned seconds,
577  Milliseconds fractionOfSecond,
578  Offset offset);
579  static Datetime createTime(unsigned hours,
580  unsigned minutes,
581  unsigned seconds,
582  Microseconds fractionOfSecond,
583  Offset offset);
584  static Datetime createTime(unsigned hours,
585  unsigned minutes,
586  unsigned seconds,
587  Nanoseconds fractionOfSecond,
588  Offset offset);
589  static Datetime createTime(unsigned hours,
590  unsigned minutes,
591  unsigned seconds,
592  Picoseconds fractionOfSecond,
593  Offset offset);
606  Datetime();
611  Datetime(const Datetime& original);
617 
619 
620  Datetime(unsigned year,
621  unsigned month,
622  unsigned day,
623  unsigned hours,
624  unsigned minutes,
625  unsigned seconds);
642  Datetime(unsigned year,
643  unsigned month,
644  unsigned day,
645  unsigned hours,
646  unsigned minutes,
647  unsigned seconds,
648  unsigned milliseconds);
665  Datetime(unsigned year,
666  unsigned month,
667  unsigned day,
668  unsigned hours,
669  unsigned minutes,
670  unsigned seconds,
671  Milliseconds fractionOfSecond);
672  Datetime(unsigned year,
673  unsigned month,
674  unsigned day,
675  unsigned hours,
676  unsigned minutes,
677  unsigned seconds,
678  Microseconds fractionOfSecond);
679  Datetime(unsigned year,
680  unsigned month,
681  unsigned day,
682  unsigned hours,
683  unsigned minutes,
684  unsigned seconds,
685  Nanoseconds fractionOfSecond);
686  Datetime(unsigned year,
687  unsigned month,
688  unsigned day,
689  unsigned hours,
690  unsigned minutes,
691  unsigned seconds,
692  Picoseconds fractionOfSecond);
710  Datetime(unsigned year, unsigned month, unsigned day);
726  Datetime(unsigned hours,
727  unsigned minutes,
728  unsigned seconds,
729  unsigned milliseconds);
743  Datetime(unsigned hours,
744  unsigned minutes,
745  unsigned seconds,
746  Milliseconds fractionOfSecond);
747  Datetime(unsigned hours,
748  unsigned minutes,
749  unsigned seconds,
750  Microseconds fractionOfSecond);
751  Datetime(unsigned hours,
752  unsigned minutes,
753  unsigned seconds,
754  Nanoseconds fractionOfSecond);
755  Datetime(unsigned hours,
756  unsigned minutes,
757  unsigned seconds,
758  Picoseconds fractionOfSecond);
772  Datetime& operator=(const Datetime& rhs);
777  void setDate(unsigned year, unsigned month, unsigned day);
786  void setTime(unsigned hours, unsigned minutes, unsigned seconds);
796  void setTime(unsigned hours,
797  unsigned minutes,
798  unsigned seconds,
799  unsigned milliseconds);
809  void setTime(unsigned hours,
810  unsigned minutes,
811  unsigned seconds,
812  Milliseconds fractionOfSecond);
813  void setTime(unsigned hours,
814  unsigned minutes,
815  unsigned seconds,
816  Microseconds fractionOfSecond);
817  void setTime(unsigned hours,
818  unsigned minutes,
819  unsigned seconds,
820  Nanoseconds fractionOfSecond);
821  void setTime(unsigned hours,
822  unsigned minutes,
823  unsigned seconds,
824  Picoseconds fractionOfSecond);
834  void setOffset(short minutesAheadOfUTC);
842  void setYear(unsigned value);
852  void setMonth(unsigned value);
862  void setDay(unsigned value);
872  void setHours(unsigned value);
879  void setMinutes(unsigned value);
886  void setSeconds(unsigned value);
893  void setMilliseconds(unsigned milliseconds);
900  void setFractionOfSecond(Milliseconds value);
907  void setFractionOfSecond(Microseconds value);
914  void setFractionOfSecond(Nanoseconds value);
921  void setFractionOfSecond(Picoseconds value);
960  bool hasParts(unsigned parts) const;
968  unsigned parts() const;
975  unsigned year() const;
981  unsigned month() const;
987  unsigned day() const;
993  unsigned hours() const;
999  unsigned minutes() const;
1006  unsigned seconds() const;
1013  unsigned milliSeconds() const;
1021  unsigned milliseconds() const;
1028  unsigned microseconds() const;
1035  unsigned nanoseconds() const;
1042  unsigned long long picoseconds() const;
1049  short offset() const;
1056  const blpapi_Datetime_t& rawValue() const;
1068  const HighPrecision& highPrecisionValue() const;
1074  bool isValid() const;
1086  std::ostream& print(
1087  std::ostream& stream, int level = 0, int spacesPerLevel = 4) const;
1103 };
1104 
1112 
1113  static Datetime fromTimePoint(const TimePoint& timePoint,
1114  Datetime::Offset offset = Datetime::Offset(0));
1122 };
1123 
1127 // ============================================================================
1128 // INLINE FUNCTION DEFINITIONS
1129 // ============================================================================
1130 
1131 // --------------
1132 // class Datetime
1133 // --------------
1134 
1135 // FREE OPERATORS
1136 bool operator==(const Datetime& lhs, const Datetime& rhs);
1144 bool operator!=(const Datetime& lhs, const Datetime& rhs);
1152 bool operator<(const Datetime& lhs, const Datetime& rhs);
1153 bool operator<=(const Datetime& lhs, const Datetime& rhs);
1154 bool operator>(const Datetime& lhs, const Datetime& rhs);
1155 bool operator>=(const Datetime& lhs, const Datetime& rhs);
1166 std::ostream& operator<<(std::ostream& stream, const Datetime& datetime);
1179 inline bool Datetime::isLeapYear(int y)
1180 {
1181  return 0 == y % 4 && (y <= 1752 || 0 != y % 100 || 0 == y % 400);
1182 }
1183 
1184 inline Datetime::Datetime(
1185  unsigned newHours, unsigned newMinutes, unsigned newSeconds, TimeTag)
1186 {
1187  std::memset(&d_value, 0, sizeof(d_value));
1188  setTime(newHours, newMinutes, newSeconds);
1189 }
1190 
1192  : d_msec(milliseconds)
1193 {
1194 }
1195 
1197  : d_usec(microseconds)
1198 {
1199 }
1200 
1202  : d_nsec(nanoseconds)
1203 {
1204 }
1205 
1207  : d_psec(picoseconds)
1208 {
1209 }
1210 
1211 inline Datetime::Offset::Offset(short minutesAheadOfUTC)
1212  : d_minutesAheadOfUTC(minutesAheadOfUTC)
1213 {
1214 }
1215 
1216 inline bool Datetime::isValidDate(int year, int month, int day)
1217 {
1218  if ((year <= 0) || (year > 9999) || (month <= 0) || (month > 12)
1219  || (day <= 0) || (day > 31)) {
1220  return false;
1221  }
1222  if (year == 1752) {
1223  if (month == 9 && day > 2 && day < 14) {
1224  return false;
1225  }
1226  }
1227  if (day < 29) {
1228  return true;
1229  }
1230  switch (month) {
1231  case 1:
1232  case 3:
1233  case 5:
1234  case 7:
1235  case 8:
1236  case 10:
1237  case 12:
1238  return true;
1239 
1240  case 4:
1241  case 6:
1242  case 9:
1243  case 11: {
1244  if (day > 30) {
1245  return false;
1246  } else {
1247  return true;
1248  }
1249  }
1250  case 2: {
1251  if (isLeapYear(year)) {
1252  if (day > 29) {
1253  return false;
1254  } else {
1255  return true;
1256  }
1257  } else if (day > 28) {
1258  return false;
1259  } else {
1260  return true;
1261  }
1262  }
1263  default: {
1264  return true;
1265  }
1266  }
1267 }
1268 
1269 inline bool Datetime::isValidTime(int hours, int minutes, int seconds)
1270 {
1271  return (hours >= 0) && (hours < 24) && (minutes >= 0) && (minutes < 60)
1272  && (seconds >= 0) && (seconds < 60);
1273 }
1274 
1276  int hours, int minutes, int seconds, int milliSeconds)
1277 {
1278  return (hours >= 0) && (hours < 24) && (minutes >= 0) && (minutes < 60)
1279  && (seconds >= 0) && (seconds < 60) && (milliSeconds >= 0)
1280  && (milliSeconds < 1000);
1281 }
1282 
1284  int hours, int minutes, int seconds, Milliseconds fractionOfSecond)
1285 {
1286  return isValidTime(hours, minutes, seconds, fractionOfSecond.d_msec);
1287 }
1288 
1290  int hours, int minutes, int seconds, Microseconds fractionOfSecond)
1291 {
1292  return (hours >= 0) && (hours < 24) && (minutes >= 0) && (minutes < 60)
1293  && (seconds >= 0) && (seconds < 60)
1294  && (fractionOfSecond.d_usec >= 0)
1295  && (fractionOfSecond.d_usec < 1000 * 1000);
1296 }
1297 
1299  int hours, int minutes, int seconds, Nanoseconds fractionOfSecond)
1300 {
1301  return (hours >= 0) && (hours < 24) && (minutes >= 0) && (minutes < 60)
1302  && (seconds >= 0) && (seconds < 60)
1303  && (fractionOfSecond.d_nsec >= 0)
1304  && (fractionOfSecond.d_nsec < 1000 * 1000 * 1000);
1305 }
1306 
1308  int hours, int minutes, int seconds, Picoseconds fractionOfSecond)
1309 {
1310  return (hours >= 0) && (hours < 24) && (minutes >= 0) && (minutes < 60)
1311  && (seconds >= 0) && (seconds < 60)
1312  && (fractionOfSecond.d_psec >= 0)
1313  && (fractionOfSecond.d_psec < 1000LL * 1000 * 1000 * 1000);
1314 }
1315 
1317  unsigned month,
1318  unsigned day,
1319  unsigned hours,
1320  unsigned minutes,
1321  unsigned seconds)
1322 {
1323  return Datetime(year, month, day, hours, minutes, seconds);
1324 }
1325 
1327  unsigned month,
1328  unsigned day,
1329  unsigned hours,
1330  unsigned minutes,
1331  unsigned seconds,
1332  Offset offset)
1333 {
1335  dt.setOffset(offset.d_minutesAheadOfUTC);
1336  return dt;
1337 }
1338 
1340  unsigned month,
1341  unsigned day,
1342  unsigned hours,
1343  unsigned minutes,
1344  unsigned seconds,
1345  Milliseconds fractionOfSecond)
1346 {
1347  return Datetime(
1348  year, month, day, hours, minutes, seconds, fractionOfSecond);
1349 }
1350 
1352  unsigned month,
1353  unsigned day,
1354  unsigned hours,
1355  unsigned minutes,
1356  unsigned seconds,
1357  Microseconds fractionOfSecond)
1358 {
1359  return Datetime(
1360  year, month, day, hours, minutes, seconds, fractionOfSecond);
1361 }
1362 
1364  unsigned month,
1365  unsigned day,
1366  unsigned hours,
1367  unsigned minutes,
1368  unsigned seconds,
1369  Nanoseconds fractionOfSecond)
1370 {
1371  return Datetime(
1372  year, month, day, hours, minutes, seconds, fractionOfSecond);
1373 }
1374 
1376  unsigned month,
1377  unsigned day,
1378  unsigned hours,
1379  unsigned minutes,
1380  unsigned seconds,
1381  Picoseconds fractionOfSecond)
1382 {
1383  return Datetime(
1384  year, month, day, hours, minutes, seconds, fractionOfSecond);
1385 }
1386 
1388  unsigned month,
1389  unsigned day,
1390  unsigned hours,
1391  unsigned minutes,
1392  unsigned seconds,
1393  Milliseconds fractionOfSecond,
1394  Offset offset)
1395 {
1396  Datetime dt(year, month, day, hours, minutes, seconds, fractionOfSecond);
1397  dt.setOffset(offset.d_minutesAheadOfUTC);
1398  return dt;
1399 }
1400 
1402  unsigned month,
1403  unsigned day,
1404  unsigned hours,
1405  unsigned minutes,
1406  unsigned seconds,
1407  Microseconds fractionOfSecond,
1408  Offset offset)
1409 {
1410  Datetime dt(year, month, day, hours, minutes, seconds, fractionOfSecond);
1411  dt.setOffset(offset.d_minutesAheadOfUTC);
1412  return dt;
1413 }
1414 
1416  unsigned month,
1417  unsigned day,
1418  unsigned hours,
1419  unsigned minutes,
1420  unsigned seconds,
1421  Nanoseconds fractionOfSecond,
1422  Offset offset)
1423 {
1424  Datetime dt(year, month, day, hours, minutes, seconds, fractionOfSecond);
1425  dt.setOffset(offset.d_minutesAheadOfUTC);
1426  return dt;
1427 }
1428 
1430  unsigned month,
1431  unsigned day,
1432  unsigned hours,
1433  unsigned minutes,
1434  unsigned seconds,
1435  Picoseconds fractionOfSecond,
1436  Offset offset)
1437 {
1438  Datetime dt(year, month, day, hours, minutes, seconds, fractionOfSecond);
1439  dt.setOffset(offset.d_minutesAheadOfUTC);
1440  return dt;
1441 }
1442 
1444  unsigned year, unsigned month, unsigned day)
1445 {
1446  return Datetime(year, month, day);
1447 }
1448 
1450  unsigned hours, unsigned minutes, unsigned seconds)
1451 {
1452  return Datetime(hours, minutes, seconds, TimeTag());
1453 }
1454 
1456  unsigned hours, unsigned minutes, unsigned seconds, Offset offset)
1457 {
1458  Datetime dt(hours, minutes, seconds, TimeTag());
1459  dt.setOffset(offset.d_minutesAheadOfUTC);
1460  return dt;
1461 }
1462 
1464  unsigned minutes,
1465  unsigned seconds,
1466  unsigned milliseconds)
1467 {
1469 }
1470 
1471 inline
1472 
1473  Datetime
1475  unsigned minutes,
1476  unsigned seconds,
1477  unsigned milliseconds,
1478  Offset offset)
1479 {
1481  dt.setOffset(offset.d_minutesAheadOfUTC);
1482  return dt;
1483 }
1484 
1486  unsigned minutes,
1487  unsigned seconds,
1488  Milliseconds fractionOfSecond)
1489 {
1490  return Datetime(hours, minutes, seconds, fractionOfSecond);
1491 }
1492 
1494  unsigned minutes,
1495  unsigned seconds,
1496  Microseconds fractionOfSecond)
1497 {
1498  return Datetime(hours, minutes, seconds, fractionOfSecond);
1499 }
1500 
1502  unsigned minutes,
1503  unsigned seconds,
1504  Nanoseconds fractionOfSecond)
1505 {
1506  return Datetime(hours, minutes, seconds, fractionOfSecond);
1507 }
1508 
1510  unsigned minutes,
1511  unsigned seconds,
1512  Picoseconds fractionOfSecond)
1513 {
1514  return Datetime(hours, minutes, seconds, fractionOfSecond);
1515 }
1516 
1518  unsigned minutes,
1519  unsigned seconds,
1520  Milliseconds fractionOfSecond,
1521  Offset offset)
1522 {
1523  Datetime dt(hours, minutes, seconds, fractionOfSecond);
1524  dt.setOffset(offset.d_minutesAheadOfUTC);
1525  return dt;
1526 }
1527 
1529  unsigned minutes,
1530  unsigned seconds,
1531  Microseconds fractionOfSecond,
1532  Offset offset)
1533 {
1534  Datetime dt(hours, minutes, seconds, fractionOfSecond);
1535  dt.setOffset(offset.d_minutesAheadOfUTC);
1536  return dt;
1537 }
1538 
1540  unsigned minutes,
1541  unsigned seconds,
1542  Nanoseconds fractionOfSecond,
1543  Offset offset)
1544 {
1545  Datetime dt(hours, minutes, seconds, fractionOfSecond);
1546  dt.setOffset(offset.d_minutesAheadOfUTC);
1547  return dt;
1548 }
1549 
1551  unsigned minutes,
1552  unsigned seconds,
1553  Picoseconds fractionOfSecond,
1554  Offset offset)
1555 {
1556  Datetime dt(hours, minutes, seconds, fractionOfSecond);
1557  dt.setOffset(offset.d_minutesAheadOfUTC);
1558  return dt;
1559 }
1560 
1562 {
1563  std::memset(&d_value, 0, sizeof(d_value));
1564  d_value.datetime.year = 1;
1565  d_value.datetime.month = 1;
1566  d_value.datetime.day = 1;
1567 }
1568 
1569 inline Datetime::Datetime(const Datetime& original)
1570  : d_value(original.d_value)
1571 {
1572 }
1573 
1574 inline Datetime::Datetime(const blpapi_Datetime_t& newRawValue)
1575 {
1576  d_value.datetime = newRawValue;
1577  d_value.picoseconds = 0;
1578 }
1579 
1581  : d_value(newRawValue)
1582 {
1583 }
1584 
1585 inline Datetime::Datetime(unsigned newYear,
1586  unsigned newMonth,
1587  unsigned newDay,
1588  unsigned newHours,
1589  unsigned newMinutes,
1590  unsigned newSeconds)
1591 {
1592  d_value.datetime.offset = 0;
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);
1597  d_value.datetime.minutes = static_cast<blpapi_UChar_t>(newMinutes);
1598  d_value.datetime.seconds = static_cast<blpapi_UChar_t>(newSeconds);
1599  d_value.datetime.milliSeconds = 0;
1600  d_value.picoseconds = 0;
1602 }
1603 
1604 inline Datetime::Datetime(unsigned newYear,
1605  unsigned newMonth,
1606  unsigned newDay,
1607  unsigned newHours,
1608  unsigned newMinutes,
1609  unsigned newSeconds,
1610  unsigned newMilliSeconds)
1611 {
1612  d_value.datetime.offset = 0;
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);
1617  d_value.datetime.minutes = static_cast<blpapi_UChar_t>(newMinutes);
1618  d_value.datetime.seconds = static_cast<blpapi_UChar_t>(newSeconds);
1619  d_value.datetime.milliSeconds
1620  = static_cast<blpapi_UInt16_t>(newMilliSeconds);
1621  d_value.picoseconds = 0;
1622  d_value.datetime.parts
1624 }
1625 
1626 inline Datetime::Datetime(unsigned newYear,
1627  unsigned newMonth,
1628  unsigned newDay,
1629  unsigned newHours,
1630  unsigned newMinutes,
1631  unsigned newSeconds,
1632  Milliseconds fractionOfSecond)
1633 {
1634  d_value.datetime.offset = 0;
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);
1639  d_value.datetime.minutes = static_cast<blpapi_UChar_t>(newMinutes);
1640  d_value.datetime.seconds = static_cast<blpapi_UChar_t>(newSeconds);
1641  d_value.datetime.milliSeconds
1642  = static_cast<blpapi_UInt16_t>(fractionOfSecond.d_msec);
1643  d_value.picoseconds = 0;
1644  d_value.datetime.parts
1646 }
1647 
1648 inline Datetime::Datetime(unsigned newYear,
1649  unsigned newMonth,
1650  unsigned newDay,
1651  unsigned newHours,
1652  unsigned newMinutes,
1653  unsigned newSeconds,
1654  Microseconds fractionOfSecond)
1655 {
1656  d_value.datetime.offset = 0;
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);
1661  d_value.datetime.minutes = static_cast<blpapi_UChar_t>(newMinutes);
1662  d_value.datetime.seconds = static_cast<blpapi_UChar_t>(newSeconds);
1663  d_value.datetime.milliSeconds
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);
1667  d_value.datetime.parts
1669 }
1670 
1671 inline Datetime::Datetime(unsigned newYear,
1672  unsigned newMonth,
1673  unsigned newDay,
1674  unsigned newHours,
1675  unsigned newMinutes,
1676  unsigned newSeconds,
1677  Nanoseconds fractionOfSecond)
1678 {
1679  d_value.datetime.offset = 0;
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);
1684  d_value.datetime.minutes = static_cast<blpapi_UChar_t>(newMinutes);
1685  d_value.datetime.seconds = static_cast<blpapi_UChar_t>(newSeconds);
1686  d_value.datetime.milliSeconds = static_cast<blpapi_UInt16_t>(
1687  fractionOfSecond.d_nsec / 1000 / 1000);
1688  d_value.picoseconds = static_cast<blpapi_UInt32_t>(
1689  (fractionOfSecond.d_nsec % (1000 * 1000)) * 1000);
1690  d_value.datetime.parts
1692 }
1693 
1694 inline Datetime::Datetime(unsigned newYear,
1695  unsigned newMonth,
1696  unsigned newDay,
1697  unsigned newHours,
1698  unsigned newMinutes,
1699  unsigned newSeconds,
1700  Picoseconds fractionOfSecond)
1701 {
1702  d_value.datetime.offset = 0;
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);
1707  d_value.datetime.minutes = static_cast<blpapi_UChar_t>(newMinutes);
1708  d_value.datetime.seconds = static_cast<blpapi_UChar_t>(newSeconds);
1709  d_value.datetime.milliSeconds = static_cast<blpapi_UInt16_t>(
1710  fractionOfSecond.d_psec / 1000 / 1000 / 1000);
1711  d_value.picoseconds = static_cast<blpapi_UInt32_t>(
1712  fractionOfSecond.d_psec % (1000 * 1000 * 1000));
1713  d_value.datetime.parts
1715 }
1716 
1717 inline Datetime::Datetime(unsigned newYear, unsigned newMonth, unsigned newDay)
1718 {
1719  std::memset(&d_value, 0, sizeof(d_value));
1720  setDate(newYear, newMonth, newDay);
1721 }
1722 
1723 inline Datetime::Datetime(unsigned newHours,
1724  unsigned newMinutes,
1725  unsigned newSeconds,
1726  unsigned newMilliSeconds)
1727 {
1728  std::memset(&d_value, 0, sizeof(d_value));
1729  setTime(newHours, newMinutes, newSeconds, newMilliSeconds);
1730 }
1731 
1732 inline Datetime::Datetime(unsigned newHours,
1733  unsigned newMinutes,
1734  unsigned newSeconds,
1735  Milliseconds fractionOfSecond)
1736 {
1737  std::memset(&d_value, 0, sizeof(d_value));
1738  setTime(newHours, newMinutes, newSeconds, fractionOfSecond);
1739 }
1740 
1741 inline Datetime::Datetime(unsigned newHours,
1742  unsigned newMinutes,
1743  unsigned newSeconds,
1744  Microseconds fractionOfSecond)
1745 {
1746  std::memset(&d_value, 0, sizeof(d_value));
1747  setTime(newHours, newMinutes, newSeconds, fractionOfSecond);
1748 }
1749 
1750 inline Datetime::Datetime(unsigned newHours,
1751  unsigned newMinutes,
1752  unsigned newSeconds,
1753  Nanoseconds fractionOfSecond)
1754 {
1755  std::memset(&d_value, 0, sizeof(d_value));
1756  setTime(newHours, newMinutes, newSeconds, fractionOfSecond);
1757 }
1758 
1759 inline Datetime::Datetime(unsigned newHours,
1760  unsigned newMinutes,
1761  unsigned newSeconds,
1762  Picoseconds fractionOfSecond)
1763 {
1764  std::memset(&d_value, 0, sizeof(d_value));
1765  setTime(newHours, newMinutes, newSeconds, fractionOfSecond);
1766 }
1767 
1769 {
1770  d_value = rhs.d_value;
1771  return *this;
1772 }
1773 
1774 inline void Datetime::setDate(
1775  unsigned newYear, unsigned newMonth, unsigned newDay)
1776 {
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);
1780  d_value.datetime.parts |= DatetimeParts::DATE;
1781 }
1782 
1783 inline void Datetime::setTime(
1784  unsigned newHours, unsigned newMinutes, unsigned newSeconds)
1785 {
1786  d_value.datetime.hours = static_cast<blpapi_UChar_t>(newHours);
1787  d_value.datetime.minutes = static_cast<blpapi_UChar_t>(newMinutes);
1788  d_value.datetime.seconds = static_cast<blpapi_UChar_t>(newSeconds);
1789  d_value.datetime.milliSeconds = 0;
1790  d_value.picoseconds = 0;
1791  d_value.datetime.parts = static_cast<blpapi_UChar_t>(
1794 }
1795 
1796 inline void Datetime::setTime(unsigned newHours,
1797  unsigned newMinutes,
1798  unsigned newSeconds,
1799  unsigned newMilliSeconds)
1800 {
1801  d_value.datetime.hours = static_cast<blpapi_UChar_t>(newHours);
1802  d_value.datetime.minutes = static_cast<blpapi_UChar_t>(newMinutes);
1803  d_value.datetime.seconds = static_cast<blpapi_UChar_t>(newSeconds);
1804  d_value.datetime.milliSeconds
1805  = static_cast<blpapi_UInt16_t>(newMilliSeconds);
1806  d_value.picoseconds = 0;
1808 }
1809 
1810 inline void Datetime::setTime(unsigned newHours,
1811  unsigned newMinutes,
1812  unsigned newSeconds,
1813  Milliseconds fractionOfSecond)
1814 {
1815  d_value.datetime.hours = static_cast<blpapi_UChar_t>(newHours);
1816  d_value.datetime.minutes = static_cast<blpapi_UChar_t>(newMinutes);
1817  d_value.datetime.seconds = static_cast<blpapi_UChar_t>(newSeconds);
1818  d_value.datetime.milliSeconds
1819  = static_cast<blpapi_UInt16_t>(fractionOfSecond.d_msec);
1820  d_value.picoseconds = 0;
1822 }
1823 
1824 inline void Datetime::setTime(unsigned newHours,
1825  unsigned newMinutes,
1826  unsigned newSeconds,
1827  Microseconds fractionOfSecond)
1828 {
1829  d_value.datetime.hours = static_cast<blpapi_UChar_t>(newHours);
1830  d_value.datetime.minutes = static_cast<blpapi_UChar_t>(newMinutes);
1831  d_value.datetime.seconds = static_cast<blpapi_UChar_t>(newSeconds);
1832  d_value.datetime.milliSeconds
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);
1837 }
1838 
1839 inline void Datetime::setTime(unsigned newHours,
1840  unsigned newMinutes,
1841  unsigned newSeconds,
1842  Nanoseconds fractionOfSecond)
1843 {
1844  d_value.datetime.hours = static_cast<blpapi_UChar_t>(newHours);
1845  d_value.datetime.minutes = static_cast<blpapi_UChar_t>(newMinutes);
1846  d_value.datetime.seconds = static_cast<blpapi_UChar_t>(newSeconds);
1847  d_value.datetime.milliSeconds = static_cast<blpapi_UInt16_t>(
1848  fractionOfSecond.d_nsec / 1000 / 1000);
1849  d_value.picoseconds = static_cast<blpapi_UInt32_t>(
1850  fractionOfSecond.d_nsec % (1000 * 1000) * 1000);
1852 }
1853 
1854 inline void Datetime::setTime(unsigned newHours,
1855  unsigned newMinutes,
1856  unsigned newSeconds,
1857  Picoseconds fractionOfSecond)
1858 {
1859  d_value.datetime.hours = static_cast<blpapi_UChar_t>(newHours);
1860  d_value.datetime.minutes = static_cast<blpapi_UChar_t>(newMinutes);
1861  d_value.datetime.seconds = static_cast<blpapi_UChar_t>(newSeconds);
1862  d_value.datetime.milliSeconds = static_cast<blpapi_UInt16_t>(
1863  fractionOfSecond.d_psec / 1000 / 1000 / 1000);
1864  d_value.picoseconds = static_cast<blpapi_UInt32_t>(
1865  fractionOfSecond.d_psec % (1000 * 1000 * 1000));
1867 }
1868 
1869 inline void Datetime::setOffset(short value)
1870 {
1871  d_value.datetime.offset = value;
1873 }
1874 
1875 inline void Datetime::setYear(unsigned value)
1876 {
1877  d_value.datetime.year = static_cast<blpapi_UInt16_t>(value);
1878  d_value.datetime.parts |= DatetimeParts::YEAR;
1879 }
1880 
1881 inline void Datetime::setMonth(unsigned value)
1882 {
1883  d_value.datetime.month = static_cast<blpapi_UChar_t>(value);
1884  d_value.datetime.parts |= DatetimeParts::MONTH;
1885 }
1886 
1887 inline void Datetime::setDay(unsigned value)
1888 {
1889  d_value.datetime.day = static_cast<blpapi_UChar_t>(value);
1890  d_value.datetime.parts |= DatetimeParts::DAY;
1891 }
1892 
1893 inline void Datetime::setHours(unsigned value)
1894 {
1895  d_value.datetime.hours = static_cast<blpapi_UChar_t>(value);
1896  d_value.datetime.parts |= DatetimeParts::HOURS;
1897 }
1898 
1899 inline void Datetime::setMinutes(unsigned value)
1900 {
1901  d_value.datetime.minutes = static_cast<blpapi_UChar_t>(value);
1903 }
1904 
1905 inline void Datetime::setSeconds(unsigned value)
1906 {
1907  d_value.datetime.seconds = static_cast<blpapi_UChar_t>(value);
1909 }
1910 
1911 inline void Datetime::setMilliseconds(unsigned value)
1912 {
1913  d_value.datetime.milliSeconds = static_cast<blpapi_UInt16_t>(value);
1914  d_value.picoseconds = 0;
1916 }
1917 
1919 {
1920  d_value.datetime.milliSeconds = static_cast<blpapi_UInt16_t>(value.d_msec);
1921  d_value.picoseconds = 0;
1923 }
1924 
1926 {
1927  d_value.datetime.milliSeconds
1928  = static_cast<blpapi_UInt16_t>(value.d_usec / 1000);
1929  d_value.picoseconds
1930  = static_cast<blpapi_UInt32_t>(value.d_usec % 1000 * 1000 * 1000);
1932 }
1933 
1935 {
1936  d_value.datetime.milliSeconds
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);
1941 }
1942 
1944 {
1945  d_value.datetime.milliSeconds
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));
1950 }
1951 
1952 inline blpapi_Datetime_t& Datetime::rawValue() { return d_value.datetime; }
1953 
1955 {
1956  return d_value;
1957 }
1958 
1959 inline bool Datetime::hasParts(unsigned newParts) const
1960 {
1961  return newParts == (d_value.datetime.parts & newParts);
1962 }
1963 
1964 inline unsigned Datetime::parts() const { return d_value.datetime.parts; }
1965 
1966 inline unsigned Datetime::year() const { return d_value.datetime.year; }
1967 
1968 inline unsigned Datetime::month() const { return d_value.datetime.month; }
1969 
1970 inline unsigned Datetime::day() const { return d_value.datetime.day; }
1971 
1972 inline unsigned Datetime::hours() const { return d_value.datetime.hours; }
1973 
1974 inline unsigned Datetime::minutes() const { return d_value.datetime.minutes; }
1975 
1976 inline unsigned Datetime::seconds() const { return d_value.datetime.seconds; }
1977 
1978 inline unsigned Datetime::milliSeconds() const
1979 {
1980  return d_value.datetime.milliSeconds;
1981 }
1982 
1983 inline unsigned Datetime::milliseconds() const
1984 {
1985  return d_value.datetime.milliSeconds;
1986 }
1987 
1988 inline unsigned Datetime::microseconds() const
1989 {
1990  return d_value.datetime.milliSeconds * 1000
1991  + d_value.picoseconds / 1000 / 1000;
1992 }
1993 
1994 inline unsigned Datetime::nanoseconds() const
1995 {
1996  return d_value.datetime.milliSeconds * 1000 * 1000
1997  + d_value.picoseconds / 1000;
1998 }
1999 
2000 inline unsigned long long Datetime::picoseconds() const
2001 {
2002  return d_value.datetime.milliSeconds * 1000LLU * 1000U * 1000U
2003  + d_value.picoseconds;
2004 }
2005 
2006 inline short Datetime::offset() const { return d_value.datetime.offset; }
2007 
2009 {
2010  return d_value.datetime;
2011 }
2012 
2013 inline const blpapi_HighPrecisionDatetime_t&
2015 {
2016  return d_value;
2017 }
2018 
2020 {
2021  return d_value;
2022 }
2023 
2024 inline bool Datetime::isValid() const
2025 {
2028  && !isValidDate(static_cast<int>(year()),
2029  static_cast<int>(month()),
2030  static_cast<int>(day()))) {
2031  return false;
2032  }
2036  && !isValidTime(static_cast<int>(hours()),
2037  static_cast<int>(minutes()),
2038  static_cast<int>(seconds()),
2039  static_cast<int>(milliSeconds()))) {
2040  return false;
2041  }
2043  && (picoseconds() >= 1000LL * 1000 * 1000 * 1000)) {
2044  return false;
2045  }
2046  return true;
2047 }
2048 
2049 inline std::ostream& Datetime::print(
2050  std::ostream& stream, int level, int spacesPerLevel) const
2051 {
2054  &stream,
2055  level,
2056  spacesPerLevel);
2057  return stream;
2058 }
2059 
2060 inline bool operator==(const Datetime& lhs, const Datetime& rhs)
2061 {
2062  if (lhs.parts() == rhs.parts()) {
2064  &lhs.rawHighPrecisionValue(),
2065  &rhs.rawHighPrecisionValue())
2066  == 0);
2067  }
2068  return false;
2069 }
2070 
2071 inline bool operator!=(const Datetime& lhs, const Datetime& rhs)
2072 {
2073  return !(lhs == rhs);
2074 }
2075 
2076 inline bool operator<(const Datetime& lhs, const Datetime& rhs)
2077 {
2080  < 0);
2081 }
2082 
2083 inline bool operator<=(const Datetime& lhs, const Datetime& rhs)
2084 {
2085  return !(rhs < lhs);
2086 }
2087 
2088 inline bool operator>(const Datetime& lhs, const Datetime& rhs)
2089 {
2090  return rhs < lhs;
2091 }
2092 
2093 inline bool operator>=(const Datetime& lhs, const Datetime& rhs)
2094 {
2095  return !(lhs < rhs);
2096 }
2097 
2098 inline std::ostream& operator<<(std::ostream& stream, const Datetime& datetime)
2099 {
2100  return datetime.print(stream, 0, -1);
2101 }
2102 
2103 // ------------------
2104 // class DatetimeUtil
2105 // ------------------
2106 
2108  const TimePoint& timePoint, Datetime::Offset offset)
2109 {
2110  blpapi_HighPrecisionDatetime_t highPrecisionDatetime;
2112  &highPrecisionDatetime, &timePoint, offset.d_minutesAheadOfUTC);
2113  return Datetime(highPrecisionDatetime);
2114 }
2115 
2116 } // close namespace blpapi
2117 } // close namespace BloombergLP
2118 
2119 #endif // #ifdef __cplusplus
2120 
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:220
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
Provide BLPAPI types.
#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