OnixS C++ CME Market Data Handler  5.4.0
API documentation
Time.h
Go to the documentation of this file.
1 // Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2 //
3 // This software owned by Onix Solutions Limited [OnixS] and is
4 // protected by copyright law and international copyright treaties.
5 //
6 // Access to and use of the software is governed by the terms of the applicable
7 // OnixS Software Services Agreement (the Agreement) and Customer end user license
8 // agreements granting a non-assignable, non-transferable and non-exclusive license
9 // to use the software for it's own data processing purposes under the terms defined
10 // in the Agreement.
11 //
12 // Except as otherwise granted within the terms of the Agreement, copying or
13 // reproduction of any part of this source code or associated reference material
14 // to any other location for further reproduction or redistribution, and any
15 // amendments to this copyright notice, are expressly prohibited.
16 //
17 // Any reproduction or redistribution for sale or hiring of the Software not in
18 // accordance with the terms of the Agreement is a violation of copyright law.
19 //
20 
21 #pragma once
22 
23 #include <algorithm>
24 #include <stdexcept>
25 
26 #include <OnixS/CME/MDH/String.h>
27 #include <OnixS/CME/MDH/Integral.h>
28 
30 ONIXS_CMEMDH_DATA_PACKING_BEGIN(1)
31 
32 /// Miscellaneous time characteristics.
34 {
35  /// Returns number of nanoseconds in single day.
36  static Int64 nanosecondsPerDay()
37  {
38  return 86400000000000ll;
39  }
40 
41  /// Returns number of nanoseconds in single hour.
42  static Int64 nanosecondsPerHour()
43  {
44  return 3600000000000ll;
45  }
46 
47  /// Returns number of nanoseconds in single minute.
48  static Int64 nanosecondsPerMinute()
49  {
50  return 60000000000ll;
51  }
52 
53  /// Returns number of nanoseconds in single second.
55  {
56  return 1000000000;
57  }
58 
59  /// Returns number of nanoseconds in single millisecond.
61  {
62  return 1000000;
63  }
64 
65  /// Returns number of nanoseconds in single microsecond.
67  {
68  return 1000;
69  }
70 
71  /// Returns number of hours in single day.
72  static Int32 hoursPerDay()
73  {
74  return 24;
75  }
76 
77  /// Returns number of minutes in single hour.
79  {
80  return 60;
81  }
82 
83  /// Returns number of seconds in single minute.
85  {
86  return 60;
87  }
88 
89  /// Returns number of milliseconds in single second.
91  {
92  return 1000;
93  }
94 
95  /// Returns number of microseconds in single second.
97  {
98  return 1000000;
99  }
100 };
101 
102 /// Represents time interval. Used primarily to present time-only
103 /// stamps and to measure time intervals between two timestamps.
105 {
106 public:
107  /// Integral type presenting internal ticks.
108  typedef Int64 Ticks;
109 
110  /// Integral type for number of days.
111  typedef Int32 Days;
112 
113  /// Integral type for number of hours.
114  typedef Int32 Hours;
115 
116  /// Integral type for number of minutes.
117  typedef Int32 Minutes;
118 
119  /// Integral type for number of seconds.
120  typedef Int32 Seconds;
121 
122  /// Integral type for number of milliseconds.
124 
125  /// Integral type for number of microseconds.
127 
128  /// Integral type for number of nanoseconds.
130 
131  /// Initializes timespan from given number of ticks.
132  explicit
134  Ticks ticks = 0)
135  : ticks_(ticks)
136  {
137  }
138 
139  /// Initializes with given set of values.
140  ///
141  /// Input parameters are treated as quantities,
142  /// but not as a time stamp. Therefore, there's
143  /// no requirement to fit in a certain range like
144  /// hours must fit into [0, 24) range. After
145  /// initialization time span will be normalized.
147  Days days,
148  Hours hours,
149  Minutes minutes,
150  Seconds seconds,
151  Nanoseconds nanoseconds)
152  : ticks_(
153  static_cast<Ticks>(days) *
154  TimeTraits::nanosecondsPerDay() +
155  static_cast<Ticks>(hours) *
156  TimeTraits::nanosecondsPerHour() +
157  static_cast<Ticks>(minutes) *
158  TimeTraits::nanosecondsPerMinute() +
159  static_cast<Ticks>(seconds) *
160  TimeTraits::nanosecondsPerSecond() +
161  nanoseconds)
162  {
163  }
164 
165  /// Initializes with given set of values.
166  ///
167  /// Input parameters are treated as quantities,
168  /// but not as a time stamp. Therefore, there's
169  /// no requirement to fit in a certain range like
170  /// hours must fit into [0, 24) range. After
171  /// initialization time span will be normalized.
173  Hours hours,
174  Minutes minutes,
175  Seconds seconds,
176  Nanoseconds nanoseconds)
177  : ticks_(
178  static_cast<Ticks>(hours) *
179  TimeTraits::nanosecondsPerHour() +
180  static_cast<Ticks>(minutes) *
181  TimeTraits::nanosecondsPerMinute() +
182  static_cast<Ticks>(seconds) *
183  TimeTraits::nanosecondsPerSecond() +
184  nanoseconds)
185  {
186  }
187 
188  /// Initializes instance as a copy of the other one.
190  const TimeSpan& other)
191  : ticks_(other.ticks_)
192  {
193  }
194 
195  /// Days component of time interval.
196  /// Whole number of days in time interval.
197  Days days() const
198  {
199  return
200  static_cast<Days>
201  (ticks_ /
202  TimeTraits::nanosecondsPerDay());
203  }
204 
205  /// Hours component of time interval.
206  /// Values are in range from -23 through 23.
207  Hours hours() const
208  {
209  return
210  static_cast<Hours>(
211  (ticks_ /
212  TimeTraits::nanosecondsPerHour()) %
213  TimeTraits::hoursPerDay()
214  );
215  }
216 
217  /// Minutes component of time interval.
218  /// Values are in range from -59 through 59.
219  Int32 minutes() const
220  {
221  return
222  static_cast<Minutes>(
223  (ticks_ /
224  TimeTraits::nanosecondsPerMinute()) %
225  TimeTraits::minutesPerHour()
226  );
227  }
228 
229  /// Seconds component of time interval.
230  /// Values are in range from -59 through 59.
231  Int32 seconds() const
232  {
233  return
234  static_cast<Seconds>(
235  (ticks_ /
236  TimeTraits::nanosecondsPerSecond()) %
237  TimeTraits::secondsPerMinute()
238  );
239  }
240 
241  /// Milliseconds component of time interval.
242  /// Values are in range from -999 through 999.
243  Milliseconds milliseconds() const
244  {
245  return
246  static_cast<Milliseconds>
247  ((ticks_ /
248  TimeTraits::nanosecondsPerMillisecond()) %
249  TimeTraits::millisecondsPerSecond()
250  );
251  }
252 
253  /// Microseconds component of time interval.
254  /// Values are in range from -999999 through 999999.
255  Microseconds microseconds() const
256  {
257  return
258  static_cast<Microseconds>
259  ((ticks_ /
260  TimeTraits::nanosecondsPerMicrosecond()) %
261  TimeTraits::microsecondsPerSecond()
262  );
263  }
264 
265  /// Nanoseconds component of time interval.
266  /// Values are in range from -999999999 through 999999999.
267  Nanoseconds nanoseconds() const
268  {
269  return
270  static_cast<Nanoseconds>
271  (ticks_ %
272  TimeTraits::nanosecondsPerSecond());
273  }
274 
275  /// Number of ticks in given time interval.
276  ///
277  /// Ticks are the lowest time quantity used
278  /// to measure time intervals. In current
279  /// implementation ticks are nanoseconds.
280  Ticks ticks() const
281  {
282  return ticks_;
283  }
284 
285  /// Adds time interval to current one.
286  TimeSpan&
287  operator +=(
288  const TimeSpan& other)
289  {
290  ticks_ += other.ticks_;
291 
292  return *this;
293  }
294 
295  /// Subtracts time interval from current one.
296  TimeSpan&
297  operator -=(
298  const TimeSpan& other)
299  {
300  ticks_ -= other.ticks_;
301 
302  return *this;
303  }
304 
305  /// Reinitializes as copy of given instance.
306  TimeSpan&
307  operator =(
308  const TimeSpan& other)
309  {
310  ticks_ = other.ticks_;
311 
312  return *this;
313  }
314 
315  /// Exchanges with given instance.
316  void
317  swap(TimeSpan& other)
318  {
319  std::swap(ticks_, other.ticks_);
320  }
321 
322 private:
323  Ticks ticks_;
324 };
325 
326 /// Compares with other instance for equality.
327 inline
328 bool
330  const TimeSpan& left,
331  const TimeSpan& right)
332 {
333  return left.ticks() == right.ticks();
334 }
335 
336 /// Compares with other instance for in-equality.
337 inline
338 bool
340  const TimeSpan& left,
341  const TimeSpan& right)
342 {
343  return left.ticks() != right.ticks();
344 }
345 
346 /// Checks whether left time interval less than right one.
347 inline
348 bool
350  const TimeSpan& left,
351  const TimeSpan& right)
352 {
353  return left.ticks() < right.ticks();
354 }
355 
356 /// Checks whether left time interval greater than right one.
357 inline
358 bool
360  const TimeSpan& left,
361  const TimeSpan& right)
362 {
363  return left.ticks() > right.ticks();
364 }
365 
366 // TimeSpan serialization.
367 
368 // Serializes timespan according to HH:MM:SS pattern.
369 ONIXS_CMEMDH_EXPORTED
370 void
371 toStrAsHHMMSS(std::string&, TimeSpan);
372 
373 // Serializes timespan according to HH:MM:SS.sss pattern.
374 ONIXS_CMEMDH_EXPORTED
375 void
376 toStrAsHHMMSSmsec(std::string&, TimeSpan);
377 
378 // Serializes timespan according to D.HH:MM:SS.sssssssss pattern.
379 ONIXS_CMEMDH_EXPORTED
380 void
381 toStrAsSDHHMMSSnsec(std::string&, TimeSpan);
382 
383 /// Collection of timespan formatting patterns.
385 {
386  enum Enum
387  {
388  /// HH:MM:SS.
390 
391  /// HH:MM:SS.sss.
393 
394  /// D.HH:MM:SS.sssssssss.
395  SDHHMMSSnsec
396  };
397 };
398 
399 /// Appends timespan formatted in specified pattern to given string.
400 inline
401 void
403  std::string& str,
404  TimeSpan timeSpan,
405  TimeSpanFormat::Enum format =
406  TimeSpanFormat::SDHHMMSSnsec)
407 {
408  switch (format)
409  {
410  case TimeSpanFormat::HHMMSS:
411  toStrAsHHMMSS(str, timeSpan);
412  break;
413 
414  case TimeSpanFormat::HHMMSSmsec:
415  toStrAsHHMMSSmsec(str, timeSpan);
416  break;
417 
418  case TimeSpanFormat::SDHHMMSSnsec:
419  toStrAsSDHHMMSSnsec(str, timeSpan);
420  break;
421 
422  default:
423  {
424  throw std::invalid_argument(
425  "Unknown timespan format pattern specified. ");
426  }
427  }
428 }
429 
430 /// Formats timespan according to specified pattern.
431 inline
432 std::string
434  TimeSpan timeSpan,
435  TimeSpanFormat::Enum format =
436  TimeSpanFormat::SDHHMMSSnsec)
437 {
438  std::string str;
439 
440  toStr(str, timeSpan, format);
441 
442  return str;
443 }
444 
445 /// Identifies months in year.
447 {
448  /// Defines numeric value sufficient
449  /// to hold enumeration values.
450  typedef UInt32 Base;
451 
452  /// Identifies months in year.
453  enum Enum
454  {
455  January = 1,
466  December
467  };
468 };
469 
470 /// Represents time point without time-zone information.
472 {
473 public:
474  /// Integral type storing internal ticks.
475  typedef UInt64 Ticks;
476 
477  /// Integral type presenting year component.
478  typedef UInt32 Year;
479 
480  /// Type presenting month component.
481  typedef
484 
485  /// Integral type presenting day component.
486  typedef UInt32 Day;
487 
488  /// Integral type presenting hour component.
489  typedef UInt32 Hour;
490 
491  /// Integral type presenting minute component.
492  typedef UInt32 Minute;
493 
494  /// Integral type presenting second component.
495  typedef UInt32 Second;
496 
497  /// Integral type presenting millisecond component.
499 
500  /// Integral type presenting microsecond component.
502 
503  /// Integral type presenting nanosecond component.
505 
506  /// Initializes from number of ticks since epoch.
507  explicit
509  Ticks ticks = 0)
510  : sinceEpoch_(ticks)
511  {
512  }
513 
514  /// Explicit time-stamp initialization.
515  ///
516  /// Input parameters are validated, therefore
517  /// constructor throws exception if input values
518  /// do not fit into their valid ranges.
520  Year year,
521  Month month,
522  Day day,
523  Hour hour = 0,
524  Minute minute = 0,
525  Second second = 0,
526  Nanosecond nanosecond = 0)
527  : sinceEpoch_(
528  toTicks(
529  year, month, day,
530  hour, minute, second, nanosecond)
531  )
532  {
533  }
534 
535  /// Year component of given time point.
536  Year year() const
537  {
538  Year year; Month month; Day day;
539 
540  toDate(sinceEpoch_, year, month, day);
541 
542  return year;
543  }
544 
545  /// Month component of given time point.
546  Month month() const
547  {
548  Year year; Month month; Day day;
549 
550  toDate(sinceEpoch_, year, month, day);
551 
552  return month;
553  }
554 
555  /// Day component of given time point.
556  Day day() const
557  {
558  Year year; Month month; Day day;
559 
560  toDate(sinceEpoch_, year, month, day);
561 
562  return day;
563  }
564 
565  /// Hour component of given time point.
566  Hour hour() const
567  {
568  return static_cast<Hour>(time().hours());
569  }
570 
571  /// Minute component of given time point.
572  Minute minute() const
573  {
574  return static_cast<Minute>(time().minutes());
575  }
576 
577  /// Second component of given time point.
578  Second second() const
579  {
580  return static_cast<Second>(time().seconds());
581  }
582 
583  /// Millisecond component of given time point.
584  Millisecond millisecond() const
585  {
586  return static_cast<Millisecond>(time().milliseconds());
587  }
588 
589  /// Microsecond component of given time point.
590  Microsecond microsecond() const
591  {
592  return static_cast<Microsecond>(time().microseconds());
593  }
594 
595  /// Nanosecond component of given time point.
596  Nanosecond nanosecond() const
597  {
598  return static_cast<Nanosecond>(time().nanoseconds());
599  }
600 
601  /// Timestamp without a time part.
602  Timestamp date() const
603  {
604  return
605  Timestamp(
606  sinceEpoch_ -
607  sinceEpoch_ %
608  TimeTraits::nanosecondsPerDay());
609  }
610 
611  /// Time part of timestamp.
612  TimeSpan time() const
613  {
614  return
615  TimeSpan(
616  sinceEpoch_ %
617  TimeTraits::nanosecondsPerDay());
618  }
619 
620  /// Number of nanoseconds since the Epoch (01-01-1970).
621  Ticks sinceEpoch() const
622  {
623  return sinceEpoch_;
624  }
625 
626  /// Exchanges value with other instance.
627  void
629  Timestamp& other)
630  {
631  std::swap(
632  sinceEpoch_,
633  other.sinceEpoch_);
634  }
635 
636 private:
637  // Time interval in nanoseconds since the 01-01-1970.
638  Ticks sinceEpoch_;
639 
640  // Converts structured date-time into ticks.
642  static
643  Ticks
644  toTicks(
645  Year, Month, Day,
646  Hour, Minute, Second,
647  Nanosecond);
648 
649  // Extracts date components from ticks.
651  static
652  void
653  toDate(
654  Ticks,
655  Year&, Month&, Day&);
656 };
657 
658 /// Compares with instances for equality.
659 inline
660 bool
662  const Timestamp& left,
663  const Timestamp& right)
664 {
665  return (
666  left.sinceEpoch() ==
667  right.sinceEpoch()
668  );
669 }
670 
671 /// Compares with instances for inequality.
672 inline
673 bool
675  const Timestamp& left,
676  const Timestamp& right)
677 {
678  return (
679  left.sinceEpoch() !=
680  right.sinceEpoch()
681  );
682 }
683 
684 /// Establishes order between two instances.
685 inline
686 bool
688  const Timestamp& left,
689  const Timestamp& right)
690 {
691  return (
692  left.sinceEpoch() <
693  right.sinceEpoch()
694  );
695 }
696 
697 /// Establishes order between two instances.
698 inline
699 bool
701  const Timestamp& left,
702  const Timestamp& right)
703 {
704  return (
705  left.sinceEpoch() <=
706  right.sinceEpoch()
707  );
708 }
709 
710 /// Establishes order between two instances.
711 inline
712 bool
714  const Timestamp& left,
715  const Timestamp& right)
716 {
717  return (
718  left.sinceEpoch() >
719  right.sinceEpoch()
720  );
721 }
722 
723 /// Establishes order between two instances.
724 inline
725 bool
727  const Timestamp& left,
728  const Timestamp& right)
729 {
730  return (
731  left.sinceEpoch() >=
732  right.sinceEpoch()
733  );
734 }
735 
736 /// Adds time interval to given time point.
737 inline
738 Timestamp
740  const Timestamp& timestamp,
741  const TimeSpan& timeSpan)
742 {
743  return
744  Timestamp(
745  timestamp.sinceEpoch() +
746  timeSpan.ticks()
747  );
748 }
749 
750 /// Subtracts time interval from given time point.
751 inline
752 Timestamp
754  const Timestamp& timestamp,
755  const TimeSpan& timeSpan)
756 {
757  return
758  Timestamp(
759  timestamp.sinceEpoch() -
760  timeSpan.ticks()
761  );
762 }
763 
764 /// Calculates time interval between two time points.
765 inline
766 TimeSpan
768  const Timestamp& left,
769  const Timestamp& right)
770 {
771  return
772  TimeSpan(
773  left.sinceEpoch() -
774  right.sinceEpoch()
775  );
776 }
777 
778 // Serialization.
779 
780 /// Serializes timestamp in YYYYMMDD format.
781 ONIXS_CMEMDH_EXPORTED
782 void
784 (
785  std::string&,
786  Timestamp
787 );
788 
789 /// Serializes timestamp in YYYYMMDDHHMMSS format.
790 ONIXS_CMEMDH_EXPORTED
791 void
793 (
794  std::string&,
795  Timestamp
796 );
797 
798 /// Serializes timestamp in YYYYMMDDHHMMSSmsec format.
799 ONIXS_CMEMDH_EXPORTED
800 void
802 (
803  std::string&,
804  Timestamp
805 );
806 
807 /// Serializes timestamp in YYYYMMDDHHMMSSnsec format.
808 ONIXS_CMEMDH_EXPORTED
809 void
811 (
812  std::string&,
813  Timestamp
814 );
815 
816 /// Collection of timestamp formatting patterns.
818 {
819  enum Enum
820  {
821  /// YYYYMMDD.
823 
824  /// YYYYMMDD-HH:MM:SS.
826 
827  /// YYYYMMDD-HH:MM:SS.sss.
829 
830  /// YYYYMMDD-HH:MM:SS.sssssssss.
831  YYYYMMDDHHMMSSnsec
832  };
833 };
834 
835 /// Serializes timestamp according to specified pattern.
836 inline
837 void
839  std::string& str,
841  TimestampFormat::Enum format =
842  TimestampFormat::YYYYMMDDHHMMSSnsec)
843 {
844  switch (format)
845  {
846  case TimestampFormat::YYYYMMDD:
847  toStrAsYYYYMMDD(str, timestamp);
848  break;
849 
850  case TimestampFormat::YYYYMMDDHHMMSS:
851  toStrAsYYYYMMDDHHMMSS(str, timestamp);
852  break;
853 
854  case TimestampFormat::YYYYMMDDHHMMSSmsec:
855  toStrAsYYYYMMDDHHMMSSmsec(str, timestamp);
856  break;
857 
858  case TimestampFormat::YYYYMMDDHHMMSSnsec:
859  toStrAsYYYYMMDDHHMMSSnsec(str, timestamp);
860  break;
861 
862  default:
863  {
864  throw std::invalid_argument
865  (
866  "Unknown timestamp format pattern specified. "
867  );
868  }
869  }
870 }
871 
872 /// Serializes timestamp according to specified pattern.
873 inline
874 std::string
877  TimestampFormat::Enum format =
878  TimestampFormat::YYYYMMDDHHMMSSnsec)
879 {
880  std::string str;
881 
882  toStr(str, timestamp, format);
883 
884  return str;
885 }
886 
887 /// De-serializes a timestamp from the given string.
888 ONIXS_CMEMDH_EXPORTED
889 bool
890 fromStr(
891  Timestamp&,
892  const Char*,
893  size_t);
894 
895 inline
896 bool
898  Timestamp& ts,
899  const std::string& str)
900 {
901  return
902  fromStr(
903  ts, str.c_str(), str.size());
904 }
905 
906 
907 ONIXS_CMEMDH_DATA_PACKING_END
Ticks ticks() const
Definition: Time.h:280
#define ONIXS_CMEMDH_LTWT_CLASS
Definition: Bootstrap.h:94
Microsecond microsecond() const
Microsecond component of given time point.
Definition: Time.h:590
ONIXS_CMEMDH_EXPORTED void toStrAsHHMMSSmsec(std::string &, TimeSpan)
static Int64 nanosecondsPerDay()
Returns number of nanoseconds in single day.
Definition: Time.h:36
Int32 Int32
int32.
Definition: Fields.h:69
static Int32 millisecondsPerSecond()
Returns number of milliseconds in single second.
Definition: Time.h:90
ONIXS_CMEMDH_EXPORTED void toStrAsSDHHMMSSnsec(std::string &, TimeSpan)
Timestamp(Ticks ticks=0)
Initializes from number of ticks since epoch.
Definition: Time.h:508
Milliseconds milliseconds() const
Definition: Time.h:243
Microseconds microseconds() const
Definition: Time.h:255
bool fromStr(Timestamp &ts, const std::string &str)
Definition: Time.h:897
static Int32 nanosecondsPerMicrosecond()
Returns number of nanoseconds in single microsecond.
Definition: Time.h:66
UInt32 Day
Integral type presenting day component.
Definition: Time.h:486
Int32 Hours
Integral type for number of hours.
Definition: Time.h:114
static Int64 nanosecondsPerMinute()
Returns number of nanoseconds in single minute.
Definition: Time.h:48
bool operator>=(const Timestamp &left, const Timestamp &right)
Establishes order between two instances.
Definition: Time.h:726
ONIXS_CMEMDH_EXPORTED void toStrAsYYYYMMDD(std::string &, Timestamp)
Serializes timestamp in YYYYMMDD format.
UInt32 UInt32
uInt32.
Definition: Fields.h:247
Days days() const
Definition: Time.h:197
ONIXS_CMEMDH_EXPORTED void toStrAsYYYYMMDDHHMMSS(std::string &, Timestamp)
Serializes timestamp in YYYYMMDDHHMMSS format.
Collection of timestamp formatting patterns.
Definition: Time.h:817
Represents time point without time-zone information.
Definition: Time.h:471
Hours hours() const
Definition: Time.h:207
Identifies months in year.
Definition: Time.h:446
static Int32 microsecondsPerSecond()
Returns number of microseconds in single second.
Definition: Time.h:96
Int64 Ticks
Integral type presenting internal ticks.
Definition: Time.h:108
Timestamp date() const
Timestamp without a time part.
Definition: Time.h:602
ONIXS_CMEMDH_EXPORTED void toStrAsYYYYMMDDHHMMSSmsec(std::string &, Timestamp)
Serializes timestamp in YYYYMMDDHHMMSSmsec format.
static Int32 minutesPerHour()
Returns number of minutes in single hour.
Definition: Time.h:78
Year year() const
Year component of given time point.
Definition: Time.h:536
Collection of timespan formatting patterns.
Definition: Time.h:384
UInt32 Nanosecond
Integral type presenting nanosecond component.
Definition: Time.h:504
TimeSpan(const TimeSpan &other)
Initializes instance as a copy of the other one.
Definition: Time.h:189
Int32 Nanoseconds
Integral type for number of nanoseconds.
Definition: Time.h:129
Millisecond millisecond() const
Millisecond component of given time point.
Definition: Time.h:584
Ticks sinceEpoch() const
Number of nanoseconds since the Epoch (01-01-1970).
Definition: Time.h:621
Second second() const
Second component of given time point.
Definition: Time.h:578
char Char
Character type alias.
Definition: String.h:36
UInt32 Hour
Integral type presenting hour component.
Definition: Time.h:489
UInt64 UInt64
uInt64.
Definition: Fields.h:251
Int32 Milliseconds
Integral type for number of milliseconds.
Definition: Time.h:123
bool operator<(const Timestamp &left, const Timestamp &right)
Establishes order between two instances.
Definition: Time.h:687
Hour hour() const
Hour component of given time point.
Definition: Time.h:566
Int32 minutes() const
Definition: Time.h:219
TimeSpan(Ticks ticks=0)
Initializes timespan from given number of ticks.
Definition: Time.h:133
Nanoseconds nanoseconds() const
Definition: Time.h:267
Int32 seconds() const
Definition: Time.h:231
#define ONIXS_CMEMDH_LTWT_STRUCT
Definition: Bootstrap.h:98
static Int32 hoursPerDay()
Returns number of hours in single day.
Definition: Time.h:72
bool operator<=(const Timestamp &left, const Timestamp &right)
Establishes order between two instances.
Definition: Time.h:700
UInt32 Second
Integral type presenting second component.
Definition: Time.h:495
Timestamp operator+(const Timestamp &timestamp, const TimeSpan &timeSpan)
Adds time interval to given time point.
Definition: Time.h:739
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:152
UInt32 Minute
Integral type presenting minute component.
Definition: Time.h:492
Int32 Seconds
Integral type for number of seconds.
Definition: Time.h:120
void swap(TimeSpan &other)
Exchanges with given instance.
Definition: Time.h:317
UInt32 Microsecond
Integral type presenting microsecond component.
Definition: Time.h:501
Int32 Microseconds
Integral type for number of microseconds.
Definition: Time.h:126
bool operator>(const Timestamp &left, const Timestamp &right)
Establishes order between two instances.
Definition: Time.h:713
TimeSpan time() const
Time part of timestamp.
Definition: Time.h:612
UInt64 Ticks
Integral type storing internal ticks.
Definition: Time.h:475
TimeSpan operator-(const Timestamp &left, const Timestamp &right)
Calculates time interval between two time points.
Definition: Time.h:767
#define ONIXS_CMEMDH_LTWT_EXPORTED
Definition: Bootstrap.h:102
UInt32 Year
Integral type presenting year component.
Definition: Time.h:478
ONIXS_CMEMDH_EXPORTED void toStrAsHHMMSS(std::string &, TimeSpan)
ONIXS_CMEMDH_EXPORTED void toStrAsYYYYMMDDHHMMSSnsec(std::string &, Timestamp)
Serializes timestamp in YYYYMMDDHHMMSSnsec format.
Miscellaneous time characteristics.
Definition: Time.h:33
TimeSpan(Hours hours, Minutes minutes, Seconds seconds, Nanoseconds nanoseconds)
Definition: Time.h:172
void swap(Timestamp &other)
Exchanges value with other instance.
Definition: Time.h:628
Nanosecond nanosecond() const
Nanosecond component of given time point.
Definition: Time.h:596
Timestamp(Year year, Month month, Day day, Hour hour=0, Minute minute=0, Second second=0, Nanosecond nanosecond=0)
Definition: Time.h:519
static Int32 nanosecondsPerMillisecond()
Returns number of nanoseconds in single millisecond.
Definition: Time.h:60
std::string toStr(Timestamp timestamp, TimestampFormat::Enum format=TimestampFormat::YYYYMMDDHHMMSSnsec)
Serializes timestamp according to specified pattern.
Definition: Time.h:875
static Int32 secondsPerMinute()
Returns number of seconds in single minute.
Definition: Time.h:84
static Int64 nanosecondsPerHour()
Returns number of nanoseconds in single hour.
Definition: Time.h:42
bool operator!=(const Timestamp &left, const Timestamp &right)
Compares with instances for inequality.
Definition: Time.h:674
Month month() const
Month component of given time point.
Definition: Time.h:546
bool operator==(const Timestamp &left, const Timestamp &right)
Compares with instances for equality.
Definition: Time.h:661
TimeSpan(Days days, Hours hours, Minutes minutes, Seconds seconds, Nanoseconds nanoseconds)
Definition: Time.h:146
ONIXS_CMEMDH_EXPORTED Timestamp timestamp(const MultiContainer &, Tag)
Retrieves last update time field value.
Day day() const
Day component of given time point.
Definition: Time.h:556
Minute minute() const
Minute component of given time point.
Definition: Time.h:572
Int32 Minutes
Integral type for number of minutes.
Definition: Time.h:117
Enum
Identifies months in year.
Definition: Time.h:453
OnixS::CME::MDH::Month::Enum Month
Type presenting month component.
Definition: Time.h:483
Int32 Days
Integral type for number of days.
Definition: Time.h:111
UInt32 Millisecond
Integral type presenting millisecond component.
Definition: Time.h:498
static Int32 nanosecondsPerSecond()
Returns number of nanoseconds in single second.
Definition: Time.h:54
#define ONIXS_CMEMDH_NAMESPACE_END
Definition: Bootstrap.h:156