OnixS C++ CME iLink 3 Binary Order Entry Handler  1.18.2
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_ILINK3_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_ILINK3_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_ILINK3_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`.
273  Milliseconds milliseconds() const ONIXS_ILINK3_NOTHROW
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`.
286  Microseconds microseconds() const ONIXS_ILINK3_NOTHROW
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`.
299  Nanoseconds nanoseconds() const ONIXS_ILINK3_NOTHROW
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_ILINK3_NOTHROW
350 {
351  return left.ticks() == right.ticks();
352 }
353 
354 /// Compares Timespans.
356 inline bool operator!=(const TimeSpan& left, const TimeSpan& right) ONIXS_ILINK3_NOTHROW
357 {
358  return left.ticks() != right.ticks();
359 }
360 
361 /// Compares Timespans.
363 inline bool operator<(const TimeSpan& left, const TimeSpan& right) ONIXS_ILINK3_NOTHROW
364 {
365  return left.ticks() < right.ticks();
366 }
367 
368 /// Compares Timespans.
370 inline bool operator>(const TimeSpan& left, const TimeSpan& right) ONIXS_ILINK3_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  /// Integral type storing internal ticks.
471  typedef UInt64 Ticks;
472 
473  /// Integral type presenting the year component.
474  typedef UInt32 Year;
475 
476  /// Type presenting the month component.
477  typedef
480 
481  /// Integral type presenting the day component.
482  typedef UInt32 Day;
483 
484  /// Integral type presenting the hour component.
485  typedef UInt32 Hour;
486 
487  /// Integral type presenting the minute component.
488  typedef UInt32 Minute;
489 
490  /// Integral type presenting the second component.
491  typedef UInt32 Second;
492 
493  /// Integral type presenting the millisecond component.
495 
496  /// Integral type presenting the microsecond component.
498 
499  /// Integral type presenting the nanosecond component.
501 
502  /// \return a human-readable presentation.
504  std::string toString(TimestampFormat::Enum = TimestampFormat::YYYYMMDDHHMMSSnsec) const;
505 
506  /// Initializes from the number of ticks since epoch.
507  explicit Timestamp(Ticks ticks = 0) ONIXS_ILINK3_NOTHROW
508  : sinceEpoch_(ticks)
509  {
510  }
511 
512  /// Explicit time-stamp initialization.
513  ///
514  /// Input parameters are validated, therefore constructor throws an exception if input values do not fit into their valid ranges.
516  Year year,
517  Month month,
518  Day day,
519  Hour hour = 0,
520  Minute minute = 0,
521  Second second = 0,
522  Nanosecond nanosecond = 0)
523  : sinceEpoch_(
524  toTicks(
525  year, month, day,
526  hour, minute, second, nanosecond)
527  )
528  {
529  }
530 
532  : sinceEpoch_(other.sinceEpoch_)
533  {
534  }
535 
536  /// \return the Year component.
537  Year year() const
538  {
539  Year year; Month month; Day day;
540 
541  toDate(sinceEpoch_, year, month, day);
542 
543  return year;
544  }
545 
546  /// \return the Month component.
547  Month month() const
548  {
549  Year year; Month month; Day day;
550 
551  toDate(sinceEpoch_, year, month, day);
552 
553  return month;
554  }
555 
556  /// \return Day component
557  Day day() const
558  {
559  Year year; Month month; Day day;
560 
561  toDate(sinceEpoch_, year, month, day);
562 
563  return day;
564  }
565 
566  /// \return the Hour component
568  {
569  return static_cast<Hour>(time().hours());
570  }
571 
572  /// \return the Minute component.
574  {
575  return static_cast<Minute>(time().minutes());
576  }
577 
578  /// \return the Second component.
580  {
581  return static_cast<Second>(time().seconds());
582  }
583 
584  /// \return the Millisecond component.
585  Millisecond millisecond() const ONIXS_ILINK3_NOTHROW
586  {
587  return static_cast<Millisecond>(time().milliseconds());
588  }
589 
590  /// \return the Microsecond component.
591  Microsecond microsecond() const ONIXS_ILINK3_NOTHROW
592  {
593  return static_cast<Microsecond>(time().microseconds());
594  }
595 
596  /// \return the Nanosecond component.
597  Nanosecond nanosecond() const ONIXS_ILINK3_NOTHROW
598  {
599  return static_cast<Nanosecond>(time().nanoseconds());
600  }
601 
602  /// \return the Timestamp without a time part.
604  {
605  return
606  Timestamp(
607  sinceEpoch_ -
608  sinceEpoch_ %
609  TimeTraits::nanosecondsPerDay());
610  }
611 
612  /// \return the Time part of timestamp.
614  {
615  return
616  TimeSpan(
617  sinceEpoch_ %
618  TimeTraits::nanosecondsPerDay());
619  }
620 
621  /// \return the number of nanoseconds since the Epoch (01-01-1970).
623  {
624  return sinceEpoch_;
625  }
626 
628  {
629  sinceEpoch_ = other.sinceEpoch_;
630 
631  return *this;
632  }
633 
634  /// Exchanges the value.
636  {
637  std::swap(sinceEpoch_, other.sinceEpoch_);
638  }
639 
640  /// De-serializes a timestamp from the given string.
641  ///
642  /// @throw std::runtime_error if the de-serialization is impossible.
643  static Timestamp fromStr(const std::string&, TimestampFormat::Enum = TimestampFormat::YYYYMMDDHHMMSSnsec);
644 
645 private:
646  /// Time interval in nanoseconds since the 01-01-1970.
647  Ticks sinceEpoch_;
648 
649  /// Converts structured date-time into ticks.
651  static Ticks toTicks(Year, Month, Day, Hour, Minute, Second, Nanosecond);
652 
653  // Extracts the ddate components from ticks.
655  static void toDate(Ticks, Year&, Month&, Day&);
656 };
657 
658 /// Make Timestamp helper.
661 {
662  return Timestamp(ticks);
663 }
664 
665 /// Compares instances.
667 inline bool operator==(const Timestamp& left, const Timestamp& right) ONIXS_ILINK3_NOTHROW
668 {
669  return (
670  left.sinceEpoch() ==
671  right.sinceEpoch()
672  );
673 }
674 
675 /// Compares instances.
677 inline bool operator!=(const Timestamp& left, const Timestamp& right) ONIXS_ILINK3_NOTHROW
678 {
679  return (
680  left.sinceEpoch() !=
681  right.sinceEpoch()
682  );
683 }
684 
685 /// Compares instances.
687 inline bool operator<(const Timestamp& left, const Timestamp& right) ONIXS_ILINK3_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_ILINK3_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_ILINK3_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_ILINK3_NOTHROW
718 {
719  return (
720  left.sinceEpoch() >=
721  right.sinceEpoch()
722  );
723 }
724 
725 /// Adds the time interval.
727 inline Timestamp operator +(const Timestamp& timestamp, const TimeSpan& timeSpan) ONIXS_ILINK3_NOTHROW
728 {
729  return
730  Timestamp(
731  timestamp.sinceEpoch() +
732  timeSpan.ticks()
733  );
734 }
735 
736 /// Subtracts the time interval.
738 inline Timestamp operator -(const Timestamp& timestamp, const TimeSpan& timeSpan) ONIXS_ILINK3_NOTHROW
739 {
740  return
741  Timestamp(
742  timestamp.sinceEpoch() -
743  timeSpan.ticks()
744  );
745 }
746 
747 /// Calculates the time interval between two time points.
749 inline TimeSpan operator -(const Timestamp& left, const Timestamp& right) ONIXS_ILINK3_NOTHROW
750 {
751  return TimeSpan(left.sinceEpoch() - right.sinceEpoch());
752 }
753 
754 /// Serializes the timestamp using the YYYYMMDD format.
756 void toStrAsYYYYMMDD(std::string&, Timestamp);
757 
758 /// Serializes the timestamp using the YYYYMMDDHHMMSS format.
760 void toStrAsYYYYMMDDHHMMSS(std::string&, Timestamp
761 );
762 
763 /// Serializes the timestamp using the YYYYMMDDHHMMSSmsec format.
765 void toStrAsYYYYMMDDHHMMSSmsec(std::string&, Timestamp);
766 
767 /// Serializes the timestamp using the YYYYMMDDHHMMSSusec format.
769 void toStrAsYYYYMMDDHHMMSSusec(std::string&, Timestamp);
770 
771 /// Serializes the timestamp using the YYYYMMDDHHMMSSnsec format.
773 void toStrAsYYYYMMDDHHMMSSnsec(std::string&, Timestamp);
774 
775 /// Serializes the timestamp using the YYYYMMDDHHMMSSpsec format.
777 void toStrAsYYYYMMDDHHMMSSpsec(std::string&, Timestamp);
778 
779 /// Serializes the timestamp.
781 void toStr(std::string&, Timestamp, TimestampFormat::Enum = TimestampFormat::YYYYMMDDHHMMSSnsec);
782 
783 /// Serializes the timestamp.
785 std::string toStr(Timestamp timestamp, TimestampFormat::Enum format = TimestampFormat::YYYYMMDDHHMMSSnsec)
786 {
787  std::string str;
788 
789  toStr(str, timestamp, format);
790 
791  return str;
792 }
793 
794 /// Serializes the timestamp.
796 size_t toStr(Timestamp, Char*, size_t);
797 
798 inline std::ostream & operator <<(std::ostream & os, const Timestamp& value)
799 {
800  return os << toStr(value);
801 }
802 
803 inline
804 std::ostream & operator <<(std::ostream & os, const TimeSpan& value)
805 {
806  return os << toStr(value);
807 }
808 
809 /// De-serializes a timespan from the given string
812 bool fromStr(TimeSpan&, const Char*, size_t);
813 
814 /// De-serializes a timespan from the given string.
816 bool fromStr(TimeSpan& ts, const std::string& str)
817 {
818  return
819  fromStr(
820  ts, str.c_str(), str.size());
821 }
822 
823 /// De-serializes a timestamp from the given string.
826 bool fromStr(Timestamp&, const Char*, size_t, TimestampFormat::Enum = TimestampFormat::YYYYMMDDHHMMSSnsec);
827 
828 /// De-serializes a timestamp from the given string.
830 bool fromStr(Timestamp& ts, const std::string& str, TimestampFormat::Enum format= TimestampFormat::YYYYMMDDHHMMSSnsec)
831 {
832  return
833  fromStr(
834  ts, str.c_str(), str.size(), format);
835 }
836 
837 inline
838 Timestamp Timestamp::fromStr(const std::string& str, TimestampFormat::Enum format)
839 {
840  Timestamp ts;
841 
842  const bool result =
843  Messaging::fromStr(ts, str, format);
844 
845  if(!result)
846  throw std::runtime_error("Error parsing timestamp.");
847 
848  return ts;
849 }
850 
851 inline
852 TimeSpan TimeSpan::fromStr(const std::string& str)
853 {
854  TimeSpan ts;
855 
856  const bool result =
857  Messaging::fromStr(ts, str);
858 
859  if(!result)
860  throw std::runtime_error("Error parsing timespan.");
861 
862  return ts;
863 }
864 
865 inline
866 std::string TimeSpan::toString(TimeSpanFormat::Enum format) const
867 {
868  return toStr(*this, format);
869 }
870 
871 inline
872 std::string Timestamp::toString(TimestampFormat::Enum format) const
873 {
874  return toStr(*this, format);
875 }
876 
#define ONIXS_ILINK3_CONSTEXPR
Definition: Compiler.h:179
void toStrAsHHMMSS(std::string &, TimeSpan)
Serializes the timespan according to the HH:MM:SS pattern.
TimeSpan & operator+=(const TimeSpan &other) noexcept
Adds the given time interval.
Definition: Time.h:317
Timestamp(const Timestamp &other) noexcept
Definition: Time.h:531
static constexpr Int32 minutesPerHour() noexcept
Definition: Time.h:84
static constexpr Int32 millisecondsPerSecond() noexcept
Definition: Time.h:98
Days days() const noexcept
Definition: Time.h:223
static constexpr Int32 hoursPerDay() noexcept
Definition: Time.h:77
TimeSpan(Days days, Hours hours, Minutes minutes, Seconds seconds, Nanoseconds nanoseconds) noexcept
Initializes with the given set of values.
Definition: Time.h:189
TimeSpan & operator-=(const TimeSpan &other) noexcept
Subtracts the given time interval.
Definition: Time.h:325
Timestamp makeTimestamp(Timestamp::Ticks ticks) noexcept
Make Timestamp helper.
Definition: Time.h:660
TimeSpan(Hours hours, Minutes minutes, Seconds seconds, Nanoseconds nanoseconds) noexcept
Initializes with the given set of values.
Definition: Time.h:210
char Char
Character type alias.
Definition: String.h:30
UInt32 Nanosecond
Integral type presenting the nanosecond component.
Definition: Time.h:500
Indicates a time span in the "HH:MM:SS.sss" format.
Definition: Time.h:122
Timestamp formatting patterns.
Definition: Time.h:442
Timespan formatting patterns.
Definition: Time.h:112
Int32 Days
Integral type for number of days.
Definition: Time.h:152
void toStrAsHHMMSSmsec(std::string &, TimeSpan)
Serializes the timespan according to the HH:MM:SS.sss pattern.
Indicates timestamp in "YYYYMMDD-HH:MM:SS.ssssss" format.
Definition: Time.h:456
Hour hour() const noexcept
Definition: Time.h:567
Int32 Nanoseconds
Integral type for number of nanoseconds.
Definition: Time.h:170
#define ONIXS_ILINK3_PURE
Definition: Compiler.h:189
static constexpr Int32 nanosecondsPerMillisecond() noexcept
Definition: Time.h:63
static constexpr Int64 nanosecondsPerMinute() noexcept
Definition: Time.h:49
Second second() const noexcept
Definition: Time.h:579
UInt32 Hour
Integral type presenting the hour component.
Definition: Time.h:485
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
Int32 Milliseconds
Integral type for number of milliseconds.
Definition: Time.h:164
Timestamp date() const noexcept
Definition: Time.h:603
UInt32 Second
Integral type presenting the second component.
Definition: Time.h:491
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:515
UInt64 Ticks
Integral type storing internal ticks.
Definition: Time.h:471
The months in year.
Definition: Time.h:422
Int32 Microseconds
Integral type for number of microseconds.
Definition: Time.h:167
bool fromStr(Timestamp &ts, const std::string &str, TimestampFormat::Enum format=TimestampFormat::YYYYMMDDHHMMSSnsec)
De-serializes a timestamp from the given string.
Definition: Time.h:830
Ticks ticks() const noexcept
Definition: Time.h:311
Seconds seconds() const noexcept
Definition: Time.h:260
Minute minute() const noexcept
Definition: Time.h:573
Ticks sinceEpoch() const noexcept
Definition: Time.h:622
static constexpr Int64 nanosecondsPerHour() noexcept
Definition: Time.h:42
bool operator<=(const Timestamp &left, const Timestamp &right) noexcept
Compares instances.
Definition: Time.h:697
static constexpr Int32 secondsPerMinute() noexcept
Definition: Time.h:91
Hours hours() const noexcept
Definition: Time.h:234
void toStrAsYYYYMMDDHHMMSSnsec(std::string &, Timestamp)
Serializes the timestamp using the YYYYMMDDHHMMSSnsec format.
#define ONIXS_ILINK3_LTWT_EXPORTED
Definition: ABI.h:92
void toStrAsYYYYMMDDHHMMSSusec(std::string &, Timestamp)
Serializes the timestamp using the YYYYMMDDHHMMSSusec format.
Int32 Seconds
Integral type for number of seconds.
Definition: Time.h:161
static constexpr Int32 nanosecondsPerMicrosecond() noexcept
Definition: Time.h:70
Millisecond millisecond() const noexcept
Definition: Time.h:585
UInt32 Day
Integral type presenting the day component.
Definition: Time.h:482
#define ONIXS_ILINK3_LTWT_CLASS
Definition: ABI.h:84
OnixS::CME::iLink3::Messaging::Month::Enum Month
Type presenting the month component.
Definition: Time.h:479
Int32 Hours
Integral type for number of hours.
Definition: Time.h:155
std::ostream & operator<<(std::ostream &os, const TimeSpan &value)
Definition: Time.h:804
void toStrAsYYYYMMDDHHMMSSpsec(std::string &, Timestamp)
Serializes the timestamp using the YYYYMMDDHHMMSSpsec format.
Int64 Ticks
Integral type presenting internal ticks.
Definition: Time.h:149
void toStrAsYYYYMMDDHHMMSSmsec(std::string &, Timestamp)
Serializes the timestamp using the YYYYMMDDHHMMSSmsec format.
void toStrAsHHMMSSnsec(std::string &, TimeSpan)
Serializes the timespan according to the HH:MM:SS.sssssssss pattern.
bool operator!=(const Timestamp &left, const Timestamp &right) noexcept
Compares instances.
Definition: Time.h:677
void toStrAsYYYYMMDDHHMMSS(std::string &, Timestamp)
Serializes the timestamp using the YYYYMMDDHHMMSS format.
Indicates a time span in the "HH:MM:SS.ssssss" format.
Definition: Time.h:126
Indicates a time span in the "HH:MM:SS.sssssssss" format.
Definition: Time.h:130
Indicates a time span in the "HH:MM:SS.ssssssssssss" format.
Definition: Time.h:134
#define ONIXS_ILINK3_MESSAGING_NAMESPACE_END
Definition: ABI.h:144
UInt32 Year
Integral type presenting the year component.
Definition: Time.h:474
#define ONIXS_ILINK3_EXPORTED
Definition: Compiler.h:175
bool operator==(const Timestamp &left, const Timestamp &right) noexcept
Compares instances.
Definition: Time.h:667
void swap(Timestamp &other) noexcept
Exchanges the value.
Definition: Time.h:635
Milliseconds milliseconds() const noexcept
Definition: Time.h:273
static constexpr Int32 microsecondsPerSecond() noexcept
Definition: Time.h:105
size_t toStr(Timestamp, Char *, size_t)
Serializes the timestamp.
UInt64 UInt64
uInt64.
Definition: Fields.h:308
UInt32 Millisecond
Integral type presenting the millisecond component.
Definition: Time.h:494
Microsecond microsecond() const noexcept
Definition: Time.h:591
Miscellaneous time characteristics.
Definition: Time.h:31
static constexpr Int64 nanosecondsPerDay() noexcept
Definition: Time.h:35
Int32 Minutes
Integral type for number of minutes.
Definition: Time.h:158
UInt32 UInt32
uInt32.
Definition: Fields.h:302
UInt32 Microsecond
Integral type presenting the microsecond component.
Definition: Time.h:497
Nanoseconds nanoseconds() const noexcept
Definition: Time.h:299
#define ONIXS_ILINK3_MESSAGING_NAMESPACE_BEGIN
Definition: ABI.h:140
Indicates a time span in the "HH:MM:SS" format.
Definition: Time.h:118
static constexpr Int32 nanosecondsPerSecond() noexcept
Definition: Time.h:56
Minutes minutes() const noexcept
Definition: Time.h:247
void toStrAsSDHHMMSSnsec(std::string &, TimeSpan)
Serializes the timespan according to the D.HH:MM:SS.sssssssss pattern.
Nanosecond nanosecond() const noexcept
Definition: Time.h:597
TimeSpan time() const noexcept
Definition: Time.h:613
bool operator<(const Timestamp &left, const Timestamp &right) noexcept
Compares instances.
Definition: Time.h:687
The time point without the time-zone information.
Definition: Time.h:467
UInt32 Minute
Integral type presenting the minute component.
Definition: Time.h:488
TimeSpan operator-(const Timestamp &left, const Timestamp &right) noexcept
Calculates the time interval between two time points.
Definition: Time.h:749
TimeSpan(Ticks ticks=0) noexcept
Initializes the timespan from the given number of ticks.
Definition: Time.h:177
Microseconds microseconds() const noexcept
Definition: Time.h:286
bool operator>(const Timestamp &left, const Timestamp &right) noexcept
Compares instances.
Definition: Time.h:707
void toStrAsHHMMSSusec(std::string &, TimeSpan)
Serializes the timespan according to the HH:MM:SS.ssssss pattern.
void toStrAsYYYYMMDD(std::string &, Timestamp)
Serializes the timestamp using the YYYYMMDD format.
#define ONIXS_ILINK3_NODISCARD
Definition: Compiler.h:185
void toStrAsHHMMSSpsec(std::string &, TimeSpan)
Serializes the timespan according to the HH:MM:SS.ssssssssssss pattern.
Timestamp(Ticks ticks=0) noexcept
Initializes from the number of ticks since epoch.
Definition: Time.h:507
#define ONIXS_ILINK3_NOTHROW
Definition: Compiler.h:176
#define ONIXS_ILINK3_LTWT_STRUCT
Definition: ABI.h:88
Timestamp & operator=(const Timestamp &other) noexcept
Definition: Time.h:627
Timestamp operator+(const Timestamp &timestamp, const TimeSpan &timeSpan) noexcept
Adds the time interval.
Definition: Time.h:727