OnixS C++ CME MDP Conflated TCP Handler  1.3.6
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 
25 
26 #include <stdexcept>
27 
29 
30 /// Miscellaneous time characteristics.
32 {
33  /// \return the number of nanoseconds in a day.
36  {
37  return 86400000000000ll;
38  }
39 
40  /// \return the number of nanoseconds in an hour.
43  {
44  return 3600000000000ll;
45  }
46 
47  /// \return the number of nanoseconds in a minute.
50  {
51  return 60000000000ll;
52  }
53 
54  /// \return the number of nanoseconds in a second.
57  {
58  return 1000000000;
59  }
60 
61  /// \return the number of nanoseconds in a millisecond.
64  {
65  return 1000000;
66  }
67 
68  /// \return the number of nanoseconds in a microsecond.
71  {
72  return 1000;
73  }
74 
75  /// \return the number of hours in a day.
78  {
79  return 24;
80  }
81 
82  /// \return the number of minutes in an hour.
85  {
86  return 60;
87  }
88 
89  /// \return the number of seconds in a minute.
92  {
93  return 60;
94  }
95 
96  /// \return the number of milliseconds in a second.
99  {
100  return 1000;
101  }
102 
103  /// \return the number of microseconds in a second.
106  {
107  return 1000000;
108  }
109 };
110 
111 /// Timespan formatting patterns.
113 {
114  enum Enum
115  {
116  /// Indicates a time span in the "HH:MM:SS" format.
117  /// Used to represent a day time.
119 
120  /// Indicates a time span in the "HH:MM:SS.sss" format.
121  /// Used to represent a day time.
123 
124  /// Indicates a time span in the "HH:MM:SS.ssssss" format.
125  /// Used to represent a day time.
127 
128  /// Indicates a time span in the "HH:MM:SS.sssssssss" format.
129  /// Used to represent a day time.
131 
132  /// Indicates a time span in the "HH:MM:SS.ssssssssssss" format.
133  /// Used to represent a day time.
135 
136  /// Indicates a time span in the "D.HH:MM:SS.sssssssss" format.
137  /// Used to represent a time interval.
138  SDHHMMSSnsec
139  };
140 };
141 
142 /// Time interval.
143 ///
144 /// Used primarily to present time-only stamps and to time intervals between two timestamps.
146 {
147 public:
148  /// Integral type presenting internal ticks.
149  typedef Int64 Ticks;
150 
151  /// Integral type for number of days.
152  typedef Int32 Days;
153 
154  /// Integral type for number of hours.
155  typedef Int32 Hours;
156 
157  /// Integral type for number of minutes.
158  typedef Int32 Minutes;
159 
160  /// Integral type for number of seconds.
161  typedef Int32 Seconds;
162 
163  /// Integral type for number of milliseconds.
165 
166  /// Integral type for number of microseconds.
168 
169  /// Integral type for number of nanoseconds.
171 
172  /// \return a human-readable presentation.
174  std::string toString(TimeSpanFormat::Enum = TimeSpanFormat::SDHHMMSSnsec) const;
175 
176  /// Initializes the timespan from the given number of ticks.
177  explicit TimeSpan(Ticks ticks = 0) ONIXS_CONFLATEDTCP_NOTHROW
178  : ticks_(ticks)
179  {
180  }
181 
182  /// Initializes with the given set of values.
183  ///
184  /// Input parameters are treated as quantities,
185  /// but not as a time stamp. Therefore, there's
186  /// no requirement to fit in a certain range like
187  /// hours must fit into [0, 24) range. After
188  /// initialization time span will be normalized.
189  TimeSpan(Days days, Hours hours, Minutes minutes, Seconds seconds, Nanoseconds nanoseconds) ONIXS_CONFLATEDTCP_NOTHROW
190  : ticks_(
191  numericCast<Ticks>(days) *
192  TimeTraits::nanosecondsPerDay() +
193  numericCast<Ticks>(hours) *
194  TimeTraits::nanosecondsPerHour() +
195  numericCast<Ticks>(minutes) *
196  TimeTraits::nanosecondsPerMinute() +
197  numericCast<Ticks>(seconds) *
198  TimeTraits::nanosecondsPerSecond() +
199  nanoseconds)
200  {
201  }
202 
203  /// Initializes with the given set of values.
204  ///
205  /// Input parameters are treated as quantities,
206  /// but not as a time stamp. Therefore, there's
207  /// no requirement to fit in a certain range like
208  /// hours must fit into [0, 24) range. After
209  /// initialization time span will be normalized.
210  TimeSpan(Hours hours, Minutes minutes, Seconds seconds, Nanoseconds nanoseconds) ONIXS_CONFLATEDTCP_NOTHROW
211  : ticks_(
212  numericCast<Ticks>(hours) *
213  TimeTraits::nanosecondsPerHour() +
214  numericCast<Ticks>(minutes) *
215  TimeTraits::nanosecondsPerMinute() +
216  numericCast<Ticks>(seconds) *
217  TimeTraits::nanosecondsPerSecond() +
218  nanoseconds)
219  {
220  }
221 
222  /// \return the Days component of the time interval.
224  {
225  return
226  numericCast<Days>
227  (ticks_ /
228  TimeTraits::nanosecondsPerDay());
229  }
230 
231  /// \return the Hours component of the time interval.
232  ///
233  /// Values are in range from `-23` through `23`.
235  {
236  return
237  numericCast<Hours>(
238  (ticks_ /
239  TimeTraits::nanosecondsPerHour()) %
240  TimeTraits::hoursPerDay()
241  );
242  }
243 
244  /// \return the Minutes component of the time interval.
245  ///
246  /// Values are in range from `-59` through `59`.
248  {
249  return
250  numericCast<Minutes>(
251  (ticks_ /
252  TimeTraits::nanosecondsPerMinute()) %
253  TimeTraits::minutesPerHour()
254  );
255  }
256 
257  /// \return the Seconds component of the time interval.
258  ///
259  /// Values are in range from `-59` through `59`.
261  {
262  return
263  numericCast<Seconds>(
264  (ticks_ /
265  TimeTraits::nanosecondsPerSecond()) %
266  TimeTraits::secondsPerMinute()
267  );
268  }
269 
270  /// \return the Milliseconds component of the time interval.
271  ///
272  /// Values are in range from `-999` through `999`.
274  {
275  return
276  numericCast<Milliseconds>
277  ((ticks_ /
278  TimeTraits::nanosecondsPerMillisecond()) %
279  TimeTraits::millisecondsPerSecond()
280  );
281  }
282 
283  /// \return the Microseconds component of the time interval.
284  ///
285  /// Values are in range from `-999999` through `999999`.
287  {
288  return
289  numericCast<Microseconds>
290  ((ticks_ /
291  TimeTraits::nanosecondsPerMicrosecond()) %
292  TimeTraits::microsecondsPerSecond()
293  );
294  }
295 
296  /// \return the Nanoseconds component of the time interval.
297  ///
298  /// Values are in range from `-999999999` through `999999999`.
300  {
301  return
302  numericCast<Nanoseconds>
303  (ticks_ %
304  TimeTraits::nanosecondsPerSecond());
305  }
306 
307  /// \return the number of ticks in the time interval.
308  ///
309  /// Ticks are the lowest time quantity used to measure time intervals.
310  /// In the current implementation ticks are nanoseconds.
312  {
313  return ticks_;
314  }
315 
316  /// Adds the given time interval.
318  {
319  ticks_ += other.ticks_;
320 
321  return *this;
322  }
323 
324  /// Subtracts the given time interval.
326  {
327  ticks_ -= other.ticks_;
328 
329  return *this;
330  }
331 
332  /// Swaps.
334  {
335  std::swap(ticks_, other.ticks_);
336  }
337 
338  /// De-serializes the timespan from the given string according to the specified pattern.
339  ///
340  /// @throw std::runtime_error if the de-serialization is impossible.
341  static TimeSpan fromStr(const std::string&);
342 
343 private:
344  Ticks ticks_;
345 };
346 
347 /// Compares Timespans.
349 inline bool operator==(const TimeSpan& left, const TimeSpan& right) ONIXS_CONFLATEDTCP_NOTHROW
350 {
351  return left.ticks() == right.ticks();
352 }
353 
354 /// Compares Timespans.
356 inline bool operator!=(const TimeSpan& left, const TimeSpan& right) ONIXS_CONFLATEDTCP_NOTHROW
357 {
358  return left.ticks() != right.ticks();
359 }
360 
361 /// Compares Timespans.
363 inline bool operator<(const TimeSpan& left, const TimeSpan& right) ONIXS_CONFLATEDTCP_NOTHROW
364 {
365  return left.ticks() < right.ticks();
366 }
367 
368 /// Compares Timespans.
370 inline bool operator>(const TimeSpan& left, const TimeSpan& right) ONIXS_CONFLATEDTCP_NOTHROW
371 {
372  return left.ticks() > right.ticks();
373 }
374 
375 /// Changes the sign of the Timestamp.
378 {
379  return TimeSpan(-timeSpan.ticks());
380 }
381 
382 /// Serializes the timespan according to the HH:MM:SS pattern.
384 void toStrAsHHMMSS(std::string&, TimeSpan);
385 
386 /// Serializes the timespan according to the HH:MM:SS.sss pattern.
388 void toStrAsHHMMSSmsec(std::string&, TimeSpan);
389 
390 /// Serializes the timespan according to the HH:MM:SS.ssssss pattern.
392 void toStrAsHHMMSSusec(std::string&, TimeSpan);
393 
394 /// Serializes the timespan according to the HH:MM:SS.sssssssss pattern.
396 void toStrAsHHMMSSnsec(std::string&, TimeSpan);
397 
398 /// Serializes the timespan according to the HH:MM:SS.ssssssssssss pattern.
400 void toStrAsHHMMSSpsec(std::string&, TimeSpan);
401 
402 /// Serializes the timespan according to the D.HH:MM:SS.sssssssss pattern.
404 void toStrAsSDHHMMSSnsec(std::string&, TimeSpan);
405 
406 /// Appends the timespan.
408 void toStr(std::string&, TimeSpan, TimeSpanFormat::Enum = TimeSpanFormat::SDHHMMSSnsec);
409 
410 /// Formats the timespan.
411 inline
412 std::string toStr(TimeSpan timeSpan, TimeSpanFormat::Enum format = TimeSpanFormat::SDHHMMSSnsec)
413 {
414  std::string str;
415 
416  toStr(str, timeSpan, format);
417 
418  return str;
419 }
420 
421 /// The months in year.
423 {
424  enum Enum
425  {
426  January = 1,
437  December
438  };
439 };
440 
441 /// Timestamp formatting patterns.
443 {
444  enum Enum
445  {
446  /// YYYYMMDD.
448 
449  /// YYYYMMDD-HH:MM:SS.
451 
452  /// YYYYMMDD-HH:MM:SS.sss.
454 
455  /// Indicates timestamp in "YYYYMMDD-HH:MM:SS.ssssss" format.
457 
458  /// YYYYMMDD-HH:MM:SS.sssssssss.
460 
461  /// Indicates timestamp in "YYYYMMDD-HH:MM:SS.ssssssssssss" format.
462  YYYYMMDDHHMMSSpsec
463  };
464 };
465 
466 /// The time point without the time-zone information.
468 {
469 public:
470 
471  /// Integral type storing internal ticks.
472  typedef UInt64 Ticks;
473 
474  /// \private
475  /// Init traits.
476  struct MemberTraits
477  {
478  enum
479  {
480  Count = 1
481  };
482 
483  typedef Ticks FirstArgType;
484  };
485 
486  /// Traits.
487  enum
488  {
489  /// Size of the class in bytes.
490  Size = sizeof(Ticks)
491  };
492 
493  /// Integral type presenting the year component.
494  typedef UInt32 Year;
495 
496  /// Type presenting the month component.
497  typedef
500 
501  /// Integral type presenting the day component.
502  typedef UInt32 Day;
503 
504  /// Integral type presenting the hour component.
505  typedef UInt32 Hour;
506 
507  /// Integral type presenting the minute component.
508  typedef UInt32 Minute;
509 
510  /// Integral type presenting the second component.
511  typedef UInt32 Second;
512 
513  /// Integral type presenting the millisecond component.
515 
516  /// Integral type presenting the microsecond component.
518 
519  /// Integral type presenting the nanosecond component.
521 
522  /// \return a human-readable presentation.
524  std::string toString(TimestampFormat::Enum = TimestampFormat::YYYYMMDDHHMMSSnsec) const;
525 
526  /// Initializes from the number of ticks since epoch.
527  explicit Timestamp(Ticks ticks = 0) ONIXS_CONFLATEDTCP_NOTHROW
528  : sinceEpoch_(ticks)
529  {
530  }
531 
532  /// Explicit time-stamp initialization.
533  ///
534  /// Input parameters are validated, therefore constructor throws an exception if input values do not fit into their valid ranges.
536  Year year,
537  Month month,
538  Day day,
539  Hour hour = 0,
540  Minute minute = 0,
541  Second second = 0,
542  Nanosecond nanosecond = 0)
543  : sinceEpoch_(
544  toTicks(
545  year, month, day,
546  hour, minute, second, nanosecond)
547  )
548  {
549  }
550 
552  : sinceEpoch_(other.sinceEpoch_)
553  {
554  }
555 
556  /// \return the Year component.
557  Year year() const
558  {
559  Year year; Month month; Day day;
560 
561  toDate(sinceEpoch_, year, month, day);
562 
563  return year;
564  }
565 
566  /// \return the Month component.
567  Month month() const
568  {
569  Year year; Month month; Day day;
570 
571  toDate(sinceEpoch_, year, month, day);
572 
573  return month;
574  }
575 
576  /// \return Day component
577  Day day() const
578  {
579  Year year; Month month; Day day;
580 
581  toDate(sinceEpoch_, year, month, day);
582 
583  return day;
584  }
585 
586  /// \return the Hour component
588  {
589  return static_cast<Hour>(time().hours());
590  }
591 
592  /// \return the Minute component.
594  {
595  return static_cast<Minute>(time().minutes());
596  }
597 
598  /// \return the Second component.
600  {
601  return static_cast<Second>(time().seconds());
602  }
603 
604  /// \return the Millisecond component.
606  {
607  return static_cast<Millisecond>(time().milliseconds());
608  }
609 
610  /// \return the Microsecond component.
612  {
613  return static_cast<Microsecond>(time().microseconds());
614  }
615 
616  /// \return the Nanosecond component.
618  {
619  return static_cast<Nanosecond>(time().nanoseconds());
620  }
621 
622  /// \return the Timestamp without a time part.
624  {
625  return
626  Timestamp(
627  sinceEpoch_ -
628  sinceEpoch_ %
629  TimeTraits::nanosecondsPerDay());
630  }
631 
632  /// \return the Time part of timestamp.
634  {
635  return
636  TimeSpan(
637  sinceEpoch_ %
638  TimeTraits::nanosecondsPerDay());
639  }
640 
641  /// \return the number of nanoseconds since the Epoch (01-01-1970).
643  {
644  return sinceEpoch_;
645  }
646 
648  {
649  sinceEpoch_ = other.sinceEpoch_;
650 
651  return *this;
652  }
653 
654  /// Exchanges the value.
656  {
657  std::swap(sinceEpoch_, other.sinceEpoch_);
658  }
659 
660  /// De-serializes a timestamp from the given string.
661  ///
662  /// @throw std::runtime_error if the de-serialization is impossible.
663  static Timestamp fromStr(const std::string&, TimestampFormat::Enum = TimestampFormat::YYYYMMDDHHMMSSnsec);
664 
665 private:
666  /// Time interval in nanoseconds since the 01-01-1970.
667  Ticks sinceEpoch_;
668 
669  /// Converts structured date-time into ticks.
671  static Ticks toTicks(Year, Month, Day, Hour, Minute, Second, Nanosecond);
672 
673  // Extracts the ddate components from ticks.
675  static void toDate(Ticks, Year&, Month&, Day&);
676 };
677 
678 /// Make Timestamp helper.
681 {
682  return Timestamp(ticks);
683 }
684 
685 /// Compares instances.
687 inline bool operator==(const Timestamp& left, const Timestamp& right) ONIXS_CONFLATEDTCP_NOTHROW
688 {
689  return (
690  left.sinceEpoch() ==
691  right.sinceEpoch()
692  );
693 }
694 
695 /// Compares instances.
697 inline bool operator!=(const Timestamp& left, const Timestamp& right) ONIXS_CONFLATEDTCP_NOTHROW
698 {
699  return (
700  left.sinceEpoch() !=
701  right.sinceEpoch()
702  );
703 }
704 
705 /// Compares instances.
707 inline bool operator<(const Timestamp& left, const Timestamp& right) ONIXS_CONFLATEDTCP_NOTHROW
708 {
709  return (
710  left.sinceEpoch() <
711  right.sinceEpoch()
712  );
713 }
714 
715 /// Compares instances.
717 inline bool operator<=(const Timestamp& left, const Timestamp& right) ONIXS_CONFLATEDTCP_NOTHROW
718 {
719  return (
720  left.sinceEpoch() <=
721  right.sinceEpoch()
722  );
723 }
724 
725 /// Compares instances.
727 inline bool operator>(const Timestamp& left, const Timestamp& right) ONIXS_CONFLATEDTCP_NOTHROW
728 {
729  return (
730  left.sinceEpoch() >
731  right.sinceEpoch()
732  );
733 }
734 
735 /// Compares instances.
737 inline bool operator>=(const Timestamp& left, const Timestamp& right) ONIXS_CONFLATEDTCP_NOTHROW
738 {
739  return (
740  left.sinceEpoch() >=
741  right.sinceEpoch()
742  );
743 }
744 
745 /// Adds te time interval.
747 inline Timestamp operator +(const Timestamp& timestamp, const TimeSpan& timeSpan) ONIXS_CONFLATEDTCP_NOTHROW
748 {
749  return
750  Timestamp(
751  timestamp.sinceEpoch() +
752  timeSpan.ticks()
753  );
754 }
755 
756 /// Subtracts the time interval.
758 inline Timestamp operator -(const Timestamp& timestamp, const TimeSpan& timeSpan) ONIXS_CONFLATEDTCP_NOTHROW
759 {
760  return
761  Timestamp(
762  timestamp.sinceEpoch() -
763  timeSpan.ticks()
764  );
765 }
766 
767 /// Calculates the time interval between two time points.
770 {
771  return TimeSpan(left.sinceEpoch() - right.sinceEpoch());
772 }
773 
774 /// Serializes the timestamp using the YYYYMMDD format.
776 void toStrAsYYYYMMDD(std::string&, Timestamp);
777 
778 /// Serializes the timestamp using the YYYYMMDDHHMMSS format.
780 void toStrAsYYYYMMDDHHMMSS(std::string&, Timestamp
781 );
782 
783 /// Serializes the timestamp using the YYYYMMDDHHMMSSmsec format.
785 void toStrAsYYYYMMDDHHMMSSmsec(std::string&, Timestamp);
786 
787 /// Serializes the timestamp using the YYYYMMDDHHMMSSusec format.
789 void toStrAsYYYYMMDDHHMMSSusec(std::string&, Timestamp);
790 
791 /// Serializes the timestamp using the YYYYMMDDHHMMSSnsec format.
793 void toStrAsYYYYMMDDHHMMSSnsec(std::string&, Timestamp);
794 
795 /// Serializes the timestamp using the YYYYMMDDHHMMSSpsec format.
797 void toStrAsYYYYMMDDHHMMSSpsec(std::string&, Timestamp);
798 
799 /// Serializes the timestamp.
801 void toStr(std::string&, Timestamp, TimestampFormat::Enum = TimestampFormat::YYYYMMDDHHMMSSnsec);
802 
803 /// Serializes the timestamp.
805 std::string toStr(Timestamp timestamp, TimestampFormat::Enum format = TimestampFormat::YYYYMMDDHHMMSSnsec)
806 {
807  std::string str;
808 
809  toStr(str, timestamp, format);
810 
811  return str;
812 }
813 
814 /// Serializes the timestamp.
816 size_t toStr(Timestamp, Char*, size_t);
817 
818 inline std::ostream & operator <<(std::ostream & os, const Timestamp& value)
819 {
820  return os << toStr(value);
821 }
822 
823 inline
824 std::ostream & operator <<(std::ostream & os, const TimeSpan& value)
825 {
826  return os << toStr(value);
827 }
828 
829 /// De-serializes a timespan from the given string
832 bool fromStr(TimeSpan&, const Char*, size_t);
833 
834 /// De-serializes a timespan from the given string.
836 bool fromStr(TimeSpan& ts, const std::string& str)
837 {
838  return
839  fromStr(
840  ts, str.c_str(), str.size());
841 }
842 
843 /// De-serializes a timestamp from the given string.
846 bool fromStr(Timestamp&, const Char*, size_t, TimestampFormat::Enum = TimestampFormat::YYYYMMDDHHMMSSnsec);
847 
848 /// De-serializes a timestamp from the given string.
850 bool fromStr(Timestamp& ts, const std::string& str, TimestampFormat::Enum format= TimestampFormat::YYYYMMDDHHMMSSnsec)
851 {
852  return
853  fromStr(
854  ts, str.c_str(), str.size(), format);
855 }
856 
857 inline
858 Timestamp Timestamp::fromStr(const std::string& str, TimestampFormat::Enum format)
859 {
860  Timestamp ts;
861 
862  const bool result =
863  Messaging::fromStr(ts, str, format);
864 
865  if(!result)
866  throw std::runtime_error("Error parsing timestamp.");
867 
868  return ts;
869 }
870 
871 inline
872 TimeSpan TimeSpan::fromStr(const std::string& str)
873 {
874  TimeSpan ts;
875 
876  const bool result =
877  Messaging::fromStr(ts, str);
878 
879  if(!result)
880  throw std::runtime_error("Error parsing timespan.");
881 
882  return ts;
883 }
884 
885 inline
886 std::string TimeSpan::toString(TimeSpanFormat::Enum format) const
887 {
888  return toStr(*this, format);
889 }
890 
891 inline
892 std::string Timestamp::toString(TimestampFormat::Enum format) const
893 {
894  return toStr(*this, format);
895 }
896 
void toStrAsHHMMSSnsec(std::string &, TimeSpan)
Serializes the timespan according to the HH:MM:SS.sssssssss pattern.
Int32 Hours
Integral type for number of hours.
Definition: Time.h:155
TimeSpan(Days days, Hours hours, Minutes minutes, Seconds seconds, Nanoseconds nanoseconds) noexcept
Initializes with the given set of values.
Definition: Time.h:189
Indicates a time span in the "HH:MM:SS.ssssss" format.
Definition: Time.h:126
static constexpr Int32 microsecondsPerSecond() noexcept
Definition: Time.h:105
#define ONIXS_CONFLATEDTCP_LTWT_EXPORTED
Definition: ABI.h:92
void toStrAsYYYYMMDD(std::string &, Timestamp)
Serializes the timestamp using the YYYYMMDD format.
static constexpr Int32 nanosecondsPerMicrosecond() noexcept
Definition: Time.h:70
UInt32 Hour
Integral type presenting the hour component.
Definition: Time.h:505
#define ONIXS_CONFLATEDTCP_MESSAGING_NAMESPACE_END
Definition: ABI.h:143
void toStrAsYYYYMMDDHHMMSSnsec(std::string &, Timestamp)
Serializes the timestamp using the YYYYMMDDHHMMSSnsec format.
Timestamp operator+(const Timestamp &timestamp, const TimeSpan &timeSpan) noexcept
Adds te time interval.
Definition: Time.h:747
#define ONIXS_CONFLATEDTCP_NOTHROW
Definition: Compiler.h:176
TimeSpan operator-(const Timestamp &left, const Timestamp &right) noexcept
Calculates the time interval between two time points.
Definition: Time.h:769
std::ostream & operator<<(std::ostream &os, const TimeSpan &value)
Definition: Time.h:824
Indicates a time span in the "HH:MM:SS.sss" format.
Definition: Time.h:122
Indicates a time span in the "HH:MM:SS.ssssssssssss" format.
Definition: Time.h:134
Milliseconds milliseconds() const noexcept
Definition: Time.h:273
Int32 Days
Integral type for number of days.
Definition: Time.h:152
void swap(Timestamp &other) noexcept
Exchanges the value.
Definition: Time.h:655
TimeSpan & operator-=(const TimeSpan &other) noexcept
Subtracts the given time interval.
Definition: Time.h:325
Minutes minutes() const noexcept
Definition: Time.h:247
Int32 Seconds
Integral type for number of seconds.
Definition: Time.h:161
void swap(TimeSpan &other) noexcept
Swaps.
Definition: Time.h:333
bool operator<=(const Timestamp &left, const Timestamp &right) noexcept
Compares instances.
Definition: Time.h:717
#define ONIXS_CONFLATEDTCP_EXPORTED
Definition: Compiler.h:175
Indicates a time span in the "HH:MM:SS.sssssssss" format.
Definition: Time.h:130
Timespan formatting patterns.
Definition: Time.h:112
bool fromStr(Timestamp &ts, const std::string &str, TimestampFormat::Enum format=TimestampFormat::YYYYMMDDHHMMSSnsec)
De-serializes a timestamp from the given string.
Definition: Time.h:850
bool operator<(const Timestamp &left, const Timestamp &right) noexcept
Compares instances.
Definition: Time.h:707
TimeSpan time() const noexcept
Definition: Time.h:633
static constexpr Int32 nanosecondsPerMillisecond() noexcept
Definition: Time.h:63
Microseconds microseconds() const noexcept
Definition: Time.h:286
Seconds seconds() const noexcept
Definition: Time.h:260
void toStrAsHHMMSSmsec(std::string &, TimeSpan)
Serializes the timespan according to the HH:MM:SS.sss pattern.
void toStrAsSDHHMMSSnsec(std::string &, TimeSpan)
Serializes the timespan according to the D.HH:MM:SS.sssssssss pattern.
Timestamp(Year year, Month month, Day day, Hour hour=0, Minute minute=0, Second second=0, Nanosecond nanosecond=0)
Explicit time-stamp initialization.
Definition: Time.h:535
bool operator>(const Timestamp &left, const Timestamp &right) noexcept
Compares instances.
Definition: Time.h:727
Int32 Microseconds
Integral type for number of microseconds.
Definition: Time.h:167
UInt32 Microsecond
Integral type presenting the microsecond component.
Definition: Time.h:517
static constexpr Int64 nanosecondsPerHour() noexcept
Definition: Time.h:42
static constexpr Int32 hoursPerDay() noexcept
Definition: Time.h:77
UInt64 Ticks
Integral type storing internal ticks.
Definition: Time.h:472
static constexpr Int64 nanosecondsPerMinute() noexcept
Definition: Time.h:49
void toStrAsYYYYMMDDHHMMSS(std::string &, Timestamp)
Serializes the timestamp using the YYYYMMDDHHMMSS format.
size_t toStr(Timestamp, Char *, size_t)
Serializes the timestamp.
#define ONIXS_CONFLATEDTCP_PURE
Definition: Compiler.h:189
Nanoseconds nanoseconds() const noexcept
Definition: Time.h:299
Int64 Ticks
Integral type presenting internal ticks.
Definition: Time.h:149
bool operator!=(const Timestamp &left, const Timestamp &right) noexcept
Compares instances.
Definition: Time.h:697
#define ONIXS_CONFLATEDTCP_CONSTEXPR
Definition: Compiler.h:179
Timestamp formatting patterns.
Definition: Time.h:442
#define ONIXS_CONFLATEDTCP_NODISCARD
Definition: Compiler.h:185
The time point without the time-zone information.
Definition: Time.h:467
Nanosecond nanosecond() const noexcept
Definition: Time.h:617
Timestamp(Ticks ticks=0) noexcept
Initializes from the number of ticks since epoch.
Definition: Time.h:527
bool operator==(const Timestamp &left, const Timestamp &right) noexcept
Compares instances.
Definition: Time.h:687
void toStrAsHHMMSSpsec(std::string &, TimeSpan)
Serializes the timespan according to the HH:MM:SS.ssssssssssss pattern.
Timestamp & operator=(const Timestamp &other) noexcept
Definition: Time.h:647
UInt32 Second
Integral type presenting the second component.
Definition: Time.h:511
OnixS::CME::ConflatedTCP::Messaging::Month::Enum Month
Type presenting the month component.
Definition: Time.h:499
Int32 Nanoseconds
Integral type for number of nanoseconds.
Definition: Time.h:170
TimeSpan(Ticks ticks=0) noexcept
Initializes the timespan from the given number of ticks.
Definition: Time.h:177
Indicates timestamp in "YYYYMMDD-HH:MM:SS.ssssss" format.
Definition: Time.h:456
void toStrAsYYYYMMDDHHMMSSmsec(std::string &, Timestamp)
Serializes the timestamp using the YYYYMMDDHHMMSSmsec format.
Timestamp makeTimestamp(Timestamp::Ticks ticks) noexcept
Make Timestamp helper.
Definition: Time.h:680
void toStrAsYYYYMMDDHHMMSSusec(std::string &, Timestamp)
Serializes the timestamp using the YYYYMMDDHHMMSSusec format.
void toStrAsYYYYMMDDHHMMSSpsec(std::string &, Timestamp)
Serializes the timestamp using the YYYYMMDDHHMMSSpsec format.
bool operator>=(const Timestamp &left, const Timestamp &right) noexcept
Compares instances.
Definition: Time.h:737
Indicates a time span in the "HH:MM:SS" format.
Definition: Time.h:118
#define ONIXS_CONFLATEDTCP_LTWT_CLASS
Definition: ABI.h:84
#define ONIXS_CONFLATEDTCP_MESSAGING_NAMESPACE_BEGIN
Definition: ABI.h:140
Millisecond millisecond() const noexcept
Definition: Time.h:605
static constexpr Int32 secondsPerMinute() noexcept
Definition: Time.h:91
void toStrAsHHMMSS(std::string &, TimeSpan)
Serializes the timespan according to the HH:MM:SS pattern.
static constexpr Int32 millisecondsPerSecond() noexcept
Definition: Time.h:98
void toStrAsHHMMSSusec(std::string &, TimeSpan)
Serializes the timespan according to the HH:MM:SS.ssssss pattern.
static constexpr Int64 nanosecondsPerDay() noexcept
Definition: Time.h:35
Miscellaneous time characteristics.
Definition: Time.h:31
Microsecond microsecond() const noexcept
Definition: Time.h:611
TimeSpan(Hours hours, Minutes minutes, Seconds seconds, Nanoseconds nanoseconds) noexcept
Initializes with the given set of values.
Definition: Time.h:210
UInt32 Year
Integral type presenting the year component.
Definition: Time.h:494
static constexpr Int32 minutesPerHour() noexcept
Definition: Time.h:84
Timestamp(const Timestamp &other) noexcept
Definition: Time.h:551
TimeSpan & operator+=(const TimeSpan &other) noexcept
Adds the given time interval.
Definition: Time.h:317
static constexpr Int32 nanosecondsPerSecond() noexcept
Definition: Time.h:56
Int32 Minutes
Integral type for number of minutes.
Definition: Time.h:158
Timestamp date() const noexcept
Definition: Time.h:623
UInt32 Day
Integral type presenting the day component.
Definition: Time.h:502
#define ONIXS_CONFLATEDTCP_LTWT_STRUCT
Definition: ABI.h:88
UInt32 Minute
Integral type presenting the minute component.
Definition: Time.h:508
Int32 Milliseconds
Integral type for number of milliseconds.
Definition: Time.h:164
UInt32 Nanosecond
Integral type presenting the nanosecond component.
Definition: Time.h:520
UInt32 Millisecond
Integral type presenting the millisecond component.
Definition: Time.h:514
char Char
Character type alias.
Definition: String.h:30