FieldTypes.h
Go to the documentation of this file.
1/* -*- C++ -*- */
2
3/****************************************************************************
4** Copyright (c) 2001-2014
5**
6** This file is part of the QuickFIX FIX Engine
7**
8** This file may be distributed under the terms of the quickfixengine.org
9** license as defined by quickfixengine.org and appearing in the file
10** LICENSE included in the packaging of this file.
11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14**
15** See http://www.quickfixengine.org/LICENSE for licensing information.
16**
17** Contact ask@quickfixengine.org if any conditions of this licensing are
18** not clear to you.
19**
20****************************************************************************/
21
22#ifndef FIX_FIELDTYPES_H
23#define FIX_FIELDTYPES_H
24
25#ifdef _MSC_VER
26#pragma warning( disable : 4503 4355 4786 4290 )
27#endif
28
29#if defined(_MSC_VER) && (_MSC_VER < 1600)
30 #include "stdint_msvc.h"
31#else
32 #include <stdint.h> /* integer types int8_t .. uint64_t, intptr_t */
33#endif
34
35#include "Utility.h"
36#include <string>
37#include <time.h>
38
39namespace FIX
40{
56
57// Precision factor of timestamp. [0] - second, [9] - nanosecond
58static const int PRECISION_FACTOR[10] = {1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1};
59
60struct DateTime
61{
62 int m_date;
64
66 static const int64_t SECONDS_PER_DAY = 86400;
67 static const int64_t SECONDS_PER_HOUR = 3600;
68 static const int64_t SECONDS_PER_MIN = 60;
69 static const int64_t MINUTES_PER_HOUR = 60;
70
71 static const int64_t NANOS_PER_DAY = 86400000000000;
72 static const int64_t NANOS_PER_HOUR = 3600000000000;
73 static const int64_t NANOS_PER_MIN = 60000000000;
74 static const int64_t NANOS_PER_SEC = 1000000000;
75
76 // time_t epoch (1970-01-01) as a Julian date
77 static const int64_t JULIAN_19700101 = 2440588;
78
80 DateTime () : m_date (0), m_time (0) {}
81
84
86 DateTime( int year, int month, int day,
87 int hour, int minute, int second, int millis )
88 {
91 }
92
94 DateTime( int year, int month, int day,
95 int hour, int minute, int second, int fraction, int precision )
96 {
100 }
101
102 virtual ~DateTime() {}
103
105 inline int getYear() const
106 {
107 int y, m, d;
108 getYMD( y, m, d );
109 return y;
110 }
111
113 inline int getMonth() const
114 {
115 int y, m, d;
116 getYMD( y, m, d );
117 return m;
118 }
119
121 inline int getDay() const
122 {
123 int y, m, d;
124 getYMD( y, m, d );
125 return d;
126 }
127
130 inline int getDate() const { return getDay(); }
131
133 inline int getJulianDate() const { return m_date; }
134
136 inline int getHour() const
137 {
138 return (int)(m_time / NANOS_PER_HOUR);
139 }
140
142 inline int getMinute() const
143 {
145 }
146
148 inline int getSecond() const
149 {
151 }
152
154 inline int getMillisecond() const
155 {
156 return (getNanosecond() / PRECISION_FACTOR[3]);
157 }
158
160 inline int getMicroecond() const
161 {
162 return (getNanosecond() / PRECISION_FACTOR[6]);
163 }
164
166 inline unsigned int getNanosecond() const
167 {
168 return static_cast<uint64_t>(m_time) % NANOS_PER_SEC;
169 }
170
172 inline int getFraction(int precision) const
173 {
174 switch (precision)
175 {
176 case 0:
177 return (getNanosecond() / PRECISION_FACTOR[0]);
178
179 case 1:
180 return (getNanosecond() / PRECISION_FACTOR[1]);
181
182 case 2:
183 return (getNanosecond() / PRECISION_FACTOR[2]);
184
185 case 3:
186 return (getNanosecond() / PRECISION_FACTOR[3]);
187
188 case 4:
189 return (getNanosecond() / PRECISION_FACTOR[4]);
190
191 case 5:
192 return (getNanosecond() / PRECISION_FACTOR[5]);
193
194 case 6:
195 return (getNanosecond() / PRECISION_FACTOR[6]);
196
197 case 7:
198 return (getNanosecond() / PRECISION_FACTOR[7]);
199
200 case 8:
201 return (getNanosecond() / PRECISION_FACTOR[8]);
202
203 case 9:
204 default:
205 return (getNanosecond() / PRECISION_FACTOR[9]);
206 }
207 }
208
211 inline void getYMD (int& year, int& month, int& day) const
212 {
213 getYMD( m_date, year, month, day );
214 }
215
218 inline void getHMS( int& hour, int& minute, int& second, int& millis ) const
219 {
220 int ticks = (int)(m_time / NANOS_PER_SEC);
225 }
226
229 inline void getHMS( int& hour, int& minute, int& second, int& fraction, int precision ) const
230 {
231 int ticks = (int)(m_time / NANOS_PER_SEC);
236 }
237
239 inline int getWeekDay() const
240 {
241 int Y, M, D;
242 getYMD (Y, M, D);
243 int m = M >= 3 ? M - 2 : M + 10;
244 int Yprime = M >= 3 ? Y : Y - 1;
245 int y = Yprime % 100;
246 int c = Yprime / 100;
247 int wd = (D + int (2.6 * m - 0.2) + y + int (y / 4) + int (c / 4) -
248 (2 * c)) % 7;
249 return 1 + (wd < 0 ? 7 + wd : wd);
250 }
251
254 inline time_t getTimeT() const
255 {
258 }
259
261 tm getTmUtc() const
262 {
263 int year, month, day;
264 int hour, minute, second, millis;
265 tm result = { 0 };
266
267 getYMD( year, month, day );
269
270 result.tm_year = year - 1900;
271 result.tm_mon = month - 1;
272 result.tm_mday = day;
273 result.tm_hour = hour;
274 result.tm_min = minute;
275 result.tm_sec = second;
276 result.tm_isdst = -1;
277
278 return result;
279 }
280
282 void setYMD( int year, int month, int day )
283 {
285 }
286
288 void setHMS( int hour, int minute, int second, int millis )
289 {
291 }
292
294 void setHMS( int hour, int minute, int second, int fraction, int precision )
295 {
297
299 }
300
302 void setHour( int hour )
303 {
304 int old_hour, min, sec, millis;
306 setHMS( hour, min, sec, millis );
307 }
308
310 void setMinute( int min )
311 {
312 int hour, old_min, sec, millis;
314 setHMS( hour, min, sec, millis );
315 }
316
318 void setSecond( int sec )
319 {
320 int hour, min, old_sec, millis;
322 setHMS( hour, min, sec, millis );
323 }
324
327 {
328 int hour, min, sec, old_millis;
330 setHMS( hour, min, sec, millis );
331 }
332
335 {
336 int hour, min, sec, old_nanos;
337 getHMS( hour, min, sec, old_nanos, 9 );
338 setHMS( hour, min, sec, micros, 6 );
339 }
340
343 {
344 int hour, min, sec, old_nanos;
345 getHMS( hour, min, sec, old_nanos, 9 );
346 setHMS( hour, min, sec, nanos, 9 );
347 }
348
351 {
352 int hour, min, sec, old_nanos;
353 getHMS( hour, min, sec, old_nanos, 9 );
355 }
356
358 void clearDate()
359 {
360 m_date = 0;
361 }
362
364 void clearTime()
365 {
366 m_time = 0;
367 }
368
370 void set( int date, int64_t time ) { m_date = date; m_time = time; }
371
373 void set( const DateTime& other )
374 {
375 m_date = other.m_date;
376 m_time = other.m_time;
377 }
378
380 void operator+=( int seconds )
381 {
382 int d = seconds / SECONDS_PER_DAY;
383 int s = seconds % SECONDS_PER_DAY;
384
385 m_date += d;
387
388 if( m_time > NANOS_PER_DAY )
389 {
390 m_date++;
392 }
393 else if( m_time < 0 )
394 {
395 m_date--;
397 }
398 }
399
401 static int convertToNanos(int fraction, int precision)
402 {
403 int nanos;
404
405 switch (precision)
406 {
407 case 0:
409 break;
410
411 case 1:
413 break;
414
415 case 2:
417 break;
418
419 case 3:
421 break;
422
423 case 4:
425 break;
426
427 case 5:
429 break;
430
431 case 6:
433 break;
434
435 case 7:
437 break;
438
439 case 8:
441 break;
442
443 case 9:
444 default:
446 break;
447 }
448
449 return nanos;
450 }
451
454 static int64_t makeHMS( int hour, int minute, int second, int nanos )
455 {
458 second) + nanos;
459 }
460
462 static DateTime nowUtc();
463
465 static DateTime nowLocal();
466
468 static DateTime fromUtcTimeT( time_t t, int millis = 0 )
469 {
470 struct tm tm = time_gmtime( &t );
471 return fromTm( tm, millis );
472 }
473
475 {
476 struct tm tm = time_localtime( &t );
477 return fromTm( tm, millis );
478 }
479
481 {
482 struct tm tm = time_gmtime( &t );
483 return fromTm( tm, fraction, precision );
484 }
485
487 {
488 struct tm tm = time_localtime( &t );
489 return fromTm( tm, fraction, precision );
490 }
491
494 static DateTime fromTm( const tm& tm, int millis = 0 )
495 {
496 return DateTime ( julianDate(tm.tm_year + 1900, tm.tm_mon + 1,
497 tm.tm_mday),
498 makeHMS(tm.tm_hour, tm.tm_min, tm.tm_sec, millis * PRECISION_FACTOR[3]) );
499 }
500
503 static DateTime fromTm( const tm& tm, int fraction, int precision )
504 {
506 return DateTime ( julianDate(tm.tm_year + 1900, tm.tm_mon + 1,
507 tm.tm_mday),
508 makeHMS(tm.tm_hour, tm.tm_min, tm.tm_sec, nanos) );
509 }
510
512 static int julianDate( int year, int month, int day )
513 {
514 int a = (14 - month) / 12;
515 int y = year + 4800 - a;
516 int m = month + 12 * a - 3;
517 return (day + int ((153 * m + 2) / 5) + y * 365 +
518 int (y / 4) - int (y / 100) + int (y / 400) - 32045);
519 }
520
522 static void getYMD( int jday, int& year, int& month, int& day )
523 {
524 int a = jday + 32044;
525 int b = (4 * a + 3) / 146097;
526 int c = a - int ((b * 146097) / 4);
527 int d = (4 * c + 3) / 1461;
528 int e = c - int ((1461 * d) / 4);
529 int m = (5 * e + 2) / 153;
530 day = e - int ((153 * m + 2) / 5) + 1;
531 month = m + 3 - 12 * int (m / 10);
532 year = b * 100 + d - 4800 + int (m / 10);
533 }
534};
535
536inline bool operator==( const DateTime& lhs, const DateTime& rhs )
537{
538 return lhs.m_date == rhs.m_date && lhs.m_time == rhs.m_time;
539}
540
541inline bool operator!=( const DateTime& lhs, const DateTime& rhs )
542{
543 return !(lhs == rhs);
544}
545
546inline bool operator<( const DateTime& lhs, const DateTime& rhs )
547{
548 if( lhs.m_date < rhs.m_date )
549 return true;
550 else if( lhs.m_date > rhs.m_date )
551 return false;
552 else if( lhs.m_time < rhs.m_time )
553 return true;
554 return false;
555}
556
557inline bool operator>( const DateTime& lhs, const DateTime& rhs )
558{
559 return !(lhs == rhs || lhs < rhs);
560}
561
562inline bool operator<=( const DateTime& lhs, const DateTime& rhs )
563{
564 return lhs == rhs || lhs < rhs;
565}
566
567inline bool operator>=( const DateTime& lhs, const DateTime& rhs )
568{
569 return lhs == rhs || lhs > rhs;
570}
571
574inline int operator-( const DateTime& lhs, const DateTime& rhs )
575{
576 return (DateTime::SECONDS_PER_DAY * (lhs.m_date - rhs.m_date) +
577 // Truncate the nanos before subtracting
579}
580
582class UtcTimeStamp : public DateTime
583{
584public:
588
590 UtcTimeStamp( int hour, int minute, int second, int millisecond = 0 )
591 : DateTime( DateTime::nowUtc() )
592 {
594 }
595
596 UtcTimeStamp( int hour, int minute, int second, int fraction, int precision )
597 : DateTime( DateTime::nowUtc() )
598 {
600 }
601
603 int date, int month, int year )
604 : DateTime( year, month, date, hour, minute, second, 0 ) {}
605
607 int date, int month, int year )
609
611 int date, int month, int year, int precision )
613
616
619
620 UtcTimeStamp( const tm* time, int millisecond = 0 )
621 : DateTime( fromTm (*time, millisecond) ) {}
622
625
627 {
629 }
630};
631
634{
635public:
639
641 LocalTimeStamp( int hour, int minute, int second, int millisecond = 0 )
643 {
645 }
646
649 {
651 }
652
654 int date, int month, int year )
655 : DateTime( year, month, date, hour, minute, second, 0 ) {}
656
658 int date, int month, int year )
660
662 int date, int month, int year, int precision )
664
667
670
672 : DateTime( fromTm (*time, millisecond) ) {}
673
676
678 {
680 }
681};
682
684class UtcTimeOnly : public DateTime
685{
686public:
689 {
690 setCurrent();
691 }
692
694 : DateTime(val)
695 {
696 clearDate();
697 }
698
699 UtcTimeOnly( int hour, int minute, int second, int millisecond = 0 )
700 {
702 }
703
704 UtcTimeOnly( int hour, int minute, int second, int fraction, int precision )
705 {
707 }
708
709 explicit UtcTimeOnly( time_t time, int millisecond = 0 )
711 {
712 clearDate();
713 }
714
720
721 UtcTimeOnly( const tm* time, int millisecond = 0 )
723 {
724 clearDate();
725 }
726
729 {
730 clearDate();
731 }
732
735 {
736 DateTime d = nowUtc();
737 m_time = d.m_time;
738 }
739};
740
743{
744public:
747 {
748 setCurrent();
749 }
750
752 : DateTime(val)
753 {
754 clearDate();
755 }
756
757 LocalTimeOnly( int hour, int minute, int second, int millisecond = 0 )
758 {
760 }
761
763 {
765 }
766
769 {
770 clearDate();
771 }
772
778
779 LocalTimeOnly( const tm* time, int millisecond = 0 )
781 {
782 clearDate();
783 }
784
787 {
788 clearDate();
789 }
790
793 {
794 DateTime d = nowLocal();
795 m_time = d.m_time;
796 }
797};
798
800class UtcDate : public DateTime
801{
802public:
805 {
806 setCurrent();
807 }
808
810 : DateTime( val )
811 {
812 clearTime();
813 }
814
815 UtcDate( int date, int month, int year )
816 : DateTime(year, month, date, 0, 0, 0, 0) {}
817
820
821 UtcDate( const tm* time )
822 : DateTime( fromTm (*time) )
823 {
824 clearTime();
825 }
826
829 {
830 DateTime d = nowUtc();
831 m_date = d.m_date;
832 }
833};
834
836class LocalDate : public DateTime
837{
838public:
841 {
842 setCurrent();
843 }
844
846 : DateTime( val )
847 {
848 clearTime();
849 }
850
851 LocalDate( int date, int month, int year )
852 : DateTime(year, month, date, 0, 0, 0, 0) {}
853
856
857 LocalDate( const tm* time )
858 : DateTime( fromTm (*time) )
859 {
860 clearTime();
861 }
862
865 {
866 DateTime d = nowLocal();
867 m_date = d.m_date;
868 }
869};
870
874
875typedef std::string STRING;
876typedef char CHAR;
877typedef double PRICE;
878typedef int INT;
879typedef double AMT;
880typedef double QTY;
881typedef std::string CURRENCY;
882typedef std::string MULTIPLEVALUESTRING;
883typedef std::string MULTIPLESTRINGVALUE;
884typedef std::string MULTIPLECHARVALUE;
885typedef std::string EXCHANGE;
887typedef bool BOOLEAN;
888typedef std::string LOCALMKTDATE;
889typedef std::string DATA;
890typedef double FLOAT;
891typedef double PRICEOFFSET;
892typedef std::string MONTHYEAR;
893typedef std::string DAYOFMONTH;
897typedef int NUMINGROUP;
898typedef double PERCENTAGE;
899typedef int SEQNUM;
900typedef int LENGTH;
901typedef std::string COUNTRY;
902typedef std::string TZTIMEONLY;
903typedef std::string TZTIMESTAMP;
904typedef std::string XMLDATA;
905typedef std::string LANGUAGE;
906
945}
946
947#endif //FIX_FIELDTYPES_H
Date only represented in local time.
Definition FieldTypes.h:837
LocalDate(const tm *time)
Definition FieldTypes.h:857
LocalDate(int date, int month, int year)
Definition FieldTypes.h:851
LocalDate(int sec)
Definition FieldTypes.h:854
LocalDate(const DateTime &val)
Definition FieldTypes.h:845
void setCurrent()
Set to the current time.
Definition FieldTypes.h:864
LocalDate()
Defaults to the current date.
Definition FieldTypes.h:840
Time only represented in local time.
Definition FieldTypes.h:743
LocalTimeOnly(const tm *time, int millisecond=0)
Definition FieldTypes.h:779
LocalTimeOnly(time_t time, int fraction, int precision)
Definition FieldTypes.h:773
LocalTimeOnly()
Defaults to the current time.
Definition FieldTypes.h:746
LocalTimeOnly(const DateTime &val)
Definition FieldTypes.h:751
LocalTimeOnly(int hour, int minute, int second, int millisecond=0)
Definition FieldTypes.h:757
LocalTimeOnly(time_t time, int millisecond=0)
Definition FieldTypes.h:767
void setCurrent()
Set to the current time.
Definition FieldTypes.h:792
LocalTimeOnly(const tm *time, int fraction, int precision)
Definition FieldTypes.h:785
LocalTimeOnly(int hour, int minute, int second, int fraction, int precision)
Definition FieldTypes.h:762
Date and Time represented in local time.
Definition FieldTypes.h:634
LocalTimeStamp(int hour, int minute, int second, int millisecond, int date, int month, int year)
Definition FieldTypes.h:657
LocalTimeStamp(time_t time, int fraction, int precision)
Definition FieldTypes.h:668
LocalTimeStamp(const tm *time, int millisecond=0)
Definition FieldTypes.h:671
LocalTimeStamp()
Defaults to the current date and time.
Definition FieldTypes.h:637
LocalTimeStamp(const tm *time, int fraction, int precision)
Definition FieldTypes.h:674
LocalTimeStamp(int hour, int minute, int second, int fraction, int precision)
Definition FieldTypes.h:647
LocalTimeStamp(int hour, int minute, int second, int date, int month, int year)
Definition FieldTypes.h:653
LocalTimeStamp(time_t time, int millisecond=0)
Definition FieldTypes.h:665
LocalTimeStamp(int hour, int minute, int second, int millisecond=0)
Defaults to the current date.
Definition FieldTypes.h:641
LocalTimeStamp(int hour, int minute, int second, int fraction, int date, int month, int year, int precision)
Definition FieldTypes.h:661
Date only represented in UTC.
Definition FieldTypes.h:801
void setCurrent()
Set to the current time.
Definition FieldTypes.h:828
UtcDate(const tm *time)
Definition FieldTypes.h:821
UtcDate(const DateTime &val)
Definition FieldTypes.h:809
UtcDate()
Defaults to the current date.
Definition FieldTypes.h:804
UtcDate(int date, int month, int year)
Definition FieldTypes.h:815
UtcDate(int sec)
Definition FieldTypes.h:818
Time only represented in UTC.
Definition FieldTypes.h:685
UtcTimeOnly(time_t time, int millisecond=0)
Definition FieldTypes.h:709
UtcTimeOnly()
Defaults to the current time.
Definition FieldTypes.h:688
void setCurrent()
Set to the current time.
Definition FieldTypes.h:734
UtcTimeOnly(int hour, int minute, int second, int fraction, int precision)
Definition FieldTypes.h:704
UtcTimeOnly(int hour, int minute, int second, int millisecond=0)
Definition FieldTypes.h:699
UtcTimeOnly(const tm *time, int fraction, int precision)
Definition FieldTypes.h:727
UtcTimeOnly(const tm *time, int millisecond=0)
Definition FieldTypes.h:721
UtcTimeOnly(time_t time, int fraction, int precision)
Definition FieldTypes.h:715
UtcTimeOnly(const DateTime &val)
Definition FieldTypes.h:693
Date and Time represented in UTC.
Definition FieldTypes.h:583
UtcTimeStamp(int hour, int minute, int second, int fraction, int date, int month, int year, int precision)
Definition FieldTypes.h:610
UtcTimeStamp(time_t time, int millisecond=0)
Definition FieldTypes.h:614
UtcTimeStamp(int hour, int minute, int second, int date, int month, int year)
Definition FieldTypes.h:602
UtcTimeStamp(int hour, int minute, int second, int millisecond=0)
Defaults to the current date.
Definition FieldTypes.h:590
UtcTimeStamp(int hour, int minute, int second, int fraction, int precision)
Definition FieldTypes.h:596
UtcTimeStamp(time_t time, int fraction, int precision)
Definition FieldTypes.h:617
UtcTimeStamp(const tm *time, int millisecond=0)
Definition FieldTypes.h:620
UtcTimeStamp(const tm *time, int fraction, int precision)
Definition FieldTypes.h:623
UtcTimeStamp(int hour, int minute, int second, int millisecond, int date, int month, int year)
Definition FieldTypes.h:606
UtcTimeStamp()
Defaults to the current date and time.
Definition FieldTypes.h:586
static const int PRECISION_FACTOR[10]
Date and Time stored as a Julian day number and number of nanoseconds since midnight.
Definition FieldTypes.h:58
int operator-(const DateTime &lhs, const DateTime &rhs)
Calculate the difference between two DateTime values and return the result as a number of seconds.
Definition FieldTypes.h:574
@ MultipleValueString
Definition FieldTypes.h:919
@ MultipleStringValue
Definition FieldTypes.h:920
@ MultipleCharValue
Definition FieldTypes.h:921
std::string STRING
Definition FieldTypes.h:875
std::string EXCHANGE
Definition FieldTypes.h:885
bool operator==(const DatabaseConnectionID &lhs, const DatabaseConnectionID &rhs)
std::string LANGUAGE
Definition FieldTypes.h:905
std::string MONTHYEAR
Definition FieldTypes.h:892
UtcDate UTCDATE
Definition FieldTypes.h:894
bool operator>(const StringField &lhs, const char *rhs)
Definition Field.h:316
std::string MULTIPLECHARVALUE
Definition FieldTypes.h:884
tm time_localtime(const time_t *t)
Definition Utility.cpp:400
std::string XMLDATA
Definition FieldTypes.h:904
std::string DAYOFMONTH
Definition FieldTypes.h:893
std::string MULTIPLESTRINGVALUE
Definition FieldTypes.h:883
UtcTimeOnly UTCTIMEONLY
Definition FieldTypes.h:896
int NUMINGROUP
Definition FieldTypes.h:897
bool operator<(const DatabaseConnectionID &lhs, const DatabaseConnectionID &rhs)
tm time_gmtime(const time_t *t)
Definition Utility.cpp:384
std::string TZTIMESTAMP
Definition FieldTypes.h:903
UtcDateOnly UTCDATEONLY
Definition FieldTypes.h:895
std::string CURRENCY
Definition FieldTypes.h:881
bool operator<=(const StringField &lhs, const char *rhs)
Definition Field.h:328
std::string MULTIPLEVALUESTRING
Definition FieldTypes.h:882
UtcTimeStamp UTCTIMESTAMP
Definition FieldTypes.h:886
std::string DATA
Definition FieldTypes.h:889
int LENGTH
Definition FieldTypes.h:900
bool operator!=(const DatabaseConnectionID &lhs, const DatabaseConnectionID &rhs)
bool BOOLEAN
Definition FieldTypes.h:887
double AMT
Definition FieldTypes.h:879
bool operator>=(const StringField &lhs, const char *rhs)
Definition Field.h:332
std::string COUNTRY
Definition FieldTypes.h:901
std::string LOCALMKTDATE
Definition FieldTypes.h:888
int SEQNUM
Definition FieldTypes.h:899
double FLOAT
Definition FieldTypes.h:890
std::string TZTIMEONLY
Definition FieldTypes.h:902
int INT
Definition FieldTypes.h:878
double QTY
Definition FieldTypes.h:880
double PRICEOFFSET
Definition FieldTypes.h:891
UtcDate UtcDateOnly
Definition FieldTypes.h:873
double PRICE
Definition FieldTypes.h:877
char CHAR
Definition FieldTypes.h:876
double PERCENTAGE
Definition FieldTypes.h:898
signed __int64 int64_t
Definition stdint_msvc.h:90
unsigned __int64 uint64_t
Definition stdint_msvc.h:91
int getDate() const
Another name for the day of the month.
Definition FieldTypes.h:130
void setHour(int hour)
Set the hour portion of the time.
Definition FieldTypes.h:302
int getSecond() const
Return the second portion of the time (0-59)
Definition FieldTypes.h:148
static const int64_t SECONDS_PER_HOUR
Definition FieldTypes.h:67
void clearTime()
Clear the time portion of the DateTime.
Definition FieldTypes.h:364
static const int64_t SECONDS_PER_DAY
Magic numbers.
Definition FieldTypes.h:66
DateTime(int year, int month, int day, int hour, int minute, int second, int fraction, int precision)
Construct from the specified components.
Definition FieldTypes.h:94
void operator+=(int seconds)
Add a number of seconds to this.
Definition FieldTypes.h:380
tm getTmUtc() const
Convert the DateTime to a struct tm which is in UTC.
Definition FieldTypes.h:261
int getMinute() const
Return the minute portion of the time (0-59)
Definition FieldTypes.h:142
static DateTime fromTm(const tm &tm, int millis=0)
Convert a tm and optional milliseconds to a DateTime.
Definition FieldTypes.h:494
static int64_t makeHMS(int hour, int minute, int second, int nanos)
Helper method to convert a broken down time to a number of nanoseconds since midnight.
Definition FieldTypes.h:454
void getYMD(int &year, int &month, int &day) const
Load the referenced values with the year, month and day portions of the date in a single operation.
Definition FieldTypes.h:211
int getMillisecond() const
Return the millisecond portion of the time (0-999)
Definition FieldTypes.h:154
static int convertToNanos(int fraction, int precision)
Convert to internal nanos.
Definition FieldTypes.h:401
static int julianDate(int year, int month, int day)
Helper method to calculate a Julian day number.
Definition FieldTypes.h:512
int64_t m_time
Definition FieldTypes.h:63
void set(const DateTime &other)
Initialize from another DateTime.
Definition FieldTypes.h:373
int getDay() const
Return the day of the month portion of the date.
Definition FieldTypes.h:121
time_t getTimeT() const
Convert the DateTime to a time_t.
Definition FieldTypes.h:254
DateTime()
Default constructor - initializes to zero.
Definition FieldTypes.h:80
static DateTime fromUtcTimeT(time_t t, int millis=0)
Convert a time_t and optional milliseconds to a DateTime.
Definition FieldTypes.h:468
void setHMS(int hour, int minute, int second, int millis)
Set the time portion of the DateTime.
Definition FieldTypes.h:288
static DateTime fromUtcTimeT(time_t t, int fraction, int precision)
Definition FieldTypes.h:480
static const int64_t NANOS_PER_HOUR
Definition FieldTypes.h:72
unsigned int getNanosecond() const
Return the nanosecond portion of the time.
Definition FieldTypes.h:166
int getWeekDay() const
Calculate the weekday of the date (Sunday is 1, Saturday is 7)
Definition FieldTypes.h:239
static const int64_t JULIAN_19700101
Definition FieldTypes.h:77
DateTime(int date, int64_t time)
Construct from a Julian day number and time in millis.
Definition FieldTypes.h:83
void clearDate()
Clear the date portion of the DateTime.
Definition FieldTypes.h:358
static DateTime fromTm(const tm &tm, int fraction, int precision)
Convert a tm and optional milliseconds to a DateTime.
Definition FieldTypes.h:503
void setMillisecond(int millis)
Set the millisecond portion of the time.
Definition FieldTypes.h:326
void setMicrosecond(int micros)
Set the microsecond portion of the time.
Definition FieldTypes.h:334
int getMonth() const
Return the month (1-12) portion of the date.
Definition FieldTypes.h:113
int getJulianDate() const
Return the internal julian date.
Definition FieldTypes.h:133
void setYMD(int year, int month, int day)
Set the date portion of the DateTime.
Definition FieldTypes.h:282
void getHMS(int &hour, int &minute, int &second, int &millis) const
Load the referenced values with the hour, minute, second and millisecond portions of the time in a si...
Definition FieldTypes.h:218
void setHMS(int hour, int minute, int second, int fraction, int precision)
Set the time portion of the DateTime.
Definition FieldTypes.h:294
virtual ~DateTime()
Definition FieldTypes.h:102
static const int64_t SECONDS_PER_MIN
Definition FieldTypes.h:68
void setNanosecond(int nanos)
Set the nanosecond portion of the time.
Definition FieldTypes.h:342
void set(int date, int64_t time)
Set the internal date and time members.
Definition FieldTypes.h:370
int getFraction(int precision) const
Return the fraction portion of the time.
Definition FieldTypes.h:172
void setMinute(int min)
Set the minute portion of the time.
Definition FieldTypes.h:310
static DateTime nowLocal()
Return the current wall-clock time as a local DateTime.
static void getYMD(int jday, int &year, int &month, int &day)
Convert a Julian day number to a year, month and day.
Definition FieldTypes.h:522
int getHour() const
Return the hour portion of the time (0-23)
Definition FieldTypes.h:136
void setSecond(int sec)
Set the seconds portion of the time.
Definition FieldTypes.h:318
static const int64_t NANOS_PER_MIN
Definition FieldTypes.h:73
DateTime(int year, int month, int day, int hour, int minute, int second, int millis)
Construct from the specified components.
Definition FieldTypes.h:86
int getYear() const
Return the year portion of the date.
Definition FieldTypes.h:105
static DateTime fromLocalTimeT(time_t t, int fraction, int precision)
Definition FieldTypes.h:486
static DateTime nowUtc()
Return the current wall-clock time as a utc DateTime.
int getMicroecond() const
Return the microsecond portion of the time.
Definition FieldTypes.h:160
void setFraction(int fraction, int precision)
Set the fraction portion of the time.
Definition FieldTypes.h:350
void getHMS(int &hour, int &minute, int &second, int &fraction, int precision) const
Load the referenced values with the hour, minute, second and fraction portions of the time in a singl...
Definition FieldTypes.h:229
static const int64_t MINUTES_PER_HOUR
Definition FieldTypes.h:69
static const int64_t NANOS_PER_DAY
Definition FieldTypes.h:71
static const int64_t NANOS_PER_SEC
Definition FieldTypes.h:74
static DateTime fromLocalTimeT(time_t t, int millis=0)
Definition FieldTypes.h:474

Generated on Thu May 22 2025 08:23:50 for QuickFIX by doxygen 1.9.8 written by Dimitri van Heesch, © 1997-2001